Merge branch 'test' of http://8.163.30.128:10082/java-project/baiyue-firstleg into test
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
package com.baiyue.warehouse.controller;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class InternalWarehousePalletLabelContractTest {
|
||||
@Test
|
||||
void labelEndpointIsInternalAndRequiresTheServiceToken() throws Exception {
|
||||
var method = InternalWarehousePalletController.class.getMethod("label",
|
||||
String.class, String.class, long.class, long.class, String.class);
|
||||
|
||||
assertThat(method.getAnnotation(GetMapping.class).value())
|
||||
.containsExactly("/{warehouseId}/{palletId}/label");
|
||||
assertThat(method.getParameters()[0].getAnnotation(RequestHeader.class).value())
|
||||
.isEqualTo("X-Internal-Service-Token");
|
||||
}
|
||||
}
|
||||
+20
@@ -59,6 +59,26 @@ class PalletLabelPrintServiceTest {
|
||||
verify(print, never()).generateInboundMarks(any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void transferLabelIncludesTransferNumberAndMakesAnUnknownDestinationExplicit() {
|
||||
pallet.setPalletCode("ABCD1234567-ABE3-003");
|
||||
pallet.setFbaWarehouseCode(null);
|
||||
byte[] pdf = "%PDF-transfer-label".getBytes(java.nio.charset.StandardCharsets.US_ASCII);
|
||||
when(print.generateInboundMarks(anyString(), anyString(), any()))
|
||||
.thenReturn(ResponseEntity.ok().contentType(MediaType.APPLICATION_PDF).body(pdf));
|
||||
|
||||
service.printTransfer(200L, 9L, "WTR-20260916-1", "request-transfer");
|
||||
|
||||
var request = ArgumentCaptor.forClass(PrintPdfClient.Request.class);
|
||||
verify(print).generateInboundMarks(eq("test-token"), eq("request-transfer"), request.capture());
|
||||
assertThat(request.getValue().labels()).singleElement().satisfies(label -> {
|
||||
assertThat(label.topCode()).isEqualTo("ABCD1234567-ABE3-003");
|
||||
assertThat(label.cartonText()).isEqualTo("转运单 WTR-20260916-1");
|
||||
assertThat(label.warehouseText()).isEqualTo("目的仓待定");
|
||||
assertThat(label.routeText()).isEqualTo("洛杉矶仓");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void refusesWrongWarehouseBeforeCallingPrint() {
|
||||
when(resources.pallet(0L, 201L, 9L)).thenThrow(new BizException(ResultCode.NOT_FOUND, "托盘不存在"));
|
||||
|
||||
+3
-2
@@ -262,7 +262,8 @@ class WarehouseResourceServiceTest {
|
||||
|
||||
ArgumentCaptor<WarehousePalletEntity> captor = ArgumentCaptor.forClass(WarehousePalletEntity.class);
|
||||
verify(repository).insertPallet(captor.capture());
|
||||
assertThat(captor.getValue().getPalletCode()).matches("PLT-US-LAX-01-[0-9]{8}-[0-9]+");
|
||||
assertThat(captor.getValue().getPalletCode()).matches("PLT-USLAX01-[0-9]{6}-[0-9A-Z]+");
|
||||
assertThat(captor.getValue().getPalletCode()).hasSizeLessThanOrEqualTo(34);
|
||||
assertThat(captor.getValue().getLocationId()).isEqualTo(30003L);
|
||||
assertThat(captor.getValue().getId()).isNotNull();
|
||||
}
|
||||
@@ -283,7 +284,7 @@ class WarehouseResourceServiceTest {
|
||||
|
||||
ArgumentCaptor<WarehousePalletEntity> captor = ArgumentCaptor.forClass(WarehousePalletEntity.class);
|
||||
verify(repository).insertPallet(captor.capture());
|
||||
assertThat(captor.getValue().getPalletCode()).hasSizeLessThanOrEqualTo(64);
|
||||
assertThat(captor.getValue().getPalletCode()).hasSizeLessThanOrEqualTo(34);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user