fix: complete order measurement downstream flow
This commit is contained in:
+3
@@ -7,6 +7,7 @@ import com.baiyue.firstleg.service.InboundOrderCreationService;
|
||||
import com.baiyue.firstleg.service.InboundCartonLabelService;
|
||||
import com.baiyue.firstleg.service.UnifiedInboundQueryService;
|
||||
import com.baiyue.firstleg.service.OrderDeclarationSyncService;
|
||||
import com.baiyue.firstleg.service.OrderRemarksSyncService;
|
||||
import com.baiyue.firstleg.dto.UnifiedInboundQuery;
|
||||
import com.baiyue.firstleg.dto.OrderDeclarationSync;
|
||||
import com.baiyue.common.core.api.PageResult;
|
||||
@@ -36,6 +37,8 @@ class InternalInboundOrderReferenceControllerTest {
|
||||
private UnifiedInboundQueryService unifiedQueryService;
|
||||
@MockBean
|
||||
private OrderDeclarationSyncService declarationSync;
|
||||
@MockBean
|
||||
private OrderRemarksSyncService remarksSync;
|
||||
@Resource
|
||||
private InternalInboundOrderController controller;
|
||||
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ class OrderDeclarationSyncServiceTest {
|
||||
}
|
||||
|
||||
@MockBean private OrderDeclarationSyncMapper mapper;
|
||||
@MockBean private OrderRemarksSyncService remarksSync;
|
||||
@Resource private OrderDeclarationSyncService service;
|
||||
@Resource private ObjectMapper json;
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.baiyue.firstleg.service;
|
||||
|
||||
import com.baiyue.firstleg.dto.OrderRemarksSync;
|
||||
import com.baiyue.firstleg.mapper.LoadingPlanItemMapper;
|
||||
import com.baiyue.firstleg.mapper.LoadingPlanMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@SpringJUnitConfig(OrderRemarksSyncService.class)
|
||||
class OrderRemarksSyncServiceTest {
|
||||
@MockBean private LoadingPlanItemMapper items;
|
||||
@MockBean private LoadingPlanMapper plans;
|
||||
|
||||
@jakarta.annotation.Resource private OrderRemarksSyncService service;
|
||||
|
||||
@Test
|
||||
void updatesAllMutableOrderItemsAndTouchesAffectedPlans() {
|
||||
var command = new OrderRemarksSync.Command(10L, 20L, "客户", "内部", "仓库", "客服", 30L, "操作人");
|
||||
when(items.findMutablePlanIdsWithDifferentRemarks(
|
||||
10L, 20L, "客户", "内部", "仓库", "客服", null)).thenReturn(List.of(101L, 102L));
|
||||
when(items.syncMutableOrderRemarks(
|
||||
10L, 20L, "客户", "内部", "仓库", "客服", 30L, "操作人", null)).thenReturn(3);
|
||||
|
||||
assertThat(service.sync(command)).isEqualTo(3);
|
||||
|
||||
verify(plans).touchForOrderRemarks(List.of(101L, 102L), 30L, "操作人");
|
||||
}
|
||||
|
||||
@Test
|
||||
void leavesFrozenOrAlreadyMatchingPlansUntouched() {
|
||||
var command = new OrderRemarksSync.Command(10L, 20L, null, null, null, null, 30L, null);
|
||||
when(items.findMutablePlanIdsWithDifferentRemarks(
|
||||
10L, 20L, null, null, null, null, null)).thenReturn(List.of());
|
||||
|
||||
assertThat(service.sync(command)).isZero();
|
||||
|
||||
verify(items, never()).syncMutableOrderRemarks(
|
||||
10L, 20L, null, null, null, null, 30L, null, null);
|
||||
verify(plans, never()).touchForOrderRemarks(org.mockito.ArgumentMatchers.anyList(),
|
||||
org.mockito.ArgumentMatchers.anyLong(), org.mockito.ArgumentMatchers.nullable(String.class));
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,7 @@ class SmartLoadingServiceTest {
|
||||
@MockBean private PriceBookQueryUseCase priceBooks;
|
||||
@MockBean private FirstlegDocumentNumberGenerator documentNumbers;
|
||||
@MockBean private DropshipPalletizationMapper dropshipPallets;
|
||||
@MockBean private OrderRemarksSyncService orderRemarksSync;
|
||||
@Resource private SmartLoadingService service;
|
||||
|
||||
@TestConfiguration
|
||||
@@ -119,6 +120,12 @@ class SmartLoadingServiceTest {
|
||||
when(cargoClient.detail(anyString(), anyLong(), anyLong(), anyLong())).thenReturn(
|
||||
ApiResponse.success(new OrderCargoClient.CargoBinding(20L, 30L, 1, "货物", 5,
|
||||
new BigDecimal("10"), new BigDecimal("2"))));
|
||||
when(cargoClient.updateRemarks(anyString(), anyLong(), anyLong(), any()))
|
||||
.thenAnswer(invocation -> {
|
||||
OrderCargoClient.RemarksUpdateRequest request = invocation.getArgument(3);
|
||||
return ApiResponse.success(new OrderCargoClient.RemarksUpdateResponse(2, null,
|
||||
request.internalRemark(), request.warehouseRemark(), request.customerServiceRemark()));
|
||||
});
|
||||
when(fbaPricingService.recalculateUnlockedContainerCustomerFees(anyLong(), anyLong(), anyString()))
|
||||
.thenReturn(new FbaPricingService.ContainerFeeRecalculationResult(
|
||||
FbaPricingService.ContainerFeeRecalculationStatus.NOT_READY, 0));
|
||||
@@ -1955,6 +1962,7 @@ class SmartLoadingServiceTest {
|
||||
private static LoadingPlanItemEntity item(long id, long account, long detail, int boxes) {
|
||||
LoadingPlanItemEntity value = new LoadingPlanItemEntity();
|
||||
value.setId(id); value.setLoadingPlanId(1L); value.setAccountId(account);
|
||||
value.setOrderId(30L); value.setOrderNo("O30");
|
||||
value.setInboundId(10L); value.setInboundDetailId(detail); value.setPackageCount(boxes);
|
||||
value.setVersion(0); value.setDeleted(false);
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user