fix: replay completed pallet operations
This commit is contained in:
+20
@@ -27,6 +27,7 @@ import org.springframework.transaction.support.DefaultTransactionStatus;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
@@ -119,6 +120,25 @@ class PdaPalletOperationServiceTest {
|
||||
assertEquals("PDAOPS-LONG-LOCATION-CODE", ledger.getValue().getWarehouseLocationCode());
|
||||
}
|
||||
|
||||
@Test void exactReplayReturnsStoredResultBeforeValidatingChangedPalletVersions() throws Exception {
|
||||
var request = new PalletOperationRequests.Swap("idem-replay",
|
||||
new PalletOperationRequests.PalletExpectation("SOURCE", 1),
|
||||
new PalletOperationRequests.PalletExpectation("TARGET", 2), "swap");
|
||||
PdaPalletOperation existing = new PdaPalletOperation(); existing.setId(500L);
|
||||
existing.setOperationType("PALLET_SWAP"); existing.setStatus("COMPLETED");
|
||||
existing.setRequestHash(ReflectionTestUtils.invokeMethod(service, "hash", request));
|
||||
var stored = new com.baiyue.lastleg.palletops.dto.PalletOperationResponses.Operation(
|
||||
500L, "PALLET_SWAP", "idem-replay", "COMPLETED", false, LocalDateTime.now(), List.of());
|
||||
existing.setResultJson(new ObjectMapper().findAndRegisterModules().writeValueAsString(stored));
|
||||
when(mapper.findOperation("7", "idem-replay")).thenReturn(existing);
|
||||
|
||||
var replay = service.swap(identity(), request);
|
||||
|
||||
assertTrue(replay.replayed());
|
||||
assertEquals(500L, replay.operationId());
|
||||
verifyNoInteractions(physical);
|
||||
}
|
||||
|
||||
private static PdaWarehouseIdentity identity() { return new PdaWarehouseIdentity("7", "picker", 88L); }
|
||||
private static PalletPhysicalGateway.PalletReference pallet(long id, String code, long warehouse, int version) {
|
||||
return new PalletPhysicalGateway.PalletReference(id, code, warehouse, 1000L + id,
|
||||
|
||||
Reference in New Issue
Block a user