From 4749bd3bc1458221d1b319449844fc89cd128388 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Mon, 10 Aug 2026 18:44:04 +0800 Subject: [PATCH] test(warehouse): cover PDA occupancy package counts --- .../PalletLocationAllocationServiceTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/warehouse/src/test/java/com/baiyue/warehouse/service/PalletLocationAllocationServiceTest.java b/warehouse/src/test/java/com/baiyue/warehouse/service/PalletLocationAllocationServiceTest.java index 7cb7530fa..13e037811 100644 --- a/warehouse/src/test/java/com/baiyue/warehouse/service/PalletLocationAllocationServiceTest.java +++ b/warehouse/src/test/java/com/baiyue/warehouse/service/PalletLocationAllocationServiceTest.java @@ -119,6 +119,27 @@ class PalletLocationAllocationServiceTest { verify(pallets, never()).findAvailable(any(Long.class), any(Long.class), any(), any(), any(Integer.class)); } + @Test + void confirmPersistsPackageCountOnEveryOccupancyTarget() { + LocationDtos.ActiveResource resource = new LocationDtos.ActiveResource( + 101L, 201L, 20L, 30L, "TP-001", 40L, "A-01", false, "RESERVED"); + when(locations.findActiveResources(10001L, "FIRSTLEG", 88L)).thenReturn(List.of(resource)); + when(locations.confirmOccupied(any())).thenReturn(List.of(new LocationDtos.OccupancyResult( + 301L, "OC-301", 101L, 30L, 40L, "A-01", false))); + when(pallets.transitionStatus(10001L, 20L, 30L, List.of("RESERVED"), "OCCUPIED")) + .thenReturn(1); + + service.confirm(new PalletAllocationDtos.ConfirmRequest(10001L, 20L, "FIRSTLEG", 88L, + 9001L, new BigDecimal("1.0"), new BigDecimal("2.0"), 20)); + + org.mockito.ArgumentCaptor command = + org.mockito.ArgumentCaptor.forClass(LocationDtos.ConfirmCommand.class); + verify(locations).confirmOccupied(command.capture()); + assertThat(command.getValue().targets()).singleElement() + .extracting(LocationDtos.OccupancyTarget::allocatedPackageCount) + .isEqualTo(20); + } + @Test void shouldReleaseOnlyPalletsReturnedBySelectedLocationRelease() { var resource = new LocationDtos.ExactSelectiveReleaseResult(