This commit is contained in:
2026-09-03 21:48:46 +08:00
parent eca2c94aa3
commit b8826c3e92
@@ -938,11 +938,11 @@ class SmartLoadingServiceTest {
void allowsVolumeAndWeightWithinOneHundredFiftyPercent() {
stubAssignment();
ContainerBookingEntity tolerant = booking();
tolerant.setCapacityCbm(new BigDecimal("0.6666667"));
tolerant.setMaxWeightKg(new BigDecimal("2.6666667"));
tolerant.setCapacityCbm(new BigDecimal("1"));
tolerant.setMaxWeightKg(new BigDecimal("4"));
when(repository.booking(99L)).thenReturn(tolerant);
service.assign(1, new AssignRequest(10L, 20L, 2, 0, "assign-150-ok"), 7, "u");
service.assign(1, new AssignRequest(10L, 20L, 3, 0, "assign-150-ok"), 7, "u");
verify(splitPreloadService).ensurePendingForLoadingAllocation(9L, 10L, 7L, "u");
verify(repository).touch(1, 0, 7, "u");
@@ -952,12 +952,12 @@ class SmartLoadingServiceTest {
void rejectsVolumeOrWeightAboveOneHundredFiftyPercent() {
stubAssignment();
ContainerBookingEntity exceeded = booking();
exceeded.setCapacityCbm(new BigDecimal("0.6666"));
exceeded.setMaxWeightKg(new BigDecimal("2.6666"));
exceeded.setCapacityCbm(new BigDecimal("0.9999"));
exceeded.setMaxWeightKg(new BigDecimal("3.9999"));
when(repository.booking(99L)).thenReturn(exceeded);
BizException error = catchThrowableOfType(() -> service.assign(1,
new AssignRequest(10L, 20L, 2, 0, "assign-150-exceeded"), 7, "u"), BizException.class);
new AssignRequest(10L, 20L, 3, 0, "assign-150-exceeded"), 7, "u"), BizException.class);
assertThat(error.getResultCode()).isEqualTo(ResultCode.VALIDATION_FAILED);
assertThat(error.getMessage()).contains("150%");