fix: reserve stable inbound code for draft label printing

This commit is contained in:
2026-09-08 17:33:44 +08:00
parent eead11e99d
commit 60a41ec3ea
10 changed files with 289 additions and 3 deletions
@@ -3,6 +3,7 @@ package com.baiyue.firstleg.service;
import com.baiyue.common.core.api.ApiResponse;
import com.baiyue.common.core.exception.BizException;
import com.baiyue.firstleg.client.OrderCargoClient;
import com.baiyue.firstleg.client.PrintableOrderInboundClient;
import com.baiyue.firstleg.entity.InboundCartonLabelEntity;
import com.baiyue.firstleg.entity.InboundOrderEntity;
import com.baiyue.firstleg.repository.InboundCartonLabelRepository;
@@ -28,6 +29,7 @@ import static org.mockito.Mockito.when;
class InboundCartonLabelServiceTest {
@Mock private InboundCartonLabelRepository repository;
@Mock private OrderCargoClient orderCargoClient;
@Mock private PrintableOrderInboundClient printableOrderInboundClient;
@Mock private InboundOrderCreationService inboundOrderCreationService;
private InboundCartonLabelService service;
@@ -36,6 +38,7 @@ class InboundCartonLabelServiceTest {
service = new InboundCartonLabelService();
ReflectionTestUtils.setField(service, "repository", repository);
ReflectionTestUtils.setField(service, "orderCargoClient", orderCargoClient);
ReflectionTestUtils.setField(service, "printableOrderInboundClient", printableOrderInboundClient);
ReflectionTestUtils.setField(service, "inboundOrderCreationService", inboundOrderCreationService);
ReflectionTestUtils.setField(service, "internalToken", "internal-token");
}
@@ -222,7 +225,7 @@ class InboundCartonLabelServiceTest {
@Test
void rejectsAnOrderWithoutAnOwnedPreparingInbound() {
when(repository.findByOrder(10001L, 60001L)).thenReturn(null);
when(orderCargoClient.inboundSnapshot("internal-token", 10001L, 60001L))
when(printableOrderInboundClient.reserve("internal-token", 10001L, 60001L))
.thenThrow(org.mockito.Mockito.mock(feign.FeignException.class));
assertThatThrownBy(() -> service.requireInboundIdByOrder(10001L, 60001L))
@@ -239,7 +242,7 @@ class InboundCartonLabelServiceTest {
null, null, null, 2);
InboundOrderEntity repaired = inbound();
when(repository.findByOrder(10001L, 60001L)).thenReturn(null, repaired);
when(orderCargoClient.inboundSnapshot("internal-token", 10001L, 60001L))
when(printableOrderInboundClient.reserve("internal-token", 10001L, 60001L))
.thenReturn(ApiResponse.success(snapshot));
assertThat(service.requireInboundIdByOrder(10001L, 60001L)).isEqualTo(70001L);