fix(firstleg): map declaration inbound projection
This commit is contained in:
+6
@@ -13,6 +13,12 @@ class OrderDeclarationSyncMapperContractTest {
|
||||
@Test
|
||||
void mapperIsExplicitAndProjectionUpdateCannotOverwriteOperationalFacts() throws Exception {
|
||||
assertThat(OrderDeclarationSyncMapper.class).hasAnnotation(Mapper.class);
|
||||
assertThat(OrderDeclarationSyncMapper.class
|
||||
.getDeclaredMethod("lockInbound", long.class, long.class).getReturnType())
|
||||
.isEqualTo(OrderDeclarationSyncMapper.InboundRow.class);
|
||||
assertThat(OrderDeclarationSyncMapper.InboundRow.class.getRecordComponents())
|
||||
.extracting(java.lang.reflect.RecordComponent::getName)
|
||||
.containsExactly("inboundId", "orderId", "orderNo", "inboundCode", "processStatus", "channelCode");
|
||||
String sql = String.join(" ", OrderDeclarationSyncMapper.class
|
||||
.getDeclaredMethod("updateAllowedSnapshot", long.class, long.class, long.class, String.class,
|
||||
String.class, String.class, java.time.LocalDateTime.class, String.class, String.class, long.class)
|
||||
|
||||
+8
-3
@@ -66,7 +66,7 @@ class OrderDeclarationSyncServiceTest {
|
||||
@Test
|
||||
void persistsVersionedDeclarationAndUpdatesOnlyAllowedInboundProjection() {
|
||||
var event = event(4, "event-4");
|
||||
when(mapper.lockInbound(10001L, 77L)).thenReturn(row("WAIT_MEASURE", null, null, null, null));
|
||||
when(mapper.lockInbound(10001L, 77L)).thenReturn(inboundRow("WAIT_MEASURE"));
|
||||
when(mapper.insertSnapshot(anyLong(), anyLong(), anyString(), anyInt(), anyString(), any(), any(),
|
||||
anyString(), anyString(), anyString(), anyString(), any())).thenReturn(1);
|
||||
when(mapper.insertConsumedEvent(anyLong(), anyString(), anyLong(), anyInt(), anyString())).thenReturn(1);
|
||||
@@ -82,7 +82,7 @@ class OrderDeclarationSyncServiceTest {
|
||||
@Test
|
||||
void ignoresOlderVersionWithoutOverwritingCurrentProjection() {
|
||||
var event = event(4, "event-4");
|
||||
when(mapper.lockInbound(10001L, 77L)).thenReturn(row("WAIT_MEASURE", null, null, null, null));
|
||||
when(mapper.lockInbound(10001L, 77L)).thenReturn(inboundRow("WAIT_MEASURE"));
|
||||
when(mapper.lockSnapshot(10001L, 77L)).thenReturn(
|
||||
new OrderDeclarationSyncMapper.SnapshotRow(10001L, 77L, "event-5", 5, "hash"));
|
||||
when(mapper.insertConsumedEvent(anyLong(), anyString(), anyLong(), anyInt(), anyString())).thenReturn(1);
|
||||
@@ -101,7 +101,7 @@ class OrderDeclarationSyncServiceTest {
|
||||
var event = event(4, "event-4");
|
||||
String hash = HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256")
|
||||
.digest(json.writeValueAsBytes(event)));
|
||||
when(mapper.lockInbound(10001L, 77L)).thenReturn(row("WAIT_MEASURE", null, null, null, null));
|
||||
when(mapper.lockInbound(10001L, 77L)).thenReturn(inboundRow("WAIT_MEASURE"));
|
||||
when(mapper.byEvent(10001L, "event-4")).thenReturn(
|
||||
new OrderDeclarationSyncMapper.SnapshotRow(10001L, 77L, "event-4", 4, hash));
|
||||
|
||||
@@ -118,6 +118,11 @@ class OrderDeclarationSyncServiceTest {
|
||||
"MATSON_OLD", group, split, preload, pda);
|
||||
}
|
||||
|
||||
private static OrderDeclarationSyncMapper.InboundRow inboundRow(String status) {
|
||||
return new OrderDeclarationSyncMapper.InboundRow(
|
||||
88L, 77L, "FL-77", "RK-77", status, "MATSON_OLD");
|
||||
}
|
||||
|
||||
private static OrderDeclarationSync.UpdatedEvent event(int version, String eventId) {
|
||||
var cargo = new OrderDeclarationSync.Cargo(1, "衣服", "clothes", "SKU-1", null, 2, 20,
|
||||
new BigDecimal("10"), new BigDecimal("20"), new BigDecimal("30"), new BigDecimal("37"),
|
||||
|
||||
Reference in New Issue
Block a user