暂存提交
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user