优化
This commit is contained in:
+12
@@ -3,6 +3,7 @@ package com.baiyue.warehouse.controller;
|
||||
import com.baiyue.common.core.api.ResultCode;
|
||||
import com.baiyue.common.core.exception.BizException;
|
||||
import com.baiyue.warehouse.dto.WarehouseDetailResponse;
|
||||
import com.baiyue.warehouse.dto.OverseasPartnerWarehouseResponse;
|
||||
import com.baiyue.warehouse.entity.WarehouseEntity;
|
||||
import com.baiyue.warehouse.service.WarehouseApplicationService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -71,4 +72,15 @@ class InternalWarehouseControllerTest {
|
||||
|
||||
verifyNoInteractions(service);
|
||||
}
|
||||
|
||||
@Test
|
||||
void listsActiveOverseasPartnerOptionsForInternalCallers() {
|
||||
var option = new OverseasPartnerWarehouseResponse(200002L, "US-PARTNER-LAX", "洛杉矶合作仓", "US");
|
||||
when(service.activeOverseasPartners()).thenReturn(List.of(option));
|
||||
|
||||
var response = controller.overseasPartners(INTERNAL_TOKEN);
|
||||
|
||||
assertThat(response.data()).containsExactly(option);
|
||||
verify(service).activeOverseasPartners();
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -116,4 +116,37 @@ class WarehouseApplicationServiceTest {
|
||||
.isEqualTo(ResultCode.VALIDATION_FAILED);
|
||||
verify(repository, never()).insertWarehouse(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createsOverseasPartnerWarehouseAsPlatformPublicMasterData() {
|
||||
WarehouseRequests.SaveRequest request = new WarehouseRequests.SaveRequest(null, "US-PARTNER-LAX", "洛杉矶合作仓",
|
||||
"OVERSEAS_PARTNER", "US", "UTC-8", "Alex", "+1-213-555-0100", null, null, null,
|
||||
new WarehouseRequests.AddressRequest(null, "US", "CA", "Los Angeles", null,
|
||||
"90001", "123 Partner Ave", null, null, null),
|
||||
java.util.List.of(new WarehouseRequests.CapabilityRequest("STORAGE", "仓储", true, null, null)));
|
||||
|
||||
service.create(request);
|
||||
|
||||
var warehouse = org.mockito.ArgumentCaptor.forClass(WarehouseEntity.class);
|
||||
verify(repository).insertWarehouse(warehouse.capture());
|
||||
assertThat(warehouse.getValue().getTenantId()).isZero();
|
||||
assertThat(warehouse.getValue().getWarehouseType()).isEqualTo("OVERSEAS_PARTNER");
|
||||
assertThat(warehouse.getValue().getCountryCode()).isEqualTo("US");
|
||||
assertThat(warehouse.getValue().getTimezone()).isEqualTo("UTC-8");
|
||||
}
|
||||
|
||||
@Test
|
||||
void exposesOnlyActiveOverseasPartnerWarehousesToInternalConsumers() {
|
||||
WarehouseEntity partner = new WarehouseEntity();
|
||||
partner.setId(2L);
|
||||
partner.setWarehouseCode("US-PARTNER-LAX");
|
||||
partner.setWarehouseName("洛杉矶合作仓");
|
||||
partner.setCountryCode("US");
|
||||
when(repository.findActiveByType(0L, "OVERSEAS_PARTNER")).thenReturn(java.util.List.of(partner));
|
||||
|
||||
assertThat(service.activeOverseasPartners())
|
||||
.extracting("id", "warehouseCode", "warehouseName", "countryCode")
|
||||
.containsExactly(tuple(2L, "US-PARTNER-LAX", "洛杉矶合作仓", "US"));
|
||||
verify(repository).findActiveByType(0L, "OVERSEAS_PARTNER");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,22 @@ class WarehouseImportServiceTest {
|
||||
assertThat(captor.getAllValues().get(1).warehouseName()).isEqualTo("FBA-LAX9");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("海外合作仓类型可通过批量导入进入公共仓库主数据")
|
||||
void shouldImportOverseasPartnerWarehouse() throws Exception {
|
||||
byte[] file = withRows(service.template(), new String[][] {
|
||||
{"US-PARTNER-LAX", "洛杉矶合作仓", "OVERSEAS_PARTNER", "US", "CA", "Los Angeles", "", "123 Partner Ave", "90001", "UTC-8", "", "", "", "", ""}
|
||||
});
|
||||
|
||||
WarehouseImportResult result = service.importFile(0L, "warehouses.xlsx", file, null);
|
||||
|
||||
assertThat(result.success()).isTrue();
|
||||
var captor = org.mockito.ArgumentCaptor.forClass(WarehouseRequests.SaveRequest.class);
|
||||
verify(warehouseService).create(captor.capture());
|
||||
assertThat(captor.getValue().tenantId()).isZero();
|
||||
assertThat(captor.getValue().warehouseType()).isEqualTo("OVERSEAS_PARTNER");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("任一行错误时整批零写入")
|
||||
void shouldRejectWholeBatchWhenAnyRowInvalid() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user