fix: converge inbound pallets and retries
This commit is contained in:
+19
@@ -132,6 +132,25 @@ class WarehousePalletBatchServiceTest {
|
||||
assertThat(response.items()).extracting(value -> value.palletCode()).containsExactly("PAL-301");
|
||||
}
|
||||
|
||||
@Test
|
||||
void compensatedSourcePalletCodeReusesTheExistingIdlePhysicalPallet() {
|
||||
when(batches.insertIgnore(any())).thenReturn(1);
|
||||
WarehousePalletEntity existing = pallet(301L, 401L, "DP-260910-0001");
|
||||
existing.setStatus("IDLE");
|
||||
when(resources.reusablePublicPallet(WAREHOUSE, "DP-260910-0001")).thenReturn(existing);
|
||||
when(locks.reserve(any())).thenReturn(lockResponse(CUSTOMER_A, 501L));
|
||||
var request = new WarehousePalletBatchRequests.EnsureReserved(WAREHOUSE, "retry-container", List.of(
|
||||
new WarehousePalletBatchRequests.Item(CUSTOMER_A, "container:dropship-a:1", "PLAN-A", 1,
|
||||
"STANDARD", null, "DP-260910-0001")));
|
||||
|
||||
var response = service.ensureReserved(request);
|
||||
|
||||
assertThat(response.items()).extracting(value -> value.palletId()).containsExactly(301L);
|
||||
assertThat(response.items()).extracting(value -> value.palletCode()).containsExactly("DP-260910-0001");
|
||||
verify(resources, never()).createPallet(anyLong(), anyLong(), any());
|
||||
verify(locks).reserve(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void concurrentSameRequestReplaysWinningBatchWithoutCreatingResources() {
|
||||
AtomicReference<WarehousePalletBatchEntity> inserted = new AtomicReference<>();
|
||||
|
||||
Reference in New Issue
Block a user