Merge branch 'test' of http://8.163.30.128:10082/java-project/baiyue-firstleg into dev
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.baiyue.finance;
|
package com.baiyue.finance;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.Assumptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -18,34 +19,64 @@ class FinanceExportContractTest {
|
|||||||
"FINANCE_RECEIVABLE_STATISTICS");
|
"FINANCE_RECEIVABLE_STATISTICS");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void keepsOpenApiAndAllFileDefinitionsOnTheSameNineTypes() throws Exception {
|
void keepsAllFileDefinitionsOnTheSameNineTypes() throws Exception {
|
||||||
String openApi = Files.readString(resolve("docs", "财务管理", "openapi", "finance-phase1-five-pages-v1.yaml"), StandardCharsets.UTF_8);
|
Path backendRoot = backendRoot();
|
||||||
String application = Files.readString(resolve("baiyue-firstleg", "file", "src", "main", "resources", "application.yml"), StandardCharsets.UTF_8);
|
String application = Files.readString(backendRoot.resolve("file/src/main/resources/application.yml"), StandardCharsets.UTF_8);
|
||||||
String local = Files.readString(resolve("baiyue-firstleg", "config", "nacos", "local", "file-service.yml"), StandardCharsets.UTF_8);
|
String local = Files.readString(backendRoot.resolve("config/nacos/local/file-service.yml"), StandardCharsets.UTF_8);
|
||||||
String cn = Files.readString(resolve("baiyue-firstleg", "config", "nacos", "cn", "file-service.yml"), StandardCharsets.UTF_8);
|
String cn = Files.readString(backendRoot.resolve("config/nacos/cn/file-service.yml"), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
Yaml yaml = new Yaml();
|
Yaml yaml = new Yaml();
|
||||||
assertThat((Object) yaml.load(openApi)).isNotNull();
|
|
||||||
assertThat((Object) yaml.load(application)).isNotNull();
|
assertThat((Object) yaml.load(application)).isNotNull();
|
||||||
assertThat((Object) yaml.load(local)).isNotNull();
|
assertThat((Object) yaml.load(local)).isNotNull();
|
||||||
assertThat((Object) yaml.load(cn)).isNotNull();
|
assertThat((Object) yaml.load(cn)).isNotNull();
|
||||||
|
|
||||||
assertThat(openApi).contains("/internal/exports/v1/{exportType}/batches:")
|
|
||||||
.contains("customerId?, status?, settlementNo?")
|
|
||||||
.contains("所有 DETAIL 仅 settlementId")
|
|
||||||
.doesNotContain("DETAIL: settlementId, direction");
|
|
||||||
for (String type : TYPES) {
|
for (String type : TYPES) {
|
||||||
assertThat(openApi).contains("- " + type);
|
|
||||||
assertThat(application).contains(type + ":").contains("provider-path: /internal/exports/v1/" + type + "/batches");
|
assertThat(application).contains(type + ":").contains("provider-path: /internal/exports/v1/" + type + "/batches");
|
||||||
assertThat(local).contains(type + ":").contains("provider-path: /internal/exports/v1/" + type + "/batches");
|
assertThat(local).contains(type + ":").contains("provider-path: /internal/exports/v1/" + type + "/batches");
|
||||||
assertThat(cn).contains(type + ":").contains("provider-path: /internal/exports/v1/" + type + "/batches");
|
assertThat(cn).contains(type + ":").contains("provider-path: /internal/exports/v1/" + type + "/batches");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Path resolve(String... segments) {
|
@Test
|
||||||
Path repository = Path.of("").toAbsolutePath().normalize();
|
void keepsOuterOpenApiOnTheSameNineTypesWhenAvailable() throws Exception {
|
||||||
while (repository != null && !Files.exists(repository.resolve("apps").resolve("admin-web"))) repository = repository.getParent();
|
Path outerRoot = outerRoot();
|
||||||
if (repository == null) throw new IllegalStateException("repository root not found");
|
Assumptions.assumeTrue(outerRoot != null, "outer product contract repository is not part of this checkout");
|
||||||
return repository.resolve(Path.of(segments[0], java.util.Arrays.copyOfRange(segments, 1, segments.length)));
|
|
||||||
|
String openApi = Files.readString(
|
||||||
|
outerRoot.resolve("docs/财务管理/openapi/finance-phase1-five-pages-v1.yaml"),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
assertThat((Object) new Yaml().load(openApi)).isNotNull();
|
||||||
|
assertThat(openApi).contains("/internal/exports/v1/{exportType}/batches:")
|
||||||
|
.contains("customerId?, status?, settlementNo?")
|
||||||
|
.contains("所有 DETAIL 仅 settlementId")
|
||||||
|
.doesNotContain("DETAIL: settlementId, direction");
|
||||||
|
for (String type : TYPES) {
|
||||||
|
assertThat(openApi).contains("- " + type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Path backendRoot() {
|
||||||
|
Path current = Path.of("").toAbsolutePath().normalize();
|
||||||
|
while (current != null) {
|
||||||
|
if (Files.exists(current.resolve("pom.xml"))
|
||||||
|
&& Files.isDirectory(current.resolve("finance"))
|
||||||
|
&& Files.isDirectory(current.resolve("file"))) {
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
current = current.getParent();
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("backend repository root not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Path outerRoot() {
|
||||||
|
Path current = backendRoot();
|
||||||
|
while (current != null) {
|
||||||
|
if (Files.isDirectory(current.resolve("apps/admin-web"))
|
||||||
|
&& Files.isDirectory(current.resolve("docs/财务管理"))) {
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
current = current.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user