diff options
Diffstat (limited to 'dcae-analytics/dcae-analytics-tca-web/src/test')
6 files changed, 556 insertions, 21 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 5723160..426ae46 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 @@ -19,43 +19,368 @@ package org.onap.dcae.analytics.tca.web.service; -import com.fasterxml.jackson.databind.ObjectMapper; +import static org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion.TCA_POLICY_JSON_FUNCTION; import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; +import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext; +import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext; import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext; import org.onap.dcae.analytics.tca.model.facade.TcaAlert; -import org.onap.dcae.analytics.tca.web.BaseTcaWebSpringBootIT; +import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; +import org.onap.dcae.analytics.tca.web.TcaAppProperties; import org.onap.dcae.analytics.tca.web.domain.TcaPolicyWrapper; +import org.onap.dcae.analytics.web.exception.AnalyticsParsingException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; + +import com.fasterxml.jackson.databind.ObjectMapper; /** * @author Rajiv Singla */ -class TcaProcessingServiceImplTest extends BaseTcaWebSpringBootIT { - - @Autowired - private TcaProcessingService tcaProcessingService; +class TcaProcessingServiceImplTest { - @Autowired - private TcaPolicyWrapper tcaPolicyWrapper; +// @Autowired +// Environment environment; - @Autowired - private ObjectMapper objectMapper; + public TcaPolicy convertTcaPolicy(String tcaPolicyString) { + return TCA_POLICY_JSON_FUNCTION.apply(tcaPolicyString).orElseThrow( + () -> new AnalyticsParsingException("Unable to parse Tca Policy String: " + tcaPolicyString, + new IllegalArgumentException())); + } @Test void getTcaExecutionResults() throws Exception { + TcaAbatementContext tcaAbatementContext = new TestTcaAbatementContext(); + TcaAaiEnrichmentContext tcaAaiEnrichmentContext = new TestTcaAaiEnrichmentContext(); + +// 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); + TcaProcessingService tcaProcessingService = new TcaProcessingServiceImpl(tcaAbatementContext, tcaAaiEnrichmentContext); + + String cefMessage = "{\r\n" + + " \"event\": {\r\n" + + " \"commonEventHeader\": {\r\n" + + " \"domain\": \"measurementsForVfScaling\",\r\n" + + " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" + + " \"eventName\": \"Mfvs_eNodeB_RANKPI\",\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" + + " },\r\n" + + " \"measurementsForVfScalingFields\": {\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" + + " \"vNicPerformanceArray\": [\r\n" + + " {\r\n" + + " \"receivedBroadcastPacketsAccumulated\": 5000,\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" + + " \"vNicIdentifier\": \"someVNicIdentifier\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"measurementInterval\": 900,\r\n" + + " \"measurementsForVfScalingVersion\": 2.0\r\n" + + " }\r\n" + + " }\r\n" + + "}\r\n" + + ""; - final List<TcaExecutionContext> tcaExecutionResults = - tcaProcessingService.getTcaExecutionResults - (TEST_REQUEST_ID, TEST_TRANSACTION_ID, tcaPolicyWrapper.getTcaPolicy(), - Arrays.asList(TEST_CEF_EVENT_LISTENER_STRING, - TEST_CEF_JSON_MESSAGE_WITH_VIOLATION_STRING, - TEST_CEF_JSON_MESSAGE_WITH_ABATEMENT_STRING, - TEST_CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME)); + String cefViolationMessage = "{\r\n" + + " \"event\": {\r\n" + + " \"commonEventHeader\": {\r\n" + + " \"domain\": \"measurementsForVfScaling\",\r\n" + + " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" + + " \"eventName\": \"Mfvs_eNodeB_RANKPI\",\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" + + " },\r\n" + + " \"measurementsForVfScalingFields\": {\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" + + " \"vNicPerformanceArray\": [\r\n" + + " {\r\n" + + " \"receivedBroadcastPacketsAccumulated\": 21000,\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" + + " \"vNicIdentifier\": \"someVNicIdentifier\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"measurementInterval\": 900,\r\n" + + " \"measurementsForVfScalingVersion\": 2.0\r\n" + + " }\r\n" + + " }\r\n" + + "}\r\n" + + ""; + String cefAbatementMessage = "{\r\n" + + " \"event\": {\r\n" + + " \"commonEventHeader\": {\r\n" + + " \"domain\": \"measurementsForVfScaling\",\r\n" + + " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" + + " \"eventName\": \"Mfvs_eNodeB_RANKPI\",\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" + + " },\r\n" + + " \"measurementsForVfScalingFields\": {\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" + + " \"vNicPerformanceArray\": [\r\n" + + " {\r\n" + + " \"receivedBroadcastPacketsAccumulated\": 0,\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" + + " \"vNicIdentifier\": \"someVNicIdentifier\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"measurementInterval\": 900,\r\n" + + " \"measurementsForVfScalingVersion\": 2.0\r\n" + + " }\r\n" + + " }\r\n" + + "}\r\n" + + ""; + + String cefInapplicableMessage = "{\r\n" + + " \"event\": {\r\n" + + " \"commonEventHeader\": {\r\n" + + " \"domain\": \"measurementsForVfScaling\",\r\n" + + " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" + + " \"eventName\": \"testEventName\",\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" + + " },\r\n" + + " \"measurementsForVfScalingFields\": {\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" + + " \"vNicPerformanceArray\": [\r\n" + + " {\r\n" + + " \"receivedBroadcastPacketsAccumulated\": 5000,\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" + + " \"vNicIdentifier\": \"someVNicIdentifier\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"measurementInterval\": 900,\r\n" + + " \"measurementsForVfScalingVersion\": 2.0\r\n" + + " }\r\n" + + " }\r\n" + + "}\r\n" + + ""; + + ObjectMapper objectMapper = new ObjectMapper(); + final List<TcaExecutionContext> tcaExecutionResults = tcaProcessingService.getTcaExecutionResults( + "testRequestId", "testTransactionId", tcaPolicy, + Arrays.asList(cefMessage, cefViolationMessage, + cefAbatementMessage, + cefInapplicableMessage)); for (TcaExecutionContext tcaExecutionResult : tcaExecutionResults) { final TcaAlert tcaAlert = tcaExecutionResult.getTcaResultContext().getTcaAlert(); @@ -63,10 +388,8 @@ class TcaProcessingServiceImplTest extends BaseTcaWebSpringBootIT { if (tcaAlert != null) { tcaAlertString = objectMapper.writeValueAsString(tcaAlert); } - logger.debug("{} -> {}", tcaExecutionResult.getRequestId(), tcaAlertString); - } - } - } + + diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAaiEnrichmentContext.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAaiEnrichmentContext.java new file mode 100644 index 0000000..d8779a6 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAaiEnrichmentContext.java @@ -0,0 +1,36 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.web.service; + +import lombok.Data; + +import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext; +import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService; + +/** + * @author Rajiv Singla + */ +@Data +public class TestTcaAaiEnrichmentContext implements TcaAaiEnrichmentContext { + + private boolean isAaiEnrichmentEnabled = true; + private TcaAaiEnrichmentService aaiEnrichmentService = new TestTcaAaiEnrichmentService(); + +} diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAaiEnrichmentService.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAaiEnrichmentService.java new file mode 100644 index 0000000..0f8c7ed --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAaiEnrichmentService.java @@ -0,0 +1,41 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.web.service; + +import lombok.Data; + +import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService; +import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext; +import org.onap.dcae.analytics.tca.model.facade.TcaAlert; + +/** + * @author Rajiv Singla + */ +@Data +public class TestTcaAaiEnrichmentService implements TcaAaiEnrichmentService { + + private TcaAlert enrichedTcaAlert; + + @Override + public TcaAlert doAaiEnrichment(final TcaExecutionContext tcaExecutionContext) { + final TcaAlert tcaAlert = tcaExecutionContext.getTcaResultContext().getTcaAlert(); + return enrichedTcaAlert == null ? tcaAlert : enrichedTcaAlert; + } +} diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAbatementContext.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAbatementContext.java new file mode 100644 index 0000000..42f8c1c --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAbatementContext.java @@ -0,0 +1,46 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.web.service; + +import lombok.Data; + +import java.util.Date; + +import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext; +import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity; +import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository; + +/** + * @author Rajiv Singla + */ +@Data +public class TestTcaAbatementContext implements TcaAbatementContext { + + private boolean isAbatementEnabled = true; + private TcaAbatementRepository tcaAbatementRepository = new TestTcaAbatementRepository(); + + + @Override + public TcaAbatementEntity create( + final String lookupKey, final String requestId, final boolean isAbatementAlertSent) { + return new TestTcaAbatementEntity(new Date(), lookupKey, requestId, isAbatementAlertSent); + } + +} diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAbatementEntity.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAbatementEntity.java new file mode 100644 index 0000000..e1e8418 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAbatementEntity.java @@ -0,0 +1,41 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.web.service; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.Date; + +import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity; + +/** + * @author Rajiv Singla + */ +@Data +@AllArgsConstructor +public class TestTcaAbatementEntity implements TcaAbatementEntity { + + private Date lastModificationDate; + private String lookupKey; + private String requestId; + private boolean isAbatementAlertSent; + +} diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAbatementRepository.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAbatementRepository.java new file mode 100644 index 0000000..bc32ad8 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TestTcaAbatementRepository.java @@ -0,0 +1,48 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.web.service; + +import lombok.Data; + +import java.util.LinkedList; +import java.util.List; + +import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity; +import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository; + +/** + * @author Rajiv Singla + */ +@Data +public class TestTcaAbatementRepository implements TcaAbatementRepository { + + private List<TcaAbatementEntity> testLookupAbatementEntities = new LinkedList<>(); + + @Override + public void save(final TcaAbatementEntity tcaAbatementEntity) { + // do nothing + } + + @Override + public List<TcaAbatementEntity> findByLookupKey(final String lookUpKey) { + return testLookupAbatementEntities; + } + +} |