2026-08-19 16:24:02 +08:00
|
|
|
package com.baiyue.lastleg.relabel;
|
|
|
|
|
|
|
|
|
|
import com.baiyue.lastleg.relabel.dto.RelabelRequests;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.RecordComponent;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
|
|
|
|
|
|
class RelabelContractTest {
|
|
|
|
|
@Test
|
|
|
|
|
void createHeaderDoesNotExposeWaybillLabelFileAndItemCarriesRequestedFileFields() {
|
|
|
|
|
assertFalse(Arrays.stream(RelabelRequests.Create.class.getRecordComponents())
|
|
|
|
|
.map(RecordComponent::getName)
|
|
|
|
|
.anyMatch(name -> name.toLowerCase().contains("waybill") || name.toLowerCase().contains("labelFile")));
|
|
|
|
|
assertTrue(Arrays.stream(RelabelRequests.Item.class.getRecordComponents())
|
|
|
|
|
.map(RecordComponent::getName).toList().containsAll(Arrays.asList("skuCode", "productImageFileId",
|
|
|
|
|
"productNameZh", "totalPackageCount", "notifiedPackageCount", "shipmentNo", "trackingCode",
|
|
|
|
|
"newSkuCode", "labelRequirement", "relabelFileId")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void schemasDefineRelabelApplicationItemsAndHistoryContracts() throws Exception {
|
|
|
|
|
String baseline = Files.readString(Path.of("src/main/resources/db/lastleg.sql"), StandardCharsets.UTF_8).toLowerCase();
|
|
|
|
|
String migration = Files.readString(Path.of("..", "scripts", "db", "incremental.sql"), StandardCharsets.UTF_8).toLowerCase();
|
|
|
|
|
for (String schema : new String[] { baseline, migration }) {
|
|
|
|
|
assertTrue(schema.contains("ll_relabel_application"));
|
|
|
|
|
assertTrue(schema.contains("ll_relabel_item"));
|
|
|
|
|
assertTrue(schema.contains("ll_relabel_status_history"));
|
|
|
|
|
assertTrue(schema.contains("customer_id"));
|
|
|
|
|
assertTrue(schema.contains("idempotency_key"));
|
|
|
|
|
assertTrue(schema.contains("request_hash"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-21 10:43:25 +08:00
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void openApiDocumentsAllRelabelApplicationOperations() throws Exception {
|
|
|
|
|
String openApi = Files.readString(Path.of("src/main/resources/openapi/overseas-business-v1.yaml"), StandardCharsets.UTF_8);
|
|
|
|
|
assertTrue(openApi.contains("/api/platform/v1/last-leg/relabel-applications:"));
|
|
|
|
|
assertTrue(openApi.contains("/api/platform/v1/last-leg/relabel-applications/{relabelNo}:"));
|
|
|
|
|
assertTrue(openApi.contains("/api/platform/v1/last-leg/relabel-applications/{relabelNo}/status:"));
|
|
|
|
|
assertTrue(openApi.contains("RelabelCreate"));
|
|
|
|
|
assertTrue(openApi.contains("RelabelStatusChange"));
|
|
|
|
|
assertTrue(openApi.contains("platform:overseas-warehouse:relabel-order:list"));
|
|
|
|
|
assertTrue(openApi.contains("platform:overseas-warehouse:relabel-order:create"));
|
|
|
|
|
assertTrue(openApi.contains("platform:overseas-warehouse:relabel-order:status"));
|
|
|
|
|
String relabelPaths = openApi.substring(openApi.indexOf("/api/platform/v1/last-leg/relabel-applications:"),
|
|
|
|
|
openApi.indexOf("components:"));
|
|
|
|
|
assertFalse(relabelPaths.contains("name: customerId"));
|
|
|
|
|
}
|
2026-08-19 16:24:02 +08:00
|
|
|
}
|