feat(lastleg): reserve pallets for container plans

This commit is contained in:
2026-09-09 00:15:23 +08:00
parent cf8053b7ce
commit 7b47de47c6
15 changed files with 700 additions and 18 deletions
@@ -8,6 +8,8 @@ import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestClient;
import org.springframework.web.server.ResponseStatusException;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
@@ -141,4 +143,38 @@ class HttpWarehouseResourceGatewayTest {
server.verify();
}
@Test
void ensurePalletBatchAcceptsJacksonStringEncodedLongs() {
server.expect(requestTo("http://warehouse/internal/v1/warehouse-pallet-batches/ensure-reserved"))
.andRespond(withSuccess("""
{"code":"200","data":{"batchId":"41","batchKey":"BATCH-1","status":"RESERVED",
"attemptNo":1,"replayed":false,"items":[{"customerId":"100","businessKey":"CIP:1:1",
"inboundPlanNo":"IP-21","sequenceNo":1,"palletId":"51","palletCode":"PLT-51",
"locationId":"61","resourceLockId":"71","status":"RESERVED"}]}}
""", MediaType.APPLICATION_JSON));
var result = gateway.ensurePalletBatch(new WarehouseResourceGateway.PalletBatchEnsure(31L, "BATCH-1",
List.of(new WarehouseResourceGateway.PalletBatchItemRequest(
100L, "CIP:1:1", "IP-21", 1, "STANDARD", "ONT8"))));
assertThat(result.batchId()).isEqualTo(41L);
assertThat(result.items().get(0).resourceLockId()).isEqualTo(71L);
server.verify();
}
@Test
void palletBatchMapsBusinessConflictEnvelopeEvenWithHttp200() {
server.expect(requestTo("http://warehouse/internal/v1/warehouse-pallet-batches/confirm"))
.andRespond(withSuccess("""
{"code":"A0409","message":"Batch request hash conflict","data":null}
""", MediaType.APPLICATION_JSON));
assertThatThrownBy(() -> gateway.confirmPalletBatch(
new WarehouseResourceGateway.PalletBatchCommand(31L, "BATCH-1", "CONFIRM:1")))
.isInstanceOf(ResponseStatusException.class)
.hasMessageContaining("409")
.hasMessageContaining("Batch request hash conflict");
server.verify();
}
}