优化
This commit is contained in:
+28
@@ -4,6 +4,8 @@ import com.baiyue.common.core.api.ResultCode;
|
||||
import com.baiyue.common.core.exception.BizException;
|
||||
import com.baiyue.firstleg.client.PrintPdfClient;
|
||||
import com.baiyue.firstleg.dto.InboundCartonLabels;
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.Pallet;
|
||||
import com.baiyue.firstleg.dto.DropshipPalletizationDtos.SkuItem;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -35,6 +37,25 @@ class InboundCartonLabelPrintServiceTest {
|
||||
ReflectionTestUtils.setField(service, "internalToken", "internal-token");
|
||||
}
|
||||
|
||||
@Test
|
||||
void dropshipPalletLabelIsAvailableOnlyAfterSeal() {
|
||||
Pallet open = dropshipPallet("OPEN");
|
||||
assertThatThrownBy(() -> service.generateDropshipPallet(open, "request-open"))
|
||||
.isInstanceOf(BizException.class)
|
||||
.hasMessageContaining("已完成");
|
||||
verifyNoInteractions(print);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_PDF);
|
||||
when(print.generateInboundMarks(org.mockito.ArgumentMatchers.anyString(),
|
||||
org.mockito.ArgumentMatchers.eq("request-sealed"), org.mockito.ArgumentMatchers.any()))
|
||||
.thenReturn(new ResponseEntity<>(new byte[] {7, 8, 9}, headers,
|
||||
org.springframework.http.HttpStatus.OK));
|
||||
|
||||
ResponseEntity<byte[]> response = service.generateDropshipPallet(dropshipPallet("SEALED"), "request-sealed");
|
||||
assertThat(response.getBody()).containsExactly(7, 8, 9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void forwardsStableLabelsAndOnlySafePdfHeaders() {
|
||||
when(labels.list(10001L, 70001L, List.of(1))).thenReturn(batch());
|
||||
@@ -159,4 +180,11 @@ class InboundCartonLabelPrintServiceTest {
|
||||
"PCHK2608040174", "MCC1", "CTNS:19-1", "洛杉矶普船海卡");
|
||||
return new InboundCartonLabels.Batch(70001L, 80001L, "PCHK2608040174", 19, List.of(label));
|
||||
}
|
||||
|
||||
private Pallet dropshipPallet(String status) {
|
||||
SkuItem item = new SkuItem(70001L, "PCHK2608040174", 2L,
|
||||
"SKU-1", "音箱", 1, 19, List.of("PCHK2608040174#19-1"));
|
||||
return new Pallet(90001L, "DP-260911-0001", status, 1, 1, 0,
|
||||
BigDecimal.ONE, BigDecimal.ONE, 1, List.of(item), List.of(), null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user