1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package cn.iocoder.yudao.module.srm.service.tender;
 
import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierQuoteDO;
import cn.iocoder.yudao.module.srm.dal.dataobject.SrmTenderMaterialDO;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
 
class SrmPurchaseQuoteValidationTest {
    private SrmTenderMaterialDO material(long id) { return new SrmTenderMaterialDO().setId(id).setProductId(id).setQuantity(BigDecimal.ONE); }
    private SrmSupplierQuoteDO quote(long id) { return new SrmSupplierQuoteDO().setTenderMaterialId(id).setQuotePrice(BigDecimal.TEN); }
    @Test void missingQuoteCannotCreatePartialOrder() {
        assertThrows(RuntimeException.class, () -> SrmPurchaseQuoteValidator.validate(List.of(material(1),material(2)), List.of(quote(1))));
    }
    @Test void duplicateQuoteCannotSilentlyChooseOne() {
        assertThrows(RuntimeException.class, () -> SrmPurchaseQuoteValidator.validate(List.of(material(1)), List.of(quote(1),quote(1))));
    }
    @Test void completeQuoteProducesAllMaterials() {
        assertEquals(2, SrmPurchaseQuoteValidator.validate(List.of(material(1),material(2)), List.of(quote(1),quote(2))).size());
    }
}