优化提交
This commit is contained in:
+17
@@ -111,6 +111,23 @@ class WarehousePalletTransitionServiceTest {
|
||||
verify(mapper, never()).transitionLocation(anyLong(), anyLong(), anyString(), anyString());
|
||||
}
|
||||
|
||||
@Test void locationlessPalletCanChangeStatusWithoutSelectingLocation() {
|
||||
WarehousePalletEntity pallet = pallet("P-NO-LOCATION", "IDLE", 2);
|
||||
pallet.setLocationId(null);
|
||||
when(mapper.lockPublicPallet(88L, 10L)).thenReturn(pallet);
|
||||
when(mapper.transition(88L, 10L, "OCCUPIED", null, 2)).thenReturn(1);
|
||||
|
||||
var response = service.apply(10L, new PalletTransitionRequests.Apply(
|
||||
88L, 2, "OCCUPIED", null, "locationless-occupy", "pallet-only operation"));
|
||||
|
||||
assertNull(response.beforeLocationId());
|
||||
assertNull(response.afterLocationId());
|
||||
assertEquals("OCCUPIED", response.afterStatus());
|
||||
verify(mapper, never()).lockPublicLocation(anyLong(), anyLong());
|
||||
verify(mapper, never()).transitionLocation(anyLong(), anyLong(), anyString(), anyString());
|
||||
verify(mapper).transition(88L, 10L, "OCCUPIED", null, 2);
|
||||
}
|
||||
|
||||
@Test void inconsistentIdlePalletAndOccupiedLocationIsRejectedBeforeMutation() {
|
||||
when(mapper.lockPublicPallet(88L, 10L)).thenReturn(pallet("P-1", "IDLE", 4));
|
||||
when(mapper.lockPublicLocation(88L, 11L)).thenReturn(location(11L, "STORAGE", "OCCUPIED"));
|
||||
|
||||
+33
@@ -7,6 +7,7 @@ import com.baiyue.warehouse.dto.LocationRequests;
|
||||
import com.baiyue.warehouse.dto.PalletRequests;
|
||||
import com.baiyue.warehouse.entity.WarehouseLocationEntity;
|
||||
import com.baiyue.warehouse.entity.WarehousePalletEntity;
|
||||
import com.baiyue.warehouse.entity.WarehousePalletBindingEntity;
|
||||
import com.baiyue.warehouse.dto.SharedWarehouseReference;
|
||||
import com.baiyue.warehouse.repository.WarehouseResourceRepository;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -97,6 +98,21 @@ class WarehouseResourceServiceTest {
|
||||
assertThat(result.reservationBlockReason()).isEqualTo("LOCATION_NOT_IDLE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolvesLocationlessPalletForPalletOnlyWorkflow() {
|
||||
WarehousePalletEntity pallet = pallet(40001L, "IDLE", 30001L);
|
||||
pallet.setLocationId(null);
|
||||
when(repository.findPublicPalletsByCode("PLT-NO-LOCATION")).thenReturn(List.of(pallet));
|
||||
pallet.setPalletCode("PLT-NO-LOCATION");
|
||||
|
||||
var result = service.resolvePublicPallet("PLT-NO-LOCATION");
|
||||
|
||||
assertThat(result.locationId()).isNull();
|
||||
assertThat(result.reservable()).isFalse();
|
||||
assertThat(result.reservationBlockReason()).isEqualTo("LOCATION_NOT_REQUIRED");
|
||||
verify(repository, never()).findLocation(0L, WAREHOUSE, 0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createsLocationWithSnowflakeAssignedByMapper() {
|
||||
doAnswer(invocation -> {
|
||||
@@ -378,6 +394,23 @@ class WarehouseResourceServiceTest {
|
||||
verify(repository, never()).updatePallet(org.mockito.ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void relabelPalletCreationReplaysExistingBusinessBinding() {
|
||||
WarehousePalletBindingEntity binding = new WarehousePalletBindingEntity();
|
||||
binding.setPalletId(40001L);
|
||||
when(repository.findPalletBinding(0L, WAREHOUSE, "RELABEL_PDA_NEW", "RL-1:key-1"))
|
||||
.thenReturn(binding);
|
||||
when(repository.findPublicPallet(40001L)).thenReturn(pallet(40001L, "IDLE", 30001L));
|
||||
when(repository.findLocation(0L, WAREHOUSE, 30001L)).thenReturn(location(30001L, "VIRTUAL", "ACTIVE"));
|
||||
|
||||
var result = service.ensureRelabelPallet(WAREHOUSE, " RL-1:key-1 ");
|
||||
|
||||
assertThat(result.palletId()).isEqualTo(40001L);
|
||||
assertThat(result.palletCode()).isEqualTo("PLT-01");
|
||||
verify(repository, never()).insertPallet(org.mockito.ArgumentMatchers.any());
|
||||
verify(repository, never()).insertPalletBinding(org.mockito.ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
private static SharedWarehouseReference warehouse() {
|
||||
return new SharedWarehouseReference(WAREHOUSE, "US-LAX-01", "Los Angeles", "ACTIVE");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user