优化
This commit is contained in:
+5
-1
@@ -57,7 +57,11 @@ class PlatformOceanBookingControllerContractTest {
|
||||
String yaml = Files.readString(Path.of("src/main/resources/openapi/ocean-bookings-v1.yaml"));
|
||||
assertThat(yaml).contains("/api/platform/v1/ocean-bookings/channels:",
|
||||
"originWarehouseId", "platform:firstleg:ocean-booking:list", "ChannelOption")
|
||||
.contains("required: [customerId, customerName, channelCode, warehouseId, warehouseName")
|
||||
.contains("required: [channelCode, warehouseId, warehouseName, serviceTerm, freightTerm, parties, containerRequirements]")
|
||||
.contains("customerId: {type: integer, format: int64, minimum: 1, nullable: true")
|
||||
.contains("customerName: {type: string, maxLength: 128, nullable: true")
|
||||
.contains("serviceTerm: {type: string, maxLength: 32, description: Required free-text")
|
||||
.contains("freightTerm: {type: string, maxLength: 32, description: Required free-text")
|
||||
.doesNotContain("required: [customerId, customerName, channelCode, channelName");
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -18,6 +18,10 @@ class OceanBookingSqlContractTest {
|
||||
.contains("CREATE TABLE IF NOT EXISTS fl_ocean_booking_container_allocation")
|
||||
.contains("CREATE TABLE IF NOT EXISTS fl_ocean_booking_status_history")
|
||||
.contains("CREATE TABLE IF NOT EXISTS fl_ocean_booking_operation")
|
||||
.contains("customer_id BIGINT UNSIGNED NULL COMMENT '可选客户ID快照'")
|
||||
.contains("customer_name VARCHAR(128) NULL COMMENT '可选客户名称快照'")
|
||||
.contains("service_term VARCHAR(32) NOT NULL COMMENT '运输服务条款快照'")
|
||||
.contains("freight_term VARCHAR(32) NOT NULL COMMENT '海运费支付条款快照'")
|
||||
.contains("container_booking_id BIGINT UNSIGNED NOT NULL COMMENT '明确引用现有柜次ID'")
|
||||
.contains("REFERENCES fl_container_booking(id)")
|
||||
.doesNotContain("ALTER TABLE fl_container_booking");
|
||||
|
||||
+49
-2
@@ -214,6 +214,49 @@ class OceanBookingServiceTest {
|
||||
assertThat(result.oceanBooking().getChannelName()).isEqualTo("价格簿美西海运");
|
||||
}
|
||||
|
||||
@Test
|
||||
void savesEmptyCustomerSnapshotAndFreeTextTransportTerms() {
|
||||
ChannelRow channel = channel("SEA-US", "价格簿美西海运");
|
||||
when(priceBooks.activeVersionId()).thenReturn(51L);
|
||||
when(priceBooks.channels(51L, 701L)).thenReturn(List.of(channel));
|
||||
AtomicReference<OceanBookingEntity> inserted = new AtomicReference<>();
|
||||
doAnswer(invocation -> { inserted.set(invocation.getArgument(0)); return null; })
|
||||
.when(repository).insert(any(OceanBookingEntity.class));
|
||||
when(repository.find(anyLong())).thenAnswer(invocation -> inserted.get());
|
||||
|
||||
Detail result = service.create(9L, "admin", "create-without-customer",
|
||||
new CreateRequest(0, draft(null, null, "CY-CY", "NINGBO")));
|
||||
|
||||
assertThat(result.oceanBooking().getCustomerId()).isNull();
|
||||
assertThat(result.oceanBooking().getCustomerName()).isNull();
|
||||
assertThat(result.oceanBooking().getServiceTerm()).isEqualTo("CY-CY");
|
||||
assertThat(result.oceanBooking().getFreightTerm()).isEqualTo("NINGBO");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsPartialCustomerSnapshot() {
|
||||
assertThatThrownBy(() -> service.create(9L, "admin", "partial-customer-id",
|
||||
new CreateRequest(0, draft(100L, null, null, null))))
|
||||
.isInstanceOf(BizException.class).hasMessageContaining("客户ID和客户名称必须同时填写或同时为空");
|
||||
assertThatThrownBy(() -> service.create(9L, "admin", "partial-customer-name",
|
||||
new CreateRequest(0, draft(null, "客户", null, null))))
|
||||
.isInstanceOf(BizException.class).hasMessageContaining("客户ID和客户名称必须同时填写或同时为空");
|
||||
|
||||
verifyNoInteractions(priceBooks);
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMissingRequiredTransportTerms() {
|
||||
assertThatThrownBy(() -> service.create(9L, "admin", "missing-service-term",
|
||||
new CreateRequest(0, draft(100L, "客户", null, "NINGBO"))))
|
||||
.isInstanceOf(BizException.class).hasMessageContaining("Service Term和Freight Term不能为空");
|
||||
assertThatThrownBy(() -> service.create(9L, "admin", "blank-freight-term",
|
||||
new CreateRequest(0, draft(100L, "客户", "CY-CY", " "))))
|
||||
.isInstanceOf(BizException.class).hasMessageContaining("Service Term和Freight Term不能为空");
|
||||
|
||||
verifyNoInteractions(priceBooks);
|
||||
}
|
||||
|
||||
@Test
|
||||
void replaysCreateAfterChannelIsNoLongerActive() throws Exception {
|
||||
ChannelRow channel = channel("SEA-US", "价格簿美西海运");
|
||||
@@ -280,15 +323,19 @@ class OceanBookingServiceTest {
|
||||
}
|
||||
|
||||
private static DraftData draft() {
|
||||
return draft(100L, "客户", "CY-CY", "NINGBO");
|
||||
}
|
||||
|
||||
private static DraftData draft(Long customerId, String customerName, String serviceTerm, String freightTerm) {
|
||||
List<PartyRequest> parties = List.of(
|
||||
new PartyRequest("SHIPPER", "发货人", null, null, null),
|
||||
new PartyRequest("CONSIGNEE", "收货人", null, null, null),
|
||||
new PartyRequest("NOTIFY_PARTY", "通知人", null, null, null));
|
||||
List<ContainerRequirementRequest> requirements = List.of(
|
||||
new ContainerRequirementRequest("40HQ", "DRY", BigDecimal.ONE, BigDecimal.TEN, 1));
|
||||
return new DraftData(100L, "客户", "SEA-US", 701L, "深圳仓", null,
|
||||
return new DraftData(customerId, customerName, "SEA-US", 701L, "深圳仓", null,
|
||||
81L, "船公司", null, null, null, null, "CNSZX", "深圳", "USLAX", "洛杉矶",
|
||||
null, null, null, null, null, null, parties, requirements);
|
||||
null, serviceTerm, freightTerm, null, null, null, parties, requirements);
|
||||
}
|
||||
|
||||
private String hashForSubmit() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user