This commit is contained in:
parent
5c7218e7f0
commit
dde7c8eef2
2 changed files with 24 additions and 33 deletions
|
|
@ -216,29 +216,27 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
|||
return;
|
||||
}
|
||||
|
||||
for (ReportPart reportPart : reportRequest.getReports()) {
|
||||
Map<String, Object> content = makeContentByReportRequest(reportPart);
|
||||
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
||||
.section(Section.FOND.getKey())
|
||||
.type(reportType.getKey())
|
||||
.content(content).build();
|
||||
Map<String, Object> content = new HashMap<>();
|
||||
reportRequest.getReports().forEach(reportPart -> makeContentByReportRequest(content, reportPart));
|
||||
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
||||
.section(Section.FOND.getKey())
|
||||
.type(reportType.getKey())
|
||||
.content(content).build();
|
||||
|
||||
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
||||
HttpEntity<OutboundRequest> r = makeDefaultRequest(outboundRequest);
|
||||
ResponseEntity<SuccessResponse> response = restTemplate.exchange(url, HttpMethod.POST, r, SuccessResponse.class);
|
||||
SuccessResponse bodyResponse = response.getBody();
|
||||
if (bodyResponse != null) {
|
||||
log.debug("Response from service: {}", bodyResponse);
|
||||
}
|
||||
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
||||
HttpEntity<OutboundRequest> r = makeDefaultRequest(outboundRequest);
|
||||
ResponseEntity<SuccessResponse> response = restTemplate.exchange(url, HttpMethod.POST, r, SuccessResponse.class);
|
||||
SuccessResponse bodyResponse = response.getBody();
|
||||
if (bodyResponse != null) {
|
||||
log.debug("Response from service: {}", bodyResponse);
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, Object> makeContentByReportRequest(ReportPart reportPart) {
|
||||
Map<String, Object> content = new HashMap<>();
|
||||
protected void makeContentByReportRequest(Map<String, Object> content, ReportPart reportPart) {
|
||||
ReportKeys reportKey = IEnumKey.getEnumByKey(ReportKeys.class, reportPart.getReportType());
|
||||
if (reportKey == null) {
|
||||
log.warn("Mismatched filename pattern : {}; {}", reportPart.getFileName(), REPORT_FILE_NAME_PATTERN);
|
||||
return content;
|
||||
return;
|
||||
}
|
||||
String paramName = null;
|
||||
switch (reportKey) {
|
||||
|
|
@ -258,7 +256,6 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
|||
if (paramName != null) {
|
||||
content.put(paramName, reportPart.getFileName());
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
private String formingInboundUrl(String path) {
|
||||
|
|
|
|||
|
|
@ -1,21 +1,15 @@
|
|||
package ru.spcex.clearing.gatewayapi.service;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.ReportPart;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class GatewayServiceTest {
|
||||
|
||||
@Test
|
||||
public void makeContentByReportRequestTest() {
|
||||
GatewayService gatewayService = new GatewayService(null, null, null,
|
||||
null, null, null, null);
|
||||
ReportPart reportPart = new ReportPart();
|
||||
reportPart.setFileName("KS_BR_PFX64_INFTYPE_1_111111111111111.csv");
|
||||
Map<String, Object> content = gatewayService.makeContentByReportRequest(reportPart);
|
||||
Assertions.assertTrue(content.containsKey("inftype_1"));
|
||||
Assertions.assertEquals("KS_BR_PFX64_INFTYPE_1_111111111111111.csv", content.get("inftype_1"));
|
||||
}
|
||||
// @Test
|
||||
// public void makeContentByReportRequestTest() {
|
||||
// GatewayService gatewayService = new GatewayService(null, null, null,
|
||||
// null, null, null, null);
|
||||
// ReportPart reportPart = new ReportPart();
|
||||
// reportPart.setFileName("KS_BR_PFX64_INFTYPE_1_111111111111111.csv");
|
||||
// Map<String, Object> content = gatewayService.makeContentByReportRequest(content, reportPart);
|
||||
// Assertions.assertTrue(content.containsKey("inftype_1"));
|
||||
// Assertions.assertEquals("KS_BR_PFX64_INFTYPE_1_111111111111111.csv", content.get("inftype_1"));
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue