修改提交
This commit is contained in:
+48
@@ -0,0 +1,48 @@
|
||||
package com.baiyue.lastleg.discard.controller;
|
||||
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.discard.dto.CargoDiscardRequests;
|
||||
import com.baiyue.lastleg.discard.service.CargoDiscardService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
class MerchantCargoDiscardControllerTest {
|
||||
private final CargoDiscardService service = mock(CargoDiscardService.class);
|
||||
private final MerchantCargoDiscardController controller = controller();
|
||||
private final CargoDiscardRequests.Query query = new CargoDiscardRequests.Query(
|
||||
1, 20, null, null, null, null, null, null);
|
||||
|
||||
@Test
|
||||
void merchantQueriesUseOnlyAuthenticatedTenant() {
|
||||
AuthenticatedUser user = user(100L, "MERCHANT");
|
||||
controller.page(user, query);
|
||||
controller.candidates(user, "IN001");
|
||||
controller.detail(user, "DS001");
|
||||
verify(service).page("100", query);
|
||||
verify(service).candidates("100", "IN001");
|
||||
verify(service).detail("100", "DS001");
|
||||
}
|
||||
|
||||
@Test
|
||||
void merchantEndpointRejectsPlatformIdentity() {
|
||||
assertThrows(ResponseStatusException.class,
|
||||
() -> controller.page(user(0L, "PLATFORM"), query));
|
||||
}
|
||||
|
||||
private static AuthenticatedUser user(long tenantId, String appCode) {
|
||||
return new AuthenticatedUser(1L, tenantId, tenantId, 9L, "merchant", appCode, "WEB", Set.of());
|
||||
}
|
||||
|
||||
private MerchantCargoDiscardController controller() {
|
||||
MerchantCargoDiscardController controller = new MerchantCargoDiscardController();
|
||||
ReflectionTestUtils.setField(controller, "service", service);
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.baiyue.lastleg.dispatch;
|
||||
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchCandidateMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class DispatchCandidateMapperContractTest {
|
||||
private static final List<String> CONSTRUCTOR_ALIASES = List.of(
|
||||
"planId", "planPalletId", "warehousePalletId", "orderId", "customerId", "customerName",
|
||||
"planNo", "orderType", "volumeWeightKg", "containerNo", "appointmentAt", "expectedLoadingAt",
|
||||
"overseasWarehouseId", "overseasWarehouseName", "orderNo", "orderRefs", "inboundCode", "palletNo",
|
||||
"destinationWarehouseId", "destinationWarehouseCode", "destinationWarehouseName", "fbaWarehouseCode",
|
||||
"packageCount", "volumeCbm", "sourceStage", "cartonMarks"
|
||||
);
|
||||
|
||||
@Test
|
||||
void candidateQueriesKeepRecordConstructorColumnOrder() throws Exception {
|
||||
assertConstructorColumnOrder(DispatchCandidateMapper.class.getMethod("available",
|
||||
String.class, List.class, String.class, String.class, String.class));
|
||||
assertConstructorColumnOrder(DispatchCandidateMapper.class.getMethod("lockSelected",
|
||||
String.class, List.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectedReceivedPalletMustStillHaveAvailableInventory() throws Exception {
|
||||
Method method = DispatchCandidateMapper.class.getMethod("lockSelected", String.class, List.class);
|
||||
String sql = String.join(" ", method.getAnnotation(Select.class).value());
|
||||
|
||||
assertTrue(sql.contains("p.warehouse_pallet_id IS NULL OR EXISTS"));
|
||||
assertTrue(sql.contains("pos.available_packages > 0"));
|
||||
}
|
||||
|
||||
private void assertConstructorColumnOrder(Method method) {
|
||||
String sql = String.join(" ", method.getAnnotation(Select.class).value());
|
||||
int previous = -1;
|
||||
for (String alias : CONSTRUCTOR_ALIASES) {
|
||||
int current = sql.indexOf(" AS " + alias, previous + 1);
|
||||
assertTrue(current > previous,
|
||||
() -> method.getName() + " must select alias " + alias + " in record constructor order");
|
||||
previous = current;
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.baiyue.lastleg.dispatch;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchPalletLock;
|
||||
import com.baiyue.lastleg.dispatch.mapper.DispatchPalletLockMapper;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class DispatchPalletLockPersistenceContractTest {
|
||||
@Test
|
||||
void nullableLockFieldsAreWrittenAsNullOnReleaseAndFinalization() throws Exception {
|
||||
assertAlwaysUpdated("activeKey");
|
||||
assertAlwaysUpdated("draftToken");
|
||||
assertAlwaysUpdated("expiresAt");
|
||||
}
|
||||
|
||||
@Test
|
||||
void relockClearsInactiveUniqueKeyResidue() throws Exception {
|
||||
Update update = DispatchPalletLockMapper.class
|
||||
.getMethod("clearInactiveActiveKey", String.class, String.class)
|
||||
.getAnnotation(Update.class);
|
||||
String sql = String.join(" ", Arrays.asList(update.value()));
|
||||
|
||||
assertTrue(sql.contains("active_key=NULL"));
|
||||
assertTrue(sql.contains("status!='ACTIVE'"));
|
||||
}
|
||||
|
||||
private void assertAlwaysUpdated(String fieldName) throws Exception {
|
||||
TableField field = DispatchPalletLock.class.getDeclaredField(fieldName).getAnnotation(TableField.class);
|
||||
assertEquals(FieldStrategy.ALWAYS, field.updateStrategy());
|
||||
}
|
||||
}
|
||||
+3
@@ -19,6 +19,9 @@ class DispatchSchemaContractTest {
|
||||
assertTrue(sql.contains("CREATE TABLE IF NOT EXISTS ll_dispatch_pda_pick"));
|
||||
assertTrue(sql.contains("CREATE TABLE IF NOT EXISTS ll_dispatch_pda_operation"));
|
||||
assertTrue(sql.contains("active_key"));
|
||||
assertTrue(sql.contains("draft_token"));
|
||||
assertTrue(sql.contains("expires_at"));
|
||||
assertTrue(sql.contains("dispatch_order_id BIGINT NULL"));
|
||||
assertTrue(sql.contains("order_refs"));
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -16,12 +16,17 @@ class SmartDispatchOpenApiContractTest {
|
||||
}
|
||||
assertTrue(yaml.contains("/api/platform/v1/last-leg/dispatches/candidates:"));
|
||||
assertTrue(yaml.contains("/api/platform/v1/last-leg/dispatches/pre-arrange:"));
|
||||
assertTrue(yaml.contains("/api/platform/v1/last-leg/dispatches/draft-locks/lock:"));
|
||||
assertTrue(yaml.contains("/api/platform/v1/last-leg/dispatches/draft-locks/unlock:"));
|
||||
assertTrue(yaml.contains("/api/platform/v1/last-leg/dispatches/draft-locks/release:"));
|
||||
assertTrue(yaml.contains("platform:overseas-warehouse:inbound-order:list"));
|
||||
assertTrue(yaml.contains("platform:overseas-warehouse:inbound-order:smart-dispatch"));
|
||||
assertTrue(yaml.contains("SmartDispatchPreArrange"));
|
||||
assertTrue(yaml.contains("SmartDispatchCandidate"));
|
||||
assertTrue(yaml.contains("name: planIds"));
|
||||
assertTrue(yaml.contains("required: true"));
|
||||
String planIdsParameter = yaml.substring(yaml.indexOf("name: planIds"),
|
||||
yaml.indexOf("name: orderNo", yaml.indexOf("name: planIds")));
|
||||
assertTrue(planIdsParameter.contains("required: false"));
|
||||
String dispatchContract = yaml.substring(0,
|
||||
yaml.indexOf("/api/platform/v1/last-leg/overseas-procurements:"));
|
||||
assertFalse(dispatchContract.contains("name: customerId"));
|
||||
|
||||
+3
-4
@@ -34,14 +34,13 @@ class DispatchQueryControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void platformPageUsesServerResolvedSingleCustomerWithoutCustomerId() {
|
||||
void platformPageQueriesAcrossCustomersWithoutCustomerId() {
|
||||
DispatchRequests.Query query = new DispatchRequests.Query(1, 20, null, null, null, null);
|
||||
when(service.resolveSingleCustomerScope()).thenReturn("100");
|
||||
when(service.page("100", query)).thenReturn(new PageResult<>(List.of(), 1, 20, 0, 0));
|
||||
when(service.platformPage(query)).thenReturn(new PageResult<>(List.of(), 1, 20, 0, 0));
|
||||
|
||||
var response = controller.page(platform(), query);
|
||||
|
||||
verify(service).page("100", query);
|
||||
verify(service).platformPage(query);
|
||||
assertThat(response.code()).isEqualTo("200");
|
||||
assertThat(response.data().records()).isEmpty();
|
||||
assertThatThrownBy(() -> controller.page(null, query))
|
||||
|
||||
+9
@@ -40,6 +40,15 @@ class SmartDispatchControllerTest {
|
||||
verify(service).candidates("100", List.of(1L, 2L), "LMO-1", "ONT8", "PLAN");
|
||||
}
|
||||
|
||||
@Test
|
||||
void candidatesWithoutSelectedPlansUsePlatformScope() {
|
||||
when(service.platformCandidates(null, null, "RECEIVED")).thenReturn(List.of());
|
||||
|
||||
controller.candidates(platform(), null, null, null, "RECEIVED");
|
||||
|
||||
verify(service).platformCandidates(null, null, "RECEIVED");
|
||||
}
|
||||
|
||||
@Test
|
||||
void preArrangeResolvesSingleCustomerAndAuthenticatedOperator() {
|
||||
DispatchRequests.PreArrange request = new DispatchRequests.PreArrange(
|
||||
|
||||
+113
-12
@@ -1,5 +1,7 @@
|
||||
package com.baiyue.lastleg.dispatch.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baiyue.lastleg.dispatch.dto.DispatchRequests;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchItem;
|
||||
import com.baiyue.lastleg.dispatch.entity.DispatchOrder;
|
||||
@@ -69,6 +71,74 @@ class DispatchServiceTest {
|
||||
verify(items).insert(any(DispatchItem.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void movingPalletIntoDraftImmediatelyCreatesExpiringExclusiveLock() {
|
||||
when(candidates.lockSelected("100", List.of(10L))).thenReturn(List.of(candidate(10L, null, "ONT8")));
|
||||
|
||||
service.lockDraftPallet("100", "7", new DispatchRequests.DraftPallet(10L, "draft-1"));
|
||||
|
||||
ArgumentCaptor<DispatchPalletLock> lock = ArgumentCaptor.forClass(DispatchPalletLock.class);
|
||||
verify(locks).insert(lock.capture());
|
||||
assertEquals("draft-1", lock.getValue().getDraftToken());
|
||||
assertEquals("7", lock.getValue().getOperatorId());
|
||||
assertNotNull(lock.getValue().getExpiresAt());
|
||||
assertEquals(null, lock.getValue().getDispatchOrderId());
|
||||
verify(locks).clearInactiveActiveKey("100", "PLAN:10");
|
||||
}
|
||||
|
||||
@Test
|
||||
void movingVolumeOnlyPlanPalletIntoDraftCreatesLock() {
|
||||
when(candidates.lockSelected("100", List.of(10L)))
|
||||
.thenReturn(List.of(candidate(10L, null, "ONT8", 0)));
|
||||
|
||||
service.lockDraftPallet("100", "7", new DispatchRequests.DraftPallet(10L, "draft-1"));
|
||||
|
||||
verify(locks).insert(any(DispatchPalletLock.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void preArrangeAcceptsVolumeOnlyPlanPallet() {
|
||||
when(candidates.lockSelected("100", List.of(10L)))
|
||||
.thenReturn(List.of(candidate(10L, null, "ONT8", 0)));
|
||||
|
||||
service.preArrange("100", "7", new DispatchRequests.PreArrange(List.of(10L), null,
|
||||
null, null, null));
|
||||
|
||||
ArgumentCaptor<DispatchOrder> dispatch = ArgumentCaptor.forClass(DispatchOrder.class);
|
||||
verify(orders).insert(dispatch.capture());
|
||||
assertEquals(0, dispatch.getValue().getPackageCount());
|
||||
verify(items).insert(any(DispatchItem.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void removingPalletFromOwnedDraftImmediatelyReleasesLock() {
|
||||
when(candidates.lockSelected("100", List.of(10L))).thenReturn(List.of(candidate(10L, null, "ONT8")));
|
||||
DispatchPalletLock lock = new DispatchPalletLock();
|
||||
lock.setDraftToken("draft-1"); lock.setOperatorId("7"); lock.setStatus("ACTIVE"); lock.setActiveKey("PLAN:10");
|
||||
when(locks.lockActive("100", "PLAN:10")).thenReturn(lock);
|
||||
|
||||
service.unlockDraftPallet("100", "7", new DispatchRequests.DraftPallet(10L, "draft-1"));
|
||||
|
||||
assertEquals("RELEASED", lock.getStatus());
|
||||
assertEquals(null, lock.getActiveKey());
|
||||
verify(locks).updateById(lock);
|
||||
}
|
||||
|
||||
@Test
|
||||
void preArrangeConvertsOwnedDraftLockInsteadOfInsertingAnotherLock() {
|
||||
when(candidates.lockSelected("100", List.of(10L))).thenReturn(List.of(candidate(10L, null, "ONT8")));
|
||||
DispatchPalletLock lock = new DispatchPalletLock();
|
||||
lock.setDraftToken("draft-1"); lock.setOperatorId("7"); lock.setStatus("ACTIVE"); lock.setActiveKey("PLAN:10");
|
||||
when(locks.lockActive("100", "PLAN:10")).thenReturn(lock);
|
||||
|
||||
service.preArrange("100", "7", new DispatchRequests.PreArrange(List.of(10L), null, null, null, null, "draft-1"));
|
||||
|
||||
assertNotNull(lock.getDispatchOrderId());
|
||||
assertEquals(null, lock.getDraftToken());
|
||||
verify(locks).updateById(lock);
|
||||
verify(locks, never()).insert(any(DispatchPalletLock.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsPalletAlreadyLockedByAnotherDispatch() {
|
||||
when(candidates.lockSelected("100", List.of(10L))).thenReturn(List.of(candidate(10L, null, "ONT8")));
|
||||
@@ -87,6 +157,15 @@ class DispatchServiceTest {
|
||||
verify(candidates, never()).available(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void platformCandidatesQueryAcrossCustomersWithoutPlanScope() {
|
||||
when(candidates.available(null, null, null, null, "RECEIVED")).thenReturn(List.of());
|
||||
|
||||
service.platformCandidates(null, null, "RECEIVED");
|
||||
|
||||
verify(candidates).available(null, null, null, null, "RECEIVED");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolvesCustomerFromSelectedPlansAndPalletsInMultiCustomerDeployment() {
|
||||
when(candidates.findCustomerScopesByPlanIds(List.of(1L, 2L))).thenReturn(List.of("100"));
|
||||
@@ -106,17 +185,6 @@ class DispatchServiceTest {
|
||||
assertEquals(409, exception.getStatusCode().value());
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolvesOnlyCustomerScopeAndRejectsMultipleCustomers() {
|
||||
when(candidates.findCustomerScopes()).thenReturn(List.of("100"));
|
||||
assertEquals("100", service.resolveSingleCustomerScope());
|
||||
|
||||
when(candidates.findCustomerScopes()).thenReturn(List.of("100", "200"));
|
||||
ResponseStatusException exception = assertThrows(ResponseStatusException.class,
|
||||
() -> service.resolveSingleCustomerScope());
|
||||
assertEquals(409, exception.getStatusCode().value());
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyCustomerScopeProducesEmptyCandidatesAndRejectsPreArrange() {
|
||||
assertEquals(List.of(), service.candidates(null, null, null, null, null));
|
||||
@@ -159,9 +227,42 @@ class DispatchServiceTest {
|
||||
verify(items).findByDispatchOrder("200", 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void platformPageQueriesAllCustomersAndLoadsItemsInEachCustomerScope() {
|
||||
DispatchOrder first = new DispatchOrder();
|
||||
first.setId(1L); first.setCustomerId("100"); first.setDispatchNo("PC1");
|
||||
DispatchOrder second = new DispatchOrder();
|
||||
second.setId(2L); second.setCustomerId("200"); second.setDispatchNo("PC2");
|
||||
Page<DispatchOrder> resultPage = new Page<>(1, 20, 2);
|
||||
resultPage.setRecords(List.of(first, second));
|
||||
when(orders.selectPage(any(Page.class), any(LambdaQueryWrapper.class))).thenReturn(resultPage);
|
||||
|
||||
var result = service.platformPage(new DispatchRequests.Query(1, 20, null, null, null, null));
|
||||
|
||||
assertEquals(2, result.total());
|
||||
verify(items).findByDispatchOrder("100", 1L);
|
||||
verify(items).findByDispatchOrder("200", 2L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void platformDetailUsesCustomerFromMatchedDispatch() {
|
||||
DispatchOrder dispatch = new DispatchOrder();
|
||||
dispatch.setId(1L); dispatch.setCustomerId("200"); dispatch.setDispatchNo("PC1");
|
||||
when(orders.findAcrossCustomersByDispatchNo("PC1")).thenReturn(List.of(dispatch));
|
||||
|
||||
service.platformDetail("PC1");
|
||||
|
||||
verify(items).findByDispatchOrder("200", 1L);
|
||||
}
|
||||
|
||||
private DispatchPalletCandidate candidate(long planPalletId, Long warehousePalletId, String destination) {
|
||||
return candidate(planPalletId, warehousePalletId, destination, 12);
|
||||
}
|
||||
|
||||
private DispatchPalletCandidate candidate(long planPalletId, Long warehousePalletId, String destination,
|
||||
int packageCount) {
|
||||
return new DispatchPalletCandidate(1L, planPalletId, warehousePalletId, 2L, "WH-1", "Overseas warehouse", "LMO1", "LMO1", "RK1",
|
||||
"LIP1-P001", destination, destination, destination, destination, 12,
|
||||
"LIP1-P001", destination, destination, destination, destination, packageCount,
|
||||
new BigDecimal("1.2000"), warehousePalletId == null ? "PLAN" : "RECEIVED");
|
||||
}
|
||||
}
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.baiyue.lastleg.relabel.controller;
|
||||
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.relabel.dto.RelabelRequests;
|
||||
import com.baiyue.lastleg.relabel.service.RelabelApplicationService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
class MerchantRelabelApplicationControllerTest {
|
||||
private final RelabelApplicationService service = mock(RelabelApplicationService.class);
|
||||
private final MerchantRelabelApplicationController controller = controller();
|
||||
private final RelabelRequests.Query query = new RelabelRequests.Query(
|
||||
1, 20, null, null, null, null, null, null, null);
|
||||
|
||||
@Test
|
||||
void merchantPageAndDetailUseOnlyAuthenticatedTenant() {
|
||||
AuthenticatedUser user = user(100L, "MERCHANT");
|
||||
controller.page(user, query);
|
||||
controller.detail(user, "RL001");
|
||||
verify(service).page("100", query);
|
||||
verify(service).detail("100", "RL001");
|
||||
}
|
||||
|
||||
@Test
|
||||
void merchantEndpointRejectsPlatformIdentity() {
|
||||
assertThrows(ResponseStatusException.class,
|
||||
() -> controller.page(user(0L, "PLATFORM"), query));
|
||||
}
|
||||
|
||||
private static AuthenticatedUser user(long tenantId, String appCode) {
|
||||
return new AuthenticatedUser(1L, tenantId, tenantId, 9L, "merchant", appCode, "WEB", Set.of());
|
||||
}
|
||||
|
||||
private MerchantRelabelApplicationController controller() {
|
||||
MerchantRelabelApplicationController controller = new MerchantRelabelApplicationController();
|
||||
ReflectionTestUtils.setField(controller, "service", service);
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.baiyue.lastleg.transfer.controller;
|
||||
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.transfer.dto.WarehouseTransferRequests;
|
||||
import com.baiyue.lastleg.transfer.service.WarehouseTransferService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
class MerchantWarehouseTransferControllerTest {
|
||||
private final WarehouseTransferService service = mock(WarehouseTransferService.class);
|
||||
private final MerchantWarehouseTransferController controller = controller();
|
||||
private final WarehouseTransferRequests.Query query = new WarehouseTransferRequests.Query(
|
||||
1, 20, null, null, null, null, null, null, null, null);
|
||||
|
||||
@Test
|
||||
void merchantPageUsesOnlyAuthenticatedTenant() {
|
||||
controller.page(user(100L, "MERCHANT"), query);
|
||||
verify(service).page("100", query);
|
||||
}
|
||||
|
||||
@Test
|
||||
void merchantDetailUsesOnlyAuthenticatedTenant() {
|
||||
controller.detail(user(100L, "MERCHANT"), "TR001");
|
||||
verify(service).detail("100", "TR001");
|
||||
}
|
||||
|
||||
@Test
|
||||
void merchantEndpointRejectsPlatformIdentity() {
|
||||
assertThrows(ResponseStatusException.class,
|
||||
() -> controller.page(user(0L, "PLATFORM"), query));
|
||||
}
|
||||
|
||||
private static AuthenticatedUser user(long tenantId, String appCode) {
|
||||
return new AuthenticatedUser(1L, tenantId, tenantId, 9L, "merchant", appCode, "WEB", Set.of());
|
||||
}
|
||||
|
||||
private MerchantWarehouseTransferController controller() {
|
||||
MerchantWarehouseTransferController controller = new MerchantWarehouseTransferController();
|
||||
ReflectionTestUtils.setField(controller, "service", service);
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user