test(phase4): provision overseas lifecycle fixtures

This commit is contained in:
2026-08-24 15:07:17 +08:00
parent cd97229791
commit e11a528dfe
12 changed files with 248 additions and 48 deletions
@@ -0,0 +1,53 @@
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.time.LocalDateTime;
import java.util.List;
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 RelabelApplicationControllerTest {
private final RelabelApplicationService service = mock(RelabelApplicationService.class);
private final RelabelApplicationController controller = controller();
@Test
void platformCreateUsesExplicitTargetCustomer() {
RelabelRequests.Create request = request("190000000000000001");
controller.create(platform(), request);
verify(service).create("190000000000000001", "7", request);
}
@Test
void platformCreateRejectsMissingOrPlatformCustomer() {
assertThrows(ResponseStatusException.class, () -> controller.create(platform(), request(null)));
assertThrows(ResponseStatusException.class, () -> controller.create(platform(), request("0")));
}
private RelabelRequests.Create request(String customerId) {
return new RelabelRequests.Create(customerId, "CUSTOMER-1", "WH-1",
LocalDateTime.of(2026, 8, 20, 10, 0), "Li", "13800000000", null, "key-1",
List.of(new RelabelRequests.Item("SKU-A", null, null, null, "Product", 1, 1,
"SHIP-1", null, "SKU-B", "Replace", null, null, null)));
}
private AuthenticatedUser platform() {
return new AuthenticatedUser(7L, 0L, 0L, 8L, "operator", "PLATFORM", "WEB", Set.of());
}
private RelabelApplicationController controller() {
RelabelApplicationController value = new RelabelApplicationController();
ReflectionTestUtils.setField(value, "service", service);
return value;
}
}
@@ -212,7 +212,7 @@ class RelabelApplicationServiceTest {
}
private static RelabelRequests.Create request(String key, int total, int notified) {
return new RelabelRequests.Create("CUSTOMER-1", "WH-1", LocalDateTime.of(2026, 8, 20, 10, 0),
return new RelabelRequests.Create(null, "CUSTOMER-1", "WH-1", LocalDateTime.of(2026, 8, 20, 10, 0),
"Li", "13800000000", "remark", key, List.of(new RelabelRequests.Item("SKU-A", "img-1",
"image.png", "https://files/image.png", "Chinese name", total, notified, "SHP-1", "TRACK-1",
"SKU-NEW", "Label on carton", "file-1", "relabel.pdf", "https://files/relabel.pdf")));
@@ -92,7 +92,7 @@ class TaillegRealConsumerAcceptanceTest {
if (!exists("ll_relabel_application", MARKER + "-RELABEL-KEY")) {
relabel.create(CUSTOMER, "real-acceptance", new RelabelRequests.Create(
MARKER + "-RELABEL", "92", RELABEL_DEADLINE, "验收联系人", "13800000000",
null, MARKER + "-RELABEL", "92", RELABEL_DEADLINE, "验收联系人", "13800000000",
MARKER, MARKER + "-RELABEL-KEY", List.of(new RelabelRequests.Item("SKU-REAL-A", null, null,
null, "真实验收商品", 3, 3, MARKER + "-SHIP", MARKER + "-TRACK", "SKU-REAL-A-NEW",
"换标验收", null, null, null))));