fix(overseas): restore dispatch delivery returns
This commit is contained in:
+113
@@ -0,0 +1,113 @@
|
||||
package com.baiyue.lastleg.exceptionorder.service;
|
||||
|
||||
import com.baiyue.lastleg.delivery.entity.DeliveryOrder;
|
||||
import com.baiyue.lastleg.delivery.entity.OutboundOrder;
|
||||
import com.baiyue.lastleg.delivery.entity.OutboundPalletItem;
|
||||
import com.baiyue.lastleg.delivery.mapper.DeliveryOrderMapper;
|
||||
import com.baiyue.lastleg.delivery.mapper.OutboundOrderMapper;
|
||||
import com.baiyue.lastleg.delivery.mapper.OutboundPalletItemMapper;
|
||||
import com.baiyue.lastleg.delivery.mapper.OutboundPdaPickMapper;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchItem;
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchItemMapper;
|
||||
import com.baiyue.lastleg.dispatch.pda.entity.DispatchPdaPick;
|
||||
import com.baiyue.lastleg.dispatch.pda.entity.DispatchPdaPickOrder;
|
||||
import com.baiyue.lastleg.dispatch.pda.entity.DispatchPdaTask;
|
||||
import com.baiyue.lastleg.dispatch.pda.mapper.DispatchPdaPickMapper;
|
||||
import com.baiyue.lastleg.dispatch.pda.mapper.DispatchPdaPickOrderMapper;
|
||||
import com.baiyue.lastleg.dispatch.pda.mapper.DispatchPdaTaskMapper;
|
||||
import com.baiyue.lastleg.entity.LastlegInboundOrder;
|
||||
import com.baiyue.lastleg.entity.LastlegOrder;
|
||||
import com.baiyue.lastleg.mapper.LastlegInboundOrderMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class ExceptionOrderDispatchReturnSourceTest {
|
||||
@Mock private DeliveryOrderMapper deliveryOrders;
|
||||
@Mock private OutboundOrderMapper outboundOrders;
|
||||
@Mock private OutboundPalletItemMapper outboundPalletItems;
|
||||
@Mock private OutboundPdaPickMapper outboundPdaPicks;
|
||||
@Mock private DispatchItemMapper dispatchItems;
|
||||
@Mock private DispatchPdaTaskMapper dispatchPdaTasks;
|
||||
@Mock private DispatchPdaPickMapper dispatchPdaPicks;
|
||||
@Mock private DispatchPdaPickOrderMapper dispatchPdaPickOrders;
|
||||
@Mock private LastlegOrderMapper lastMileOrders;
|
||||
@Mock private LastlegInboundOrderMapper inboundOrders;
|
||||
private ExceptionOrderService service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new ExceptionOrderService();
|
||||
ReflectionTestUtils.setField(service, "deliveryOrders", deliveryOrders);
|
||||
ReflectionTestUtils.setField(service, "outboundOrders", outboundOrders);
|
||||
ReflectionTestUtils.setField(service, "outboundPalletItems", outboundPalletItems);
|
||||
ReflectionTestUtils.setField(service, "outboundPdaPicks", outboundPdaPicks);
|
||||
ReflectionTestUtils.setField(service, "dispatchItems", dispatchItems);
|
||||
ReflectionTestUtils.setField(service, "dispatchPdaTasks", dispatchPdaTasks);
|
||||
ReflectionTestUtils.setField(service, "dispatchPdaPicks", dispatchPdaPicks);
|
||||
ReflectionTestUtils.setField(service, "dispatchPdaPickOrders", dispatchPdaPickOrders);
|
||||
ReflectionTestUtils.setField(service, "lastMileOrders", lastMileOrders);
|
||||
ReflectionTestUtils.setField(service, "inboundOrders", inboundOrders);
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsTheAttributedInventorySourceForDispatchDeliveryPicks() {
|
||||
DeliveryOrder delivery = new DeliveryOrder();
|
||||
delivery.setId(400L); delivery.setCustomerId("1001"); delivery.setDeliveryNo("DL-1");
|
||||
delivery.setOutboundNo("OUT-1"); delivery.setStatus("DELIVERED");
|
||||
OutboundOrder outbound = new OutboundOrder();
|
||||
outbound.setId(300L); outbound.setCustomerId("1001"); outbound.setOutboundNo("OUT-1");
|
||||
outbound.setDispatchOrderId(200L);
|
||||
OutboundPalletItem outboundItem = new OutboundPalletItem();
|
||||
outboundItem.setId(301L); outboundItem.setCustomerId("1001"); outboundItem.setOutboundOrderId(300L);
|
||||
outboundItem.setWarehousePalletId(501L); outboundItem.setPalletNo("PLT-1"); outboundItem.setInboundCode("IN-1");
|
||||
DispatchPdaTask task = new DispatchPdaTask();
|
||||
task.setId(201L); task.setCustomerId("1001"); task.setDispatchOrderId(200L);
|
||||
DispatchItem dispatchItem = new DispatchItem();
|
||||
dispatchItem.setId(202L); dispatchItem.setCustomerId("1001"); dispatchItem.setDispatchOrderId(200L);
|
||||
dispatchItem.setWarehousePalletId(501L);
|
||||
DispatchPdaPick pick = new DispatchPdaPick();
|
||||
pick.setId(203L); pick.setCustomerId("1001"); pick.setTaskId(201L);
|
||||
pick.setDispatchItemId(202L); pick.setInventoryPositionId(601L); pick.setPackages(2L);
|
||||
DispatchPdaPickOrder attribution = new DispatchPdaPickOrder();
|
||||
attribution.setId(204L); attribution.setCustomerId("1001"); attribution.setPickId(203L);
|
||||
attribution.setOrderId(101L); attribution.setPackages(2L);
|
||||
LastlegOrder tail = new LastlegOrder();
|
||||
tail.setId(101L); tail.setCustomerId("1001"); tail.setOrderNo("LM-1"); tail.setInboundCode("IN-1");
|
||||
tail.setDeliveryOrderNo("DL-1"); tail.setOutboundOrderNo("OUT-1"); tail.setPackageCount(2);
|
||||
LastlegInboundOrder inbound = new LastlegInboundOrder();
|
||||
inbound.setId(102L); inbound.setCustomerId("1001"); inbound.setInboundCode("IN-1"); inbound.setPackageCount(2);
|
||||
|
||||
when(deliveryOrders.findByNo("1001", "DL-1")).thenReturn(delivery);
|
||||
when(lastMileOrders.selectList(any())).thenReturn(List.of(tail));
|
||||
when(inboundOrders.selectList(any())).thenReturn(List.of(inbound));
|
||||
when(outboundOrders.findByNo("1001", "OUT-1")).thenReturn(outbound);
|
||||
when(outboundPalletItems.findByOutbound("1001", 300L)).thenReturn(List.of(outboundItem));
|
||||
when(outboundPdaPicks.findByOutbound("1001", 300L)).thenReturn(List.of());
|
||||
when(dispatchPdaTasks.findByDispatch("1001", 200L)).thenReturn(task);
|
||||
when(dispatchItems.findByDispatchOrder("1001", 200L)).thenReturn(List.of(dispatchItem));
|
||||
when(dispatchPdaPicks.listTask("1001", 201L)).thenReturn(List.of(pick));
|
||||
when(dispatchPdaPickOrders.listPick("1001", 203L)).thenReturn(List.of(attribution));
|
||||
when(lastMileOrders.selectById(101L)).thenReturn(tail);
|
||||
|
||||
var candidates = service.returnCandidates("1001", "DL-1");
|
||||
|
||||
assertThat(candidates).hasSize(1);
|
||||
assertThat(candidates.get(0).returnSources()).singleElement().satisfies(source -> {
|
||||
assertThat(source.outboundPalletItemId()).isEqualTo(301L);
|
||||
assertThat(source.inventoryPositionId()).isEqualTo(601L);
|
||||
assertThat(source.maxReturnPackages()).isEqualTo(2L);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user