Files
baiyue-firstleg/file/src/test/java/com/baiyue/file/service/OverseasExceptionEvidenceContractTest.java
T
2026-09-17 17:37:29 +08:00

38 lines
1.6 KiB
Java

package com.baiyue.file.service;
import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
import static org.assertj.core.api.Assertions.assertThat;
class OverseasExceptionEvidenceContractTest {
@Test
void categoryAndOpenApiFreezeCustomerExceptionOwnership() throws Exception {
BusinessFileCategory category = BusinessFileCategory.require("OVERSEAS_EXCEPTION_EVIDENCE");
assertThat(category.maxSizeBytes()).isEqualTo(10L * 1024 * 1024);
assertThat(category.formatPolicy()).isEqualTo(BusinessFileCategory.FormatPolicy.STANDARD);
try (var stream = getClass().getResourceAsStream(
"/openapi/overseas-exception-evidence-v1.yaml")) {
assertThat(stream).isNotNull();
String yaml = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
assertThat(yaml).contains(
"/internal/file/v1/business-files/{tenantId}/OVERSEAS_EXCEPTION_EVIDENCE/{exceptionOrderId}:",
"ownerScope: {type: string, enum: [CUSTOMER]}",
"businessType: {type: string, enum: [OVERSEAS_EXCEPTION_EVIDENCE]}",
"maximum: 10485760");
}
}
@Test
void initializationSqlHasEnoughWidthAndDocumentsTheCategory() throws Exception {
try (var stream = getClass().getResourceAsStream("/db/file.sql")) {
assertThat(stream).isNotNull();
String sql = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
assertThat(sql).contains("business_type VARCHAR(64)", "OVERSEAS_EXCEPTION_EVIDENCE");
assertThat("OVERSEAS_EXCEPTION_EVIDENCE").hasSizeLessThanOrEqualTo(64);
}
}
}