fix(lastleg): inspect occupied pallets for PDA queries

This commit is contained in:
2026-09-08 23:34:12 +08:00
parent 3e15ad6b5b
commit 0c984e8f5f
7 changed files with 68 additions and 12 deletions
@@ -64,6 +64,24 @@ class HttpWarehouseResourceGatewayTest {
server.verify();
}
@Test
void inspectAllowsOccupiedPalletForReadOnlyInventoryQueries() {
server.expect(requestTo("http://warehouse/internal/v1/warehouse-pallets/resolve/PAL-OCCUPIED"))
.andRespond(withSuccess("""
{"code":"200","data":{"palletId":2092040891261427713,"palletCode":"PAL-OCCUPIED",
"warehouseId":2092040869757231105,"locationId":2092040891076878337,
"status":"OCCUPIED","fbaWarehouseCode":null,"version":4,
"locationType":"STORAGE","locationStatus":"OCCUPIED","reservable":false,
"reservationBlockReason":"PALLET_NOT_IDLE"}}
""", MediaType.APPLICATION_JSON));
WarehouseResourceGateway.WarehousePalletReference result = gateway.inspectPallet("PAL-OCCUPIED");
assertThat(result.palletId()).isEqualTo(2092040891261427713L);
assertThat(result.status()).isEqualTo("OCCUPIED");
server.verify();
}
@Test
void resolveFailsClosedWhenWarehouseOmitsReservationFacts() {
server.expect(requestTo("http://warehouse/internal/v1/warehouse-pallets/resolve/PAL-UNKNOWN"))
@@ -42,7 +42,7 @@ class PdaWarehouseServiceTest {
@Test
void palletFromAnotherWarehouseIsRejected() {
when(warehouse.resolvePallet("PAL-1")).thenReturn(new WarehouseResourceGateway.WarehousePalletReference(
when(warehouse.inspectPallet("PAL-1")).thenReturn(new WarehouseResourceGateway.WarehousePalletReference(
1L, "PAL-1", 901L, 2L, "OCCUPIED", null, 1));
assertThatThrownBy(() -> service.pallet(900L, new PdaWarehouseRequests.Scan("PAL-1")))
.isInstanceOf(ResponseStatusException.class).hasMessageContaining("409");
@@ -50,7 +50,7 @@ class PdaWarehouseServiceTest {
@Test
void missingPalletIsReportedAsNotFound() {
when(warehouse.resolvePallet("MISSING")).thenReturn(null);
when(warehouse.inspectPallet("MISSING")).thenReturn(null);
assertThatThrownBy(() -> service.pallet(900L, new PdaWarehouseRequests.Scan("MISSING")))
.isInstanceOf(ResponseStatusException.class).hasMessageContaining("404");