test: lock weighted Mojia carton totals
This commit is contained in:
+16
-5
@@ -81,7 +81,7 @@ class CartonMeasurementServiceTest {
|
|||||||
when(repository.listItems(10001L, 30001L)).thenAnswer(invocation -> List.of(insertedItem.get()));
|
when(repository.listItems(10001L, 30001L)).thenAnswer(invocation -> List.of(insertedItem.get()));
|
||||||
when(repository.updateMeasurement(measurement)).thenReturn(true);
|
when(repository.updateMeasurement(measurement)).thenReturn(true);
|
||||||
|
|
||||||
CartonMeasurementResult result = service.upsert(10001L, 90001L, command());
|
CartonMeasurementResult result = service.upsert(10001L, 90001L, acceptanceCommand());
|
||||||
|
|
||||||
assertThat(result.created()).isTrue();
|
assertThat(result.created()).isTrue();
|
||||||
assertThat(result.confirmedPackageCount()).isEqualTo(1);
|
assertThat(result.confirmedPackageCount()).isEqualTo(1);
|
||||||
@@ -96,18 +96,21 @@ class CartonMeasurementServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
void repeatedScanReplacesDeviceValuesButPreservesManualCountAndOldImageIsDeleted() {
|
void repeatedScanReplacesDeviceValuesButPreservesManualCountAndOldImageIsDeleted() {
|
||||||
InboundMeasurementEntity measurement = measurement(30001L, "RECEIVED", 4);
|
InboundMeasurementEntity measurement = measurement(30001L, "RECEIVED", 4);
|
||||||
InboundMeasurementItemEntity existing = item(40001L, 30001L, 7, 88001L);
|
InboundMeasurementItemEntity existing = item(40001L, 30001L, 4, 88001L);
|
||||||
when(repository.findItemByBoxCode(10001L, "RK-001#5-1")).thenReturn(existing);
|
when(repository.findItemByBoxCode(10001L, "RK-001#5-1")).thenReturn(existing);
|
||||||
when(repository.findMeasurement(10001L, 70001L, 30001L)).thenReturn(measurement);
|
when(repository.findMeasurement(10001L, 70001L, 30001L)).thenReturn(measurement);
|
||||||
when(repository.updateItem(existing)).thenReturn(true);
|
when(repository.updateItem(existing)).thenReturn(true);
|
||||||
when(repository.listItems(10001L, 30001L)).thenReturn(List.of(existing));
|
when(repository.listItems(10001L, 30001L)).thenReturn(List.of(existing));
|
||||||
when(repository.updateMeasurement(measurement)).thenReturn(true);
|
when(repository.updateMeasurement(measurement)).thenReturn(true);
|
||||||
|
|
||||||
CartonMeasurementResult result = service.upsert(10001L, 90001L, command());
|
CartonMeasurementResult result = service.upsert(10001L, 90001L, acceptanceCommand());
|
||||||
|
|
||||||
assertThat(result.created()).isFalse();
|
assertThat(result.created()).isFalse();
|
||||||
assertThat(result.confirmedPackageCount()).isEqualTo(7);
|
assertThat(result.confirmedPackageCount()).isEqualTo(4);
|
||||||
assertThat(existing.getLengthCm()).isEqualByComparingTo("59.100");
|
assertThat(existing.getLengthCm()).isEqualByComparingTo("59.500");
|
||||||
|
assertThat(existing.getUnitVolumeCbm()).isEqualByComparingTo("0.187");
|
||||||
|
assertThat(existing.getTotalVolumeCbm()).isEqualByComparingTo("0.7480");
|
||||||
|
assertThat(existing.getVolumeWeightKg()).isEqualByComparingTo("124.916");
|
||||||
assertThat(existing.getSourceImageFileId()).isEqualTo(99001L);
|
assertThat(existing.getSourceImageFileId()).isEqualTo(99001L);
|
||||||
verify(images).delete("internal-token", 90001L, 10001L, 70001L, 88001L);
|
verify(images).delete("internal-token", 90001L, 10001L, 70001L, 88001L);
|
||||||
}
|
}
|
||||||
@@ -253,6 +256,14 @@ class CartonMeasurementServiceTest {
|
|||||||
new MockMultipartFile("image", "measure.jpg", "image/jpeg", "image".getBytes()));
|
new MockMultipartFile("image", "measure.jpg", "image/jpeg", "image".getBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CartonMeasurementCommand acceptanceCommand() {
|
||||||
|
return new CartonMeasurementCommand(
|
||||||
|
"RK-001#5-1", new BigDecimal("59.500"), new BigDecimal("41.200"),
|
||||||
|
new BigDecimal("31.300"), new BigDecimal("13.600"), "MJ-ADMIN-E2E-02",
|
||||||
|
LocalDateTime.parse("2026-08-08T10:01:00"),
|
||||||
|
new MockMultipartFile("image", "measure.jpg", "image/jpeg", "image".getBytes()));
|
||||||
|
}
|
||||||
|
|
||||||
private InboundOrderEntity inbound(String status) {
|
private InboundOrderEntity inbound(String status) {
|
||||||
InboundOrderEntity inbound = new InboundOrderEntity();
|
InboundOrderEntity inbound = new InboundOrderEntity();
|
||||||
inbound.setId(70001L); inbound.setTenantId(10001L); inbound.setProcessStatus(status);
|
inbound.setId(70001L); inbound.setTenantId(10001L); inbound.setProcessStatus(status);
|
||||||
|
|||||||
Reference in New Issue
Block a user