优化
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
||||
package com.baiyue.common.event;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class FirstLegLoadingPlanCompletedV3Test {
|
||||
@Test
|
||||
void carriesExactlyFiveDomesticLoadingPhotoReferences() {
|
||||
var json = new ObjectMapper().valueToTree(payload(evidence()));
|
||||
|
||||
assertThat(json.path("loadingEvidence")).hasSize(5);
|
||||
assertThat(json.at("/loadingEvidence/4/evidenceType").asText()).isEqualTo("SEAL");
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMissingOrDuplicatePhotoTypes() {
|
||||
assertThatThrownBy(() -> payload(evidence().subList(0, 4)))
|
||||
.hasMessageContaining("five unique");
|
||||
assertThatThrownBy(() -> payload(List.of(
|
||||
photo("PHOTO_STEP_1", 1), photo("PHOTO_STEP_1", 2), photo("PHOTO_STEP_2", 3),
|
||||
photo("PHOTO_STEP_3", 4), photo("SEAL", 5))))
|
||||
.hasMessageContaining("five unique");
|
||||
}
|
||||
|
||||
private FirstLegLoadingPlanCompletedV3 payload(List<FirstLegLoadingPlanCompletedV3.LoadingEvidence> photos) {
|
||||
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");
|
||||
return new FirstLegLoadingPlanCompletedV3(
|
||||
"4", "P", "5", "ZCSU7881970", "CAB", "6", "WH",
|
||||
null, null, null, List.of(order), photos);
|
||||
}
|
||||
|
||||
private List<FirstLegLoadingPlanCompletedV3.LoadingEvidence> evidence() {
|
||||
return List.of(photo("PHOTO_STEP_1", 1), photo("PHOTO_STEP_2", 2),
|
||||
photo("PHOTO_STEP_3", 3), photo("PHOTO_STEP_4", 4), photo("SEAL", 5));
|
||||
}
|
||||
|
||||
private FirstLegLoadingPlanCompletedV3.LoadingEvidence photo(String type, long id) {
|
||||
return new FirstLegLoadingPlanCompletedV3.LoadingEvidence(type, id, type + ".jpg");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user