fix(delivery): expose signed quantity and publish correct signature instant
This commit is contained in:
+27
-1
@@ -18,6 +18,30 @@ import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class OverseasDeliveryCompletedConsumerTest {
|
||||
@Test
|
||||
void preservesTheInstantOfAShanghaiSignatureInUtcInboundAndHistory() {
|
||||
var inbounds = mock(InboundOrderMapper.class);
|
||||
var histories = mock(InboundStatusHistoryMapper.class);
|
||||
var inbox = mock(ContainerEventInboxMapper.class);
|
||||
var orders = mock(OrderFulfillmentCompletionClient.class);
|
||||
var json = new ObjectMapper().registerModule(new JavaTimeModule());
|
||||
var consumer = new OverseasDeliveryCompletedConsumer(inbounds, histories, inbox, orders, json);
|
||||
var inbound = new InboundOrderEntity();
|
||||
inbound.setId(101L); inbound.setTenantId(88L); inbound.setOrderId(201L);
|
||||
inbound.setOrderNo("FL-201"); inbound.setInboundCode("IN-1"); inbound.setDestinationCode("ONT8");
|
||||
inbound.setProcessStatus("LOADED");
|
||||
when(inbounds.selectActiveByIdForUpdate(101L)).thenReturn(inbound);
|
||||
when(inbounds.completeOverseasDelivery(eq(88L), eq(101L), any())).thenReturn(1);
|
||||
when(inbounds.countNotDeliveredByOrder(88L, 201L)).thenReturn(1);
|
||||
var signature = java.time.LocalDateTime.of(2026, 10, 3, 22, 13)
|
||||
.atZone(java.time.ZoneId.of("Asia/Shanghai")).toInstant();
|
||||
consumer.consume(event(json, "201", signature));
|
||||
var expected = java.time.LocalDateTime.of(2026, 10, 3, 14, 13);
|
||||
verify(inbounds).completeOverseasDelivery(88L, 101L, expected);
|
||||
verify(histories).insert(argThat((com.baiyue.firstleg.entity.InboundStatusHistoryEntity history) -> expected.equals(history.getOccurredAt())
|
||||
&& "LOADED".equals(history.getFromStatus()) && "DELIVERED".equals(history.getToStatus())));
|
||||
verifyNoInteractions(orders);
|
||||
}
|
||||
@Test
|
||||
void completesOnlyEventSourceInboundAndOrder() {
|
||||
InboundOrderMapper inbounds = mock(InboundOrderMapper.class);
|
||||
@@ -111,7 +135,9 @@ class OverseasDeliveryCompletedConsumerTest {
|
||||
|
||||
private EventEnvelope event(ObjectMapper json) { return event(json, "201"); }
|
||||
private EventEnvelope event(ObjectMapper json, String rootOrderId) {
|
||||
Instant time = Instant.parse("2026-09-15T08:00:00Z");
|
||||
return event(json, rootOrderId, Instant.parse("2026-09-15T08:00:00Z"));
|
||||
}
|
||||
private EventEnvelope event(ObjectMapper json, String rootOrderId, Instant time) {
|
||||
var payload = new OverseasDeliveryCompletedV1("1", "DL-ONT8", "11", "LM-11",
|
||||
"101", "IN-1", "201", "FL-201", rootOrderId, "ONT8", time);
|
||||
var node = json.valueToTree(payload);
|
||||
|
||||
Reference in New Issue
Block a user