refactor: remove sample HTTP tool integration
Some checks failed
Deploy to OCIWP / deploy (push) Has been cancelled

This commit is contained in:
jade
2026-08-11 23:41:57 +09:00
parent 0e27937687
commit 6662641903
28 changed files with 72 additions and 371 deletions

View File

@@ -47,16 +47,6 @@ public class AxhubHttpComponent {
return execute(api, uri, inputDto, responseBodyClass, timeout);
}
/** Backward-compatible enum overload. */
public <T, R> R call(AxhubHttpDomain domain, String uri, T inputDto, Class<R> responseBodyClass) {
return call(domain.getCode(), uri, inputDto, responseBodyClass, 0);
}
/** Backward-compatible enum overload. */
public <T, R> R call(AxhubHttpDomain domain, String uri, T inputDto, Class<R> responseBodyClass, int timeout) {
return call(domain.getCode(), uri, inputDto, responseBodyClass, timeout);
}
/** Calls the configured URL only when the target is marked as a business Pod. */
public <T, R> R callBizPod(String apiName, T inputDto, Class<R> responseBodyClass) {
AxhubHttpProperties.ApiDefinition api = resolveApi(apiName);
@@ -66,15 +56,6 @@ public class AxhubHttpComponent {
return execute(api, "", inputDto, responseBodyClass, 0);
}
/** Backward-compatible enum overload. */
public <T, R> R callBizPod(AxhubHttpDomain domain, String uri, T inputDto, Class<R> responseBodyClass) {
AxhubHttpProperties.ApiDefinition api = resolveApi(domain.getCode());
if (!api.bizPod()) {
throw new IllegalArgumentException("Configured API is not a business Pod: " + domain.getCode());
}
return execute(api, uri, inputDto, responseBodyClass, 0);
}
private <T, R> R execute(AxhubHttpProperties.ApiDefinition api, String uri, T inputDto,
Class<R> responseBodyClass, int timeout) {
HttpHeader header = createHeader(api, timeout);
@@ -156,4 +137,4 @@ public class AxhubHttpComponent {
String right = suffix.startsWith("/") ? suffix : "/" + suffix;
return left + right;
}
}
}

View File

@@ -1,16 +0,0 @@
package io.shinhanlife.dap.lib.integration.http.component;
/** Registered outbound HTTP API domains. Add a domain only after its endpoint is configured. */
public enum AxhubHttpDomain {
SAMPLE("sample");
private final String code;
AxhubHttpDomain(String code) {
this.code = code;
}
public String getCode() {
return code;
}
}

View File

@@ -117,7 +117,8 @@ public class ToolScaffolder {
*/
public static String scaffold(String baseName, String interfaceId, String title, String description, String group, String routingType, String moduleName, String author, String createDate, boolean register, String clientSystemCode, String inputSchemaResource, String outputSchemaResource, List<FieldDefinition> inputFields, List<FieldDefinition> outputFields) throws IOException {
return scaffold(baseName, interfaceId, title, description, group, routingType, moduleName, author, createDate,
register, clientSystemCode, inputSchemaResource, outputSchemaResource, inputFields, outputFields, "sample");
register, clientSystemCode, inputSchemaResource, outputSchemaResource, inputFields, outputFields,
toKebabCase(toPascalCase(baseName)));
}
/**
@@ -127,7 +128,7 @@ public class ToolScaffolder {
baseName = toPascalCase(baseName);
title = title == null || title.isBlank() ? baseName : title.trim();
description = description == null ? "" : description.trim();
httpApiName = httpApiName == null || httpApiName.isBlank() ? "sample" : httpApiName.trim();
httpApiName = httpApiName == null || httpApiName.isBlank() ? toKebabCase(baseName) : httpApiName.trim();
String envSourceDir = System.getenv("AXHUB_SOURCE_DIR");
Path rootDir = envSourceDir != null ? Paths.get(envSourceDir) : Paths.get(".");
@@ -860,7 +861,7 @@ public class ToolScaffolder {
Files.writeString(wireMockBodyPath, mockResponse);
Files.writeString(wireMockMappingPath, wireMockMappingContent(interfaceId, wireMockBodyPath.getFileName().toString()));
Files.writeString(podMockResponsePath, mockResponse);
ensureLocalHttpApiConfiguration(moduleRoot, httpApiName, toolName);
ensureLocalHttpApiConfiguration(projectRoot, httpApiName, toolName);
log.append("[WireMock Response] ").append(wireMockBodyPath).append("\n");
log.append("[WireMock Mapping] ").append(wireMockMappingPath).append("\n");
log.append("[Pod Mock Response] ").append(podMockResponsePath).append("\n");
@@ -889,8 +890,8 @@ public class ToolScaffolder {
.toLowerCase(Locale.ROOT);
}
private static void ensureLocalHttpApiConfiguration(Path moduleRoot, String httpApiName, String toolName) throws IOException {
Path localConfigPath = moduleRoot.resolve("src/main/resources/application-local.yml");
private static void ensureLocalHttpApiConfiguration(Path projectRoot, String httpApiName, String toolName) throws IOException {
Path localConfigPath = projectRoot.resolve("dap-was-lib/src/main/resources/glow/application-glow-local.yml");
Files.createDirectories(localConfigPath.getParent());
String existing = Files.exists(localConfigPath) ? Files.readString(localConfigPath) : "";
if (java.util.regex.Pattern.compile("(?m)^\\s*-\\s+name:\\s*"
@@ -898,17 +899,7 @@ public class ToolScaffolder {
return;
}
String environmentKey = toPackageSegment(httpApiName).toUpperCase(Locale.ROOT).replace('-', '_');
String config = """
axhub:
mock:
http:
enabled: true
glow:
communication:
http:
api-list:
String apiEntry = """
- name: %s
domain: ${AXHUB_%s_HTTP_DOMAIN:http://localhost:${server.port}}
url: ${AXHUB_%s_HTTP_URL:/api/mock/http/%s}
@@ -916,7 +907,37 @@ public class ToolScaffolder {
content-type: application/json;charset=UTF-8
biz-pod: false
""".formatted(httpApiName, environmentKey, environmentKey, toolName);
Files.writeString(localConfigPath, existing + config);
if (existing.isBlank()) {
existing = """
spring:
config:
activate:
on-profile: local
glow:
communication:
http:
api-list:
""" + apiEntry;
} else if (existing.contains("\n mci:")) {
existing = existing.replace("\n mci:", apiEntry + " mci:");
} else if (existing.contains("\naxhub:")) {
existing = existing.replace("\naxhub:", apiEntry + "axhub:");
} else if (existing.contains("api-list:")) {
existing += apiEntry;
} else {
throw new IllegalStateException("application-glow-local.yml must define glow.communication.http.api-list");
}
if (!existing.contains("axhub:\n mock:\n http:\n enabled: true")) {
existing += """
axhub:
mock:
http:
enabled: true
""";
}
Files.writeString(localConfigPath, existing);
}
private static String dtoContent(String packageName, String className, List<FieldDefinition> fields,
@@ -1059,7 +1080,7 @@ public class ToolScaffolder {
String normalized = value == null ? "" : value.toLowerCase(Locale.ROOT)
.replaceAll("[^a-z0-9]+", "_")
.replaceAll("^_+|_+$", "");
return normalized.isBlank() ? "sample" : normalized;
return normalized.isBlank() ? "http_api" : normalized;
}
private static String mciConverterContent(String bizPackage, String baseName, String mciPackage, String interfaceId) {
return """

View File

@@ -13,9 +13,9 @@ glow:
connection-timeout: 5
read-timeout: 5
api-list:
- name: sample
domain: ${AXHUB_SAMPLE_HTTP_DOMAIN:http://localhost:8089}
url: ${AXHUB_SAMPLE_HTTP_URL:/CLCNNB00001}
- name: memo
domain: ${AXHUB_MEMO_HTTP_DOMAIN:http://localhost:${server.port}}
url: ${AXHUB_MEMO_HTTP_URL:/api/mock/http/cmm_memo_retriever}
method: POST
content-type: application/json;charset=UTF-8
biz-pod: false
@@ -27,4 +27,9 @@ glow:
port: ${GLOW_COMMUNICATION_EXTMCI_PORT:8080}
eai:
host: ${GLOW_COMMUNICATION_EAI_HOST:http://localhost}
port: ${GLOW_COMMUNICATION_EAI_PORT:8080}
port: ${GLOW_COMMUNICATION_EAI_PORT:8080}
axhub:
mock:
http:
enabled: true

View File

@@ -21,18 +21,8 @@ glow:
http:
connection-timeout: 5
read-timeout: 5
# HTTP Tool target catalog. Replace or add entries after the business endpoint is agreed.
api-list:
# WireMock/개발환경 샘플입니다. 컨테이너 내부에서는 localhost가 Tool Pod 자신을 뜻하므로
# Docker 서비스명(mci-mock)과 컨테이너 포트(8080)를 기본값으로 사용합니다.
# 로컬 PC에서 실행할 때는 AXHUB_SAMPLE_HTTP_DOMAIN=http://localhost:8089 로 덮어씁니다.
- name: sample
domain: ${AXHUB_SAMPLE_HTTP_DOMAIN:http://mci-mock:8080}
# mci-mock/mappings/smp_employee_search.json의 urlPath와 동일해야 합니다.
url: ${AXHUB_SAMPLE_HTTP_URL:/CLCNNB00001}
method: POST
content-type: application/json;charset=UTF-8
biz-pod: false
# HTTP Tool target catalog. Scaffold adds local mock entries after a Tool is created.
api-list: []
mci:
uri: /ntl_mci/dap_rcv
receive-uri: /itrf/mciReceive
@@ -48,4 +38,4 @@ glow:
encoding: EUC-KR
websocket:
endpoint: /ws-glow
allowed-origins: "*"
allowed-origins: "*"

View File

@@ -19,13 +19,13 @@ import org.springframework.web.client.RestClient;
class AxhubHttpComponentTest {
@Test
void callResolvesDomainBuildsGlowTransferAndDeserializesJsonResponse() {
void callByApiNameBuildsGlowTransferAndDeserializesJsonResponse() {
RestClient.Builder builder = RestClient.builder();
MockRestServiceServer server = MockRestServiceServer.bindTo(builder).build();
GlowHttpComponent glowHttpComponent = new GlowHttpComponent(builder);
AxhubHttpProperties properties = new AxhubHttpProperties();
properties.setApiList(List.of(new AxhubHttpProperties.ApiDefinition(
"sample", "https://api.example.test", "/v1", HttpMethod.GET, "application/json", false)));
"status", "https://api.example.test", "/v1", HttpMethod.GET, "application/json", false)));
AxhubHttpComponent component = new AxhubHttpComponent(
glowHttpComponent, new ObjectMapper(), new GlowCommunicationProperties(), properties);
@@ -33,7 +33,7 @@ class AxhubHttpComponentTest {
.andExpect(header("X-ANONYMOUS-REQ", "AXHUB-TOOL"))
.andRespond(withSuccess("{\"status\":\"OK\"}", APPLICATION_JSON));
SampleResponse response = component.call(AxhubHttpDomain.SAMPLE, "/status", null, SampleResponse.class);
SampleResponse response = component.call("status", "/status", null, SampleResponse.class);
assertThat(response.status()).isEqualTo("OK");
server.verify();
@@ -64,4 +64,4 @@ class AxhubHttpComponentTest {
}
record SampleResponse(String status) {
}
}
}

View File

@@ -162,11 +162,11 @@ class ToolScaffolderTest {
assertTrue(response.indexOf("private String resultCode;") == response.lastIndexOf("private String resultCode;"), response);
assertTrue(response.indexOf("private String employeeName;") == response.lastIndexOf("private String employeeName;"), response);
String converter = Files.readString(root.resolve("dap-was-http/src/main/java/io/shinhanlife/dap/mcc/biz/smp/converter/EmployeeSearchConverter.java"));
String httpRequest = Files.readString(root.resolve("dap-was-http/src/main/java/io/shinhanlife/dap/mcc/infra/itrf/http/sample/io/EmployeeSearchHttpRequest.java"));
String httpResponse = Files.readString(root.resolve("dap-was-http/src/main/java/io/shinhanlife/dap/mcc/infra/itrf/http/sample/io/EmployeeSearchHttpResponse.java"));
String httpClient = Files.readString(root.resolve("dap-was-http/src/main/java/io/shinhanlife/dap/mcc/infra/itrf/http/sample/SampleClient.java"));
String httpRequest = Files.readString(root.resolve("dap-was-http/src/main/java/io/shinhanlife/dap/mcc/infra/itrf/http/employee_search/io/EmployeeSearchHttpRequest.java"));
String httpResponse = Files.readString(root.resolve("dap-was-http/src/main/java/io/shinhanlife/dap/mcc/infra/itrf/http/employee_search/io/EmployeeSearchHttpResponse.java"));
String httpClient = Files.readString(root.resolve("dap-was-http/src/main/java/io/shinhanlife/dap/mcc/infra/itrf/http/employee_search/EmployeeSearchClient.java"));
assertFalse(converter.contains("phoneNumber"), converter);
assertTrue(converter.contains("infra.itrf.http.sample.io.EmployeeSearchHttpRequest"), converter);
assertTrue(converter.contains("infra.itrf.http.employee_search.io.EmployeeSearchHttpRequest"), converter);
assertFalse(converter.contains("io.shinhanlife.dap.mcc.io.shinhanlife.dap.mcc"), converter);
assertTrue(converter.contains("// @Mapping(source = \"sourceField\", target = \"targetField\")"), converter);
assertTrue(httpRequest.contains("private String employeeId;"), httpRequest);
@@ -175,9 +175,9 @@ class ToolScaffolderTest {
assertFalse(Files.exists(root.resolve("dap-was-http/src/main/java/io/shinhanlife/dap/mcc/biz/smp/legacy")));
String implementation = Files.readString(root.resolve("dap-was-http/src/main/java/io/shinhanlife/dap/mcc/biz/smp/usecase/impl/EmployeeSearchUseCaseImpl.java"));
assertTrue(implementation.contains("public EmployeeSearchResponse execute(EmployeeSearchRequest req)"), implementation);
assertTrue(implementation.contains("import io.shinhanlife.dap.mcc.infra.itrf.http.sample.SampleClient;"), implementation);
assertTrue(implementation.contains("private final SampleClient sampleClient;"), implementation);
assertTrue(implementation.contains("sampleClient.call(httpRequest, EmployeeSearchHttpResponse.class)"), implementation);
assertTrue(implementation.contains("import io.shinhanlife.dap.mcc.infra.itrf.http.employee_search.EmployeeSearchClient;"), implementation);
assertTrue(implementation.contains("private final EmployeeSearchClient employeeSearchClient;"), implementation);
assertTrue(implementation.contains("employeeSearchClient.call(httpRequest, EmployeeSearchHttpResponse.class)"), implementation);
assertFalse(implementation.contains("AxhubHttpComponent"), implementation);
assertFalse(implementation.contains("executeLegacy(\"HTTP\""), implementation);
Path wireMockResponse = root.resolve("mci-mock/__files/smp_employee_search.json");
@@ -185,17 +185,17 @@ class ToolScaffolderTest {
assertTrue(Files.exists(wireMockResponse), wireMockResponse.toString());
assertTrue(Files.exists(wireMockMapping), wireMockMapping.toString());
assertTrue(Files.readString(wireMockMapping).contains("\"urlPath\" : \"/HR_EMPLOYEE_SEARCH\""));
Path localConfig = root.resolve("dap-was-http/src/main/resources/application-local.yml");
Path localConfig = root.resolve("dap-was-lib/src/main/resources/glow/application-glow-local.yml");
assertTrue(Files.exists(localConfig), localConfig.toString());
assertTrue(Files.readString(localConfig).contains("name: sample"));
assertTrue(Files.readString(localConfig).contains("url: ${AXHUB_SAMPLE_HTTP_URL:/api/mock/http/smp_employee_search}"));
assertTrue(Files.readString(localConfig).contains("name: employee-search"));
assertTrue(Files.readString(localConfig).contains("url: ${AXHUB_EMPLOYEE_SEARCH_HTTP_URL:/api/mock/http/smp_employee_search}"));
Path podMockResponse = root.resolve("dap-was-http/src/main/resources/mock-responses/smp_employee_search.json");
assertTrue(Files.exists(podMockResponse), podMockResponse.toString());
ToolScaffolder.scaffold("employee search", "HR_EMPLOYEE_SEARCH", "Employee search", "smp", "HTTP", moduleName,
"tester", "2026.08.11", false, null, null, null, inputFields, outputFields);
long apiNameCount = Files.readAllLines(localConfig).stream()
.filter(line -> line.trim().equals("- name: sample"))
.filter(line -> line.trim().equals("- name: employee-search"))
.count();
assertEquals(1, apiNameCount);
}