You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.9 KiB

package common.ecommerce.xincang.adapter;
import common.ecommerce.shared.support.Money;
import common.ecommerce.warehouse.capability.WarehouseProduct;
import common.ecommerce.warehouse.model.InboundCommand;
import common.ecommerce.warehouse.model.InboundLine;
import org.junit.jupiter.api.Test;
import java.time.LocalDate;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* 统一模型里「某家仓必填、其他仓不需要」的字段不再在构造期拦截。
*
* <p>这些用例守护的是:信仓可以只给它认识的字段就构造出命令,
* 不会因为运去哪的必填项(nameEn / packingType / 海关三项 / 入库商品行)
* 被迫塞无意义的值。</p>
*/
class XincangModelRelaxTest {
/** 商品:不给 nameEn / packingType / 海关三项也能构造(信仓都收不到这些字段)。 */
@Test
void productBuildsWithoutYqnOnlyFields() {
WarehouseProduct product = WarehouseProduct.builder()
.omsSku("SKU-1")
.name("中文名")
.lengthCm(10).widthCm(10).heightCm(10).weightGrams(100)
.build();
assertNotNull(product);
}
/**
* 商品:信仓 amount 必填,但只需要 declaredValue,不需要 hsCode / countryOfOrigin。
*
* <p>改前「海关三项必须整组给」在构造期强制,信仓调用方被迫填两个用不上的字段。</p>
*/
@Test
void productCustomsValueAloneIsAccepted() {
WarehouseProduct product = WarehouseProduct.builder()
.omsSku("SKU-2")
.name("中文名")
.lengthCm(10).widthCm(10).heightCm(10).weightGrams(100)
.declaredValue(Money.of("1.00", "USD"))
.build();
assertNotNull(product);
}
/** 入库:信仓「新增预报」只建单头,可以没有商品行(明细走「完善资料」)。 */
@Test
void inboundHeaderOnlyIsEnoughForForecastCreate() {
InboundCommand head = InboundCommand.builder()
.inboundRequestNo("FC-1")
.warehouseId("NJ-2605")
.shipmentType("2")
.cabinetType("1")
.containerNo("CAB-1")
.predictionShipDate(LocalDate.now().plusDays(1))
.estimateArriveDate(LocalDate.now().plusDays(30))
.deliveryRequirements("1")
.referenceSkuCount(3)
.build();
assertNotNull(head);
}
/** 入库:完善资料阶段要明细,这时才加行,模型允许。 */
@Test
void inboundWithLinesStillWorks() {
InboundCommand withLines = InboundCommand.builder()
.inboundRequestNo("FC-2")
.warehouseId("NJ-2605")
.line(InboundLine.builder().omsSku("SKU-1").quantity(1).build())
.build();
assertNotNull(withLines);
}
}