From ddb9b0f7e578aefd06ee9e3f01d810b0b9034f3a Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 18 May 2020 09:59:28 +0800 Subject: for policy update work Issue-ID: DCAEGEN2-2198 Signed-off-by: Kai Lu Change-Id: I8e1fec6f180ea3f44fa6df707048b5396b8d5a39 --- .../dcae/analytics/tca/web/controller/TcaRestControllerTest.java | 3 +-- .../analytics/tca/web/service/TcaProcessingServiceImplTest.java | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae') diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/controller/TcaRestControllerTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/controller/TcaRestControllerTest.java index 04146a3..001af0f 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/controller/TcaRestControllerTest.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/controller/TcaRestControllerTest.java @@ -54,9 +54,8 @@ public class TcaRestControllerTest { TcaProcessingService tcaProcessingService = Mockito.mock(TcaProcessingService.class); TcaExecutionContext tcaExecutionContext = Mockito.mock(TcaExecutionContext.class); List cefMessages = Arrays.asList("Test1", "Test2"); - TcaPolicy tcaPolicy = Mockito.mock(TcaPolicy.class); List executionContexts = Arrays.asList(tcaExecutionContext, tcaExecutionContext); - Mockito.when(tcaProcessingService.getTcaExecutionResults("requestId", "transactioId", tcaPolicy, cefMessages)) + Mockito.when(tcaProcessingService.getTcaExecutionResults("requestId", "transactioId", tcaPolicyWrapper, cefMessages)) .thenReturn(executionContexts); TcaRestController restcontroller = new TcaRestController(tcaProcessingService, tcaPolicyWrapper); restcontroller.execute(tcaExecutionRequest); 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 9347d53..5e9957e 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 @@ -25,12 +25,14 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import org.onap.dcae.analytics.tca.core.exception.AnalyticsParsingException; 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.model.policy.TcaPolicy; +import org.onap.dcae.analytics.tca.web.domain.TcaPolicyWrapper; import com.fasterxml.jackson.databind.ObjectMapper; @@ -53,10 +55,12 @@ class TcaProcessingServiceImplTest { 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" + @@ -373,7 +377,7 @@ class TcaProcessingServiceImplTest { ObjectMapper objectMapper = new ObjectMapper(); final List tcaExecutionResults = tcaProcessingService.getTcaExecutionResults( - "testRequestId", "testTransactionId", tcaPolicy, + "testRequestId", "testTransactionId", tcaPolicyWrapper, Arrays.asList(cefMessage, cefViolationMessage, cefAbatementMessage, cefInapplicableMessage)); -- cgit 1.2.3-korg