Test #1

Merged
admin merged 1726 commits from test into main 2026-09-17 11:52:45 +08:00
2 changed files with 6 additions and 12 deletions
Showing only changes of commit fa7a7b8630 - Show all commits
@@ -113,6 +113,7 @@ public class ReceivingContainerService {
return grouped.entrySet().stream()
.map(entry -> readiness(entry.getKey(), entry.getValue(), planFacts, lineFacts, overseasWarehouseId))
.filter(Objects::nonNull)
.filter(ContainerReadiness::shippingReady)
.filter(value -> !reservedByOthers.contains(activeContainerKey(value.containerNo())))
.map(value -> candidate(value, current)).toList();
}
@@ -479,7 +480,7 @@ public class ReceivingContainerService {
inboundValues.stream().mapToInt(ReceivingContainerResponses.Inbound::totalPackages).sum(),
inboundValues.stream().mapToInt(ReceivingContainerResponses.Inbound::receivedPackages).sum());
return new ContainerReadiness(sourceContainerBookingId, containerNo, totalOrders, inboundCodes,
totalOrders - inboundCodes, planCount, plannedOrders, pending, allPlansReady, operable,
totalOrders - inboundCodes, planCount, plannedOrders, pending, allPlansReady, shippingReady, operable,
blockReason, arrival, factHash, totals);
}
@@ -982,7 +983,7 @@ public class ReceivingContainerService {
private record ContainerReadiness(String sourceContainerBookingId, String containerNo,
int totalOrderCount, int inboundCodeCount, int missingInboundCodeCount,
int planCount, int plannedInboundCodeCount, int pendingPlanCount,
boolean allPlansReady, boolean operable, String blockReason,
boolean allPlansReady, boolean shippingReady, boolean operable, String blockReason,
LocalDateTime plannedArrivalAt, String factHash, Totals totals) { }
private record PrepareCommand(String containerNo, String idempotencyKey) { }
}
@@ -87,18 +87,14 @@ class ReceivingContainerServiceBehaviorTest {
}
@Test
void containerRemainsVisibleButPrepareIsRejectedBeforePickupReady() {
void containerIsHiddenAndPrepareIsRejectedBeforePickupReady() {
when(plans.selectList(any())).thenReturn(List.of(plan("CONT-A")));
when(lines.selectList(any())).thenReturn(List.of(line("FBA")));
LastlegOrder order = containerOrder(1L, "100", "CONT-A", "BOOKING-A", "IN-1");
when(orders.selectList(any())).thenReturn(List.of(order));
when(shippingGates.receivingAvailable("100", "CONT-A")).thenReturn(0);
assertThat(service.candidates("7", 100L)).singleElement().satisfies(candidate -> {
assertThat(candidate.operable()).isFalse();
assertThat(candidate.allPlansReady()).isTrue();
assertThat(candidate.blockReason()).contains("尚未达到");
});
assertThat(service.candidates("7", 100L)).isEmpty();
assertThatThrownBy(() -> service.prepare("7", "receiver", 100L, "CONT-A",
new ReceivingContainerRequests.Action("not-ready")))
.isInstanceOf(ResponseStatusException.class).hasMessageContaining("409");
@@ -155,10 +151,7 @@ class ReceivingContainerServiceBehaviorTest {
when(orders.selectList(any())).thenReturn(List.of(
containerOrder(1L, "100", "CONT-A", "BOOKING-A", "IN-1"),
containerOrder(2L, "200", "CONT-A", "BOOKING-A", "IN-2")));
assertThat(service.candidates("7", 100L)).singleElement().satisfies(candidate -> {
assertThat(candidate.operable()).isFalse();
assertThat(candidate.blockReason()).contains("未操作/缺入仓码");
});
assertThat(service.candidates("7", 100L)).isEmpty();
}
@Test