summaryrefslogtreecommitdiffstats
path: root/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java')
-rw-r--r--dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java245
1 files changed, 218 insertions, 27 deletions
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java
index 5e9957e..ac01169 100644
--- a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java
+++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java
@@ -1,6 +1,7 @@
/*
- * ================================================================================
+ * ===========LICENSE_START========================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,29 +42,18 @@ import com.fasterxml.jackson.databind.ObjectMapper;
*/
class TcaProcessingServiceImplTest {
-// @Autowired
-// Environment environment;
+// @Autowired
+// Environment environment;
- public TcaPolicy convertTcaPolicy(String tcaPolicyString) {
- return TCA_POLICY_JSON_FUNCTION.apply(tcaPolicyString).orElseThrow(
+ public List<TcaPolicy> convertTcaPolicy(String tcaPolicyString) {
+ return TCA_POLICY_JSON_FUNCTION.apply(tcaPolicyString).orElseThrow(
() -> new AnalyticsParsingException("Unable to parse Tca Policy String: " + tcaPolicyString,
new IllegalArgumentException()));
}
+
+ String policy = "[{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]},{\"domain\":\"measurement\",\"metricsPerEventName\":[{\"eventName\":\"vFirewallBroadcastPackets\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":700,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"Measurement_vGMUX\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"GREATER\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]}]}]";
- @Test
- void getTcaExecutionResults() throws Exception {
- TcaAbatementContext tcaAbatementContext = new TestTcaAbatementContext();
- TcaAaiEnrichmentContext tcaAaiEnrichmentContext = new TestTcaAaiEnrichmentContext();
-
- TcaPolicyWrapper tcaPolicyWrapper = Mockito.mock(TcaPolicyWrapper.class);
-// TcaAppProperties tcaAppProperties = new TcaAppProperties(environment);
- String policy = "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]}";
-// TcaPolicyWrapper tcaPolicyWrapper = new TcaPolicyWrapper(tcaAppProperties);
- TcaPolicy tcaPolicy = convertTcaPolicy(policy);
- Mockito.when(tcaPolicyWrapper.getTcaPolicy()).thenReturn(tcaPolicy);
- TcaProcessingService tcaProcessingService = new TcaProcessingServiceImpl(tcaAbatementContext, tcaAaiEnrichmentContext);
-
- String cefMessage = "{\r\n" +
+ String cefMessage = "{\r\n" +
" \"event\": {\r\n" +
" \"commonEventHeader\": {\r\n" +
" \"domain\": \"measurementsForVfScaling\",\r\n" +
@@ -141,7 +131,174 @@ class TcaProcessingServiceImplTest {
"}\r\n" +
"";
- String cefViolationMessage = "{\r\n" +
+ String cefV7Message = "{\r\n" +
+ " \"event\": {\r\n" +
+ " \"commonEventHeader\": {\r\n" +
+ " \"domain\": \"measurement\",\r\n" +
+ " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" +
+ " \"eventName\": \"vFirewallBroadcastPackets\",\r\n" +
+ " \"lastEpochMicrosec\": 1492639920787,\r\n" +
+ " \"nfNamingCode\": \"ENBE\",\r\n" +
+ " \"priority\": \"Normal\",\r\n" +
+ " \"reportingEntityId\": \"\",\r\n" +
+ " \"reportingEntityName\": \"vtc2e7admn2\",\r\n" +
+ " \"sequence\": 0,\r\n" +
+ " \"sourceId\": \"SCL01081_9B_1\",\r\n" +
+ " \"sourceName\": \"SCL01081\",\r\n" +
+ " \"startEpochMicrosec\": 1492639920787,\r\n" +
+ " \"version\": 3.0,\r\n" +
+ " \"vesEventListenerVersion\":\"7.2.1\"\r\n" +
+ " },\r\n" +
+ " \"measurementFields\": {\r\n" +
+ " \"additionalFields\": [\r\n" +
+ " {\r\n" +
+ " \"name\": \"software_version \",\r\n" +
+ " \"value\": \"version1\"\r\n" +
+ " },\r\n" +
+ " {\r\n" +
+ " \"name\": \"vendor \",\r\n" +
+ " \"value\": \"Ericsson \"\r\n" +
+ " }\r\n" +
+ " ],\r\n" +
+ " \"additionalMeasurements\": [\r\n" +
+ " {\r\n" +
+ " \"name\": \"OaaS_UC1_EricssonSleepingCell\",\r\n" +
+ " \"arrayOfFields\": [\r\n" +
+ " {\r\n" +
+ " \"name\": \"PMRAATTCBRA\",\r\n" +
+ " \"value\": \"1353\"\r\n" +
+ " },\r\n" +
+ " {\r\n" +
+ " \"name\": \"PMRASUCCCBRA\",\r\n" +
+ " \"value\": \"1351\"\r\n" +
+ " },\r\n" +
+ " {\r\n" +
+ " \"name\": \"PMCELLDOWNTIMEAUTO\",\r\n" +
+ " \"value\": \"0\"\r\n" +
+ " },\r\n" +
+ " {\r\n" +
+ " \"name\": \"PMCELLDOWNTIMEMAN\",\r\n" +
+ " \"value\": \"0\"\r\n" +
+ " },\r\n" +
+ " {\r\n" +
+ " \"name\": \"PMRRCCONNESTABATT\",\r\n" +
+ " \"value\": \"297\"\r\n" +
+ " },\r\n" +
+ " {\r\n" +
+ " \"name\": \"PMRRCCONNESTABSUCC\",\r\n" +
+ " \"value\": \"297\"\r\n" +
+ " }\r\n" +
+ " ]\r\n" +
+ " }\r\n" +
+ " ],\r\n" +
+ " \"nicPerformanceArray\": [\r\n" +
+ " {\r\n" +
+ " \"receivedBroadcastPacketsAccumulated\": 1002,\r\n" +
+ " \"receivedBroadcastPacketsDelta\": 5,\r\n" +
+ " \"receivedDiscardedPacketsAccumulated\": 12,\r\n" +
+ " \"receivedDiscardedPacketsDelta\": 2,\r\n" +
+ " \"receivedErrorPacketsAccumulated\": 2,\r\n" +
+ " \"receivedErrorPacketsDelta\": 1,\r\n" +
+ " \"valuesAreSuspect\": false,\r\n" +
+ " \"nicIdentifier\": \"someVNicIdentifier\"\r\n" +
+ " }\r\n" +
+ " ],\r\n" +
+ " \"measurementInterval\": 900,\r\n" +
+ " \"measurementFieldsVersion\": 2.0\r\n" +
+ " }\r\n" +
+ " }\r\n" +
+ "}\r\n" +
+ "";
+
+ String cefV7OnsetMessage = "{\r\n" +
+ " \"event\": {\r\n" +
+ " \"commonEventHeader\": {\r\n" +
+ " \"domain\": \"measurement\",\r\n" +
+ " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" +
+ " \"eventName\": \"vFirewallBroadcastPackets\",\r\n" +
+ " \"lastEpochMicrosec\": 1492639920787,\r\n" +
+ " \"nfNamingCode\": \"ENBE\",\r\n" +
+ " \"priority\": \"Normal\",\r\n" +
+ " \"reportingEntityId\": \"\",\r\n" +
+ " \"reportingEntityName\": \"vtc2e7admn2\",\r\n" +
+ " \"sequence\": 0,\r\n" +
+ " \"sourceId\": \"SCL01081_9B_1\",\r\n" +
+ " \"sourceName\": \"SCL01081\",\r\n" +
+ " \"startEpochMicrosec\": 1492639920787,\r\n" +
+ " \"version\": 3.0,\r\n" +
+ " \"vesEventListenerVersion\":\"7.2.1\"\r\n" +
+ " },\r\n" +
+ " \"measurementFields\": {\r\n" +
+ " \"cpuUsageArray\": [\r\n" +
+ " {\r\n" +
+ " \"percentUsage\": 0,\r\n" +
+ " \"cpuIdentifier\": \"cpu1\",\r\n" +
+ " \"cpuIdle\": 100,\r\n" +
+ " \"cpuUsageSystem\": 0\r\n" +
+ " }\r\n" +
+ " ],\r\n" +
+ " \"nicPerformanceArray\": [\r\n" +
+ " {\r\n" +
+ " \"receivedTotalPacketsDelta\": 1002,\r\n" +
+ " \"transmittedOctetsDelta\": 0,\r\n" +
+ " \"transmittedTotalPacketsDelta\": 0,\r\n" +
+ " \"receivedOctetsDelta\": 61200,\r\n" +
+ " \"valuesAreSuspect\": true,\r\n" +
+ " \"nicIdentifier\": \"someNicIdentifier\"\r\n" +
+ " }\r\n" +
+ " ],\r\n" +
+ " \"measurementInterval\": 900,\r\n" +
+ " \"measurementFieldsVersion\": 4.0\r\n" +
+ " }\r\n" +
+ " }\r\n" +
+ "}\r\n" +
+ "";
+
+ String cefV7AbatementMessage = "{\r\n" +
+ " \"event\": {\r\n" +
+ " \"commonEventHeader\": {\r\n" +
+ " \"domain\": \"measurement\",\r\n" +
+ " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" +
+ " \"eventName\": \"vFirewallBroadcastPackets\",\r\n" +
+ " \"lastEpochMicrosec\": 1492639920787,\r\n" +
+ " \"nfNamingCode\": \"ENBE\",\r\n" +
+ " \"priority\": \"Normal\",\r\n" +
+ " \"reportingEntityId\": \"\",\r\n" +
+ " \"reportingEntityName\": \"vtc2e7admn2\",\r\n" +
+ " \"sequence\": 0,\r\n" +
+ " \"sourceId\": \"SCL01081_9B_1\",\r\n" +
+ " \"sourceName\": \"SCL01081\",\r\n" +
+ " \"startEpochMicrosec\": 1492639920787,\r\n" +
+ " \"version\": 3.0,\r\n" +
+ " \"vesEventListenerVersion\":\"7.2.1\"\r\n" +
+ " },\r\n" +
+ " \"measurementFields\": {\r\n" +
+ " \"cpuUsageArray\": [\r\n" +
+ " {\r\n" +
+ " \"percentUsage\": 0,\r\n" +
+ " \"cpuIdentifier\": \"cpu1\",\r\n" +
+ " \"cpuIdle\": 100,\r\n" +
+ " \"cpuUsageSystem\": 0\r\n" +
+ " }\r\n" +
+ " ],\r\n" +
+ " \"nicPerformanceArray\": [\r\n" +
+ " {\r\n" +
+ " \"receivedTotalPacketsDelta\": 100,\r\n" +
+ " \"transmittedOctetsDelta\": 0,\r\n" +
+ " \"transmittedTotalPacketsDelta\": 0,\r\n" +
+ " \"receivedOctetsDelta\": 61200,\r\n" +
+ " \"valuesAreSuspect\": true,\r\n" +
+ " \"nicIdentifier\": \"someNicIdentifier\"\r\n" +
+ " }\r\n" +
+ " ],\r\n" +
+ " \"measurementInterval\": 900,\r\n" +
+ " \"measurementFieldsVersion\": 4.0\r\n" +
+ " }\r\n" +
+ " }\r\n" +
+ "}\r\n" +
+ "";
+
+ String cefViolationMessage = "{\r\n" +
" \"event\": {\r\n" +
" \"commonEventHeader\": {\r\n" +
" \"domain\": \"measurementsForVfScaling\",\r\n" +
@@ -219,7 +376,7 @@ class TcaProcessingServiceImplTest {
"}\r\n" +
"";
- String cefAbatementMessage = "{\r\n" +
+ String cefAbatementMessage = "{\r\n" +
" \"event\": {\r\n" +
" \"commonEventHeader\": {\r\n" +
" \"domain\": \"measurementsForVfScaling\",\r\n" +
@@ -297,7 +454,7 @@ class TcaProcessingServiceImplTest {
"}\r\n" +
"";
- String cefInapplicableMessage = "{\r\n" +
+ String cefInapplicableMessage = "{\r\n" +
" \"event\": {\r\n" +
" \"commonEventHeader\": {\r\n" +
" \"domain\": \"measurementsForVfScaling\",\r\n" +
@@ -375,13 +532,22 @@ class TcaProcessingServiceImplTest {
"}\r\n" +
"";
- ObjectMapper objectMapper = new ObjectMapper();
- final List<TcaExecutionContext> tcaExecutionResults = tcaProcessingService.getTcaExecutionResults(
+ @Test
+ void getTcaExecutionResults() throws Exception {
+ TcaAbatementContext tcaAbatementContext = new TestTcaAbatementContext();
+ TcaAaiEnrichmentContext tcaAaiEnrichmentContext = new TestTcaAaiEnrichmentContext();
+ TcaPolicyWrapper tcaPolicyWrapper = Mockito.mock(TcaPolicyWrapper.class);
+
+ List<TcaPolicy> tcaPolicy = convertTcaPolicy(policy);
+ Mockito.when(tcaPolicyWrapper.getTcaPolicy()).thenReturn(tcaPolicy);
+ TcaProcessingService tcaProcessingService = new TcaProcessingServiceImpl(tcaAbatementContext, tcaAaiEnrichmentContext);
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ final List<TcaExecutionContext> tcaExecutionResults = tcaProcessingService.getTcaExecutionResults(
"testRequestId", "testTransactionId", tcaPolicyWrapper,
Arrays.asList(cefMessage, cefViolationMessage,
- cefAbatementMessage,
- cefInapplicableMessage));
-
+ cefAbatementMessage));
+
for (TcaExecutionContext tcaExecutionResult : tcaExecutionResults) {
final TcaAlert tcaAlert = tcaExecutionResult.getTcaResultContext().getTcaAlert();
String tcaAlertString = "";
@@ -390,6 +556,31 @@ class TcaProcessingServiceImplTest {
}
}
}
+
+ @Test
+ void getTcaExecutionResultsV7() throws Exception{
+ TcaAbatementContext tcaAbatementContext = new TestTcaAbatementContext();
+ TcaAaiEnrichmentContext tcaAaiEnrichmentContext = new TestTcaAaiEnrichmentContext();
+ TcaPolicyWrapper tcaPolicyWrapper = Mockito.mock(TcaPolicyWrapper.class);
+
+ List<TcaPolicy> tcaPolicy = convertTcaPolicy(policy);
+ Mockito.when(tcaPolicyWrapper.getTcaPolicy()).thenReturn(tcaPolicy);
+ TcaProcessingService tcaProcessingService = new TcaProcessingServiceImpl(tcaAbatementContext, tcaAaiEnrichmentContext);
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ final List<TcaExecutionContext> tcaExecutionResults = tcaProcessingService.getTcaExecutionResults(
+ "testRequestId", "testTransactionId", tcaPolicyWrapper,
+ Arrays.asList(cefV7Message, cefV7OnsetMessage,
+ cefV7AbatementMessage));
+
+ for (TcaExecutionContext tcaExecutionResult : tcaExecutionResults) {
+ final TcaAlert tcaAlert = tcaExecutionResult.getTcaResultContext().getTcaAlert();
+ String tcaAlertString = "";
+ if (tcaAlert != null) {
+ tcaAlertString = objectMapper.writeValueAsString(tcaAlert);
+ }
+ }
+ }
}