fix(lastleg): unblock inbound plan handoff
This commit is contained in:
+32
-4
@@ -4,8 +4,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
class FirstLegLoadingPlanCompletedV2Test {
|
||||
@Test
|
||||
@@ -14,7 +16,8 @@ class FirstLegLoadingPlanCompletedV2Test {
|
||||
2, null, null, null, null, null, null, null, null, null, null, null,
|
||||
"客户备注", "内部备注", "仓库备注");
|
||||
var order = new FirstLegLoadingPlanCompletedV2.Order("2", "2", "3", "ORD", "3", "RK",
|
||||
null, null, null, 1, 2, null, null, null, null, List.of(item));
|
||||
null, null, null, 1, 2, null, null, null, null, List.of(item),
|
||||
"11", "客户甲", "FIRST_LEG", List.of());
|
||||
var payload = new FirstLegLoadingPlanCompletedV2("4", "P", "5", "CONT", "CAB", "6", "WH", List.of(order));
|
||||
String json = new ObjectMapper().writeValueAsString(payload);
|
||||
assertThat(json).contains("customerRemark", "internalRemark", "warehouseRemark");
|
||||
@@ -29,13 +32,14 @@ class FirstLegLoadingPlanCompletedV2Test {
|
||||
var pallet = new FirstLegLoadingPlanCompletedV2.PalletSnapshot("PLT-01", List.of(sku));
|
||||
var order = new FirstLegLoadingPlanCompletedV2.Order(
|
||||
"2", "2", "3", "ORD", "3", "RK", null, null, null,
|
||||
2, 20, 1, null, null, null, List.of(), "11", "ONE_CLICK_DROPSHIP", List.of(pallet));
|
||||
2, 20, 1, null, null, null, List.of(), "11", "客户甲", "ONE_CLICK_DROPSHIP", List.of(pallet));
|
||||
var payload = new FirstLegLoadingPlanCompletedV2(
|
||||
"4", "P", "5", "CONT", "CAB", "6", "WH", List.of(order));
|
||||
|
||||
var json = new ObjectMapper().valueToTree(payload);
|
||||
|
||||
assertThat(json.at("/orders/0/customerId").asText()).isEqualTo("11");
|
||||
assertThat(json.at("/orders/0/customerName").asText()).isEqualTo("客户甲");
|
||||
assertThat(json.at("/orders/0/orderType").asText()).isEqualTo("ONE_CLICK_DROPSHIP");
|
||||
assertThat(json.at("/orders/0/pallets/0/skuPackages/0/cartonMarks")).hasSize(2);
|
||||
}
|
||||
@@ -44,7 +48,7 @@ class FirstLegLoadingPlanCompletedV2Test {
|
||||
void carriesFrozenDestinationType() {
|
||||
var order = new FirstLegLoadingPlanCompletedV2.Order(
|
||||
"2", "2", "3", "ORD", "3", "RK", null, "ONT8", "FBA ONT8",
|
||||
2, 20, 0, null, null, null, List.of(), "11", "FIRST_LEG", List.of(), "FBA");
|
||||
2, 20, 0, null, null, null, List.of(), "11", "客户甲", "FIRST_LEG", List.of(), "FBA");
|
||||
|
||||
var json = new ObjectMapper().valueToTree(new FirstLegLoadingPlanCompletedV2(
|
||||
"4", "P", "5", "CONT", "CAB", "6", "WH", List.of(order)));
|
||||
@@ -58,7 +62,8 @@ class FirstLegLoadingPlanCompletedV2Test {
|
||||
20, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, List.of("HDHK260711126-01", "HDHK260711126-02"));
|
||||
var order = new FirstLegLoadingPlanCompletedV2.Order("2", "2", "3", "ORD", "3", "RK",
|
||||
null, null, null, 2, 20, null, null, null, null, List.of(item));
|
||||
null, null, null, 2, 20, null, null, null, null, List.of(item),
|
||||
"11", "客户甲", "FIRST_LEG", List.of());
|
||||
|
||||
var json = new ObjectMapper().valueToTree(new FirstLegLoadingPlanCompletedV2(
|
||||
"4", "P", "5", "CONT", "CAB", "6", "WH", List.of(order)));
|
||||
@@ -66,4 +71,27 @@ class FirstLegLoadingPlanCompletedV2Test {
|
||||
assertThat(json.at("/orders/0/items/0/skuCode").asText()).isEqualTo("SKU-PSC2");
|
||||
assertThat(json.at("/orders/0/items/0/cartonMarks")).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMissingImmutableCustomerName() {
|
||||
assertThatThrownBy(() -> new FirstLegLoadingPlanCompletedV2.Order(
|
||||
"2", "2", "3", "ORD", "3", "RK", null, null, null,
|
||||
1, 1, 0, null, null, null, List.of(), "11", " ", "FIRST_LEG", List.of()))
|
||||
.isInstanceOf(IllegalArgumentException.class).hasMessageContaining("customerName");
|
||||
}
|
||||
|
||||
@Test
|
||||
void openApiRequiresImmutableCustomerNameNextToCustomerId() throws Exception {
|
||||
String yaml;
|
||||
try (var input = FirstLegLoadingPlanCompletedV2Test.class.getResourceAsStream(
|
||||
"/openapi/cross-region-events-v1.yaml")) {
|
||||
assertThat(input).isNotNull();
|
||||
yaml = new String(input.readAllBytes(), StandardCharsets.UTF_8);
|
||||
}
|
||||
assertThat(yaml)
|
||||
.contains("required: [sourceInboundId, customerId, customerName")
|
||||
.contains("customerId: {type: string, minLength: 1")
|
||||
.contains("customerName: {type: string, minLength: 1, maxLength: 128")
|
||||
.contains("consumers must not query domestic IAM");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user