This commit is contained in:
2026-09-15 11:54:14 +08:00
parent 3fb9909dd3
commit c1f01e1e87
56 changed files with 973 additions and 231 deletions
@@ -75,4 +75,34 @@ class DispatchBolPrintServiceTest {
assertThat(document.shipFromAddress()).isEqualTo(
"10767 7th Street, Rancho Cucamonga, California 91730, US"));
}
@Test
void createsOneBolDocumentPerFbaWarehouse() {
String warehouseId = "193000000000200003";
DispatchResponse detail = new DispatchResponse(1L, "DS-WH-20260911-624449", "DEV-23653906",
null, null, "五月开发验收车队", null, null, warehouseId, "洛杉矶仓", null,
null, null, null, LocalDateTime.of(2026, 9, 12, 2, 40, 20), "PENDING_DEPARTURE",
2, 2, 2, 0, 0, 2, null, LocalDateTime.of(2026, 9, 11, 10, 0), List.of(),
List.of(
new DispatchResponse.BolLine("TSTU3539519", "DP-001", "ABE2", "ABE2 Warehouse",
"NYEXX2609110214", null, null, 1),
new DispatchResponse.BolLine("TSTU3539519", "DP-002", "ONT8", "ONT8 Warehouse",
"NYEXX2609110215", null, null, 1)));
var warehouse = new DomesticWarehouseDirectoryClient.Warehouse(Long.parseLong(warehouseId), 0L,
"US-LAX", "洛杉矶仓", "OVERSEAS", "US", "ACTIVE");
when(dispatches.platformDetail(detail.dispatchNo())).thenReturn(detail);
when(warehouses.activeWarehouse(Long.parseLong(warehouseId), "internal-test-token"))
.thenReturn(ApiResponse.success(new DomesticWarehouseDirectoryClient.Detail(warehouse, List.of())));
when(print.generateDispatchBol(eq("internal-test-token"), eq("request-2"), any()))
.thenReturn(ResponseEntity.ok().contentType(MediaType.APPLICATION_PDF)
.header("X-Print-Page-Count", "2").body("%PDF-".getBytes(StandardCharsets.US_ASCII)));
service.generate(detail.dispatchNo(), "request-2");
ArgumentCaptor<PrintPdfClient.Request> request = ArgumentCaptor.forClass(PrintPdfClient.Request.class);
verify(print).generateDispatchBol(eq("internal-test-token"), eq("request-2"), request.capture());
assertThat(request.getValue().documents().stream()
.map(PrintPdfClient.Document::fbaWarehouseCode).toList())
.containsExactly("ABE2", "ONT8");
}
}