diff options
author | Kai <lukai@chinamobile.com> | 2020-02-05 13:09:23 +0800 |
---|---|---|
committer | LUKAI <lukai@chinamobile.com> | 2020-02-10 06:48:50 +0000 |
commit | a6b11ee264c2e3f4d20632b006f281025448507f (patch) | |
tree | 08c40aa1bc391adea25ee0cda0bd539ba15372d2 /dcae-analytics/dcae-analytics-tca-web/src | |
parent | 5cfa2de9371778236c1548a1961413d47abd4eb2 (diff) |
new config not reflected in TCA processing
Issue-ID: DCAEGEN2-2043
Signed-off-by: Kai Lu <lukai@chinamobile.com>
Change-Id: I9f757ce8931f725dd1c7c5398c0d40453d52e0d8
Diffstat (limited to 'dcae-analytics/dcae-analytics-tca-web/src')
10 files changed, 703 insertions, 100 deletions
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java index 9ee625a..63fd2f6 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java @@ -1,6 +1,6 @@ /* * ================================================================================ - * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2019-2020 China Mobile. 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. @@ -19,55 +19,49 @@ package org.onap.dcae.analytics.tca.web; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; +import org.onap.dcae.analytics.model.AnalyticsProfile; import org.onap.dcae.analytics.model.TcaModelConstants; import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties; import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants; -import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceModel; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; +import org.springframework.core.env.Environment; + +import lombok.Data; +import lombok.ToString; /** - * @author Rajiv Singla + * @author Kai Lu */ -@Data -@EqualsAndHashCode(callSuper = true) -@ConfigurationProperties(ConfigBindingServiceConstants.CONFIG_BINDING_SERVICE_PROPERTIES_KEY) -@Validated -public class TcaAppProperties extends BaseConfigBindingServiceProperties { - private static final long serialVersionUID = 1L; +public class TcaAppProperties extends BaseConfigBindingServiceProperties { - private Tca tca; + private final Environment environment; + public TcaAppProperties(final Environment environment) { + this.environment = environment; + } /** * TCA Application properties */ @Data - public static class Tca implements ConfigBindingServiceModel { - - private static final long serialVersionUID = 1L; - + public static class Tca { private String policy; private Integer processingBatchSize = TcaModelConstants.DEFAULT_TCA_PROCESSING_BATCH_SIZE; private Boolean enableAbatement = TcaModelConstants.DEFAULT_ABATEMENT_ENABLED; private Boolean enableEcompLogging = TcaModelConstants.DEFAULT_ECOMP_LOGGING_ENABLED; private Aai aai = new Aai(); - } - /** * A&AI properties */ @Data @ToString(exclude = "password") - public static class Aai implements ConfigBindingServiceModel { - - private static final long serialVersionUID = 1L; + public static class Aai { private Boolean enableEnrichment = TcaModelConstants.DEFAULT_AAI_ENRICHMENT_ENABLED; private String url; @@ -82,5 +76,73 @@ public class TcaAppProperties extends BaseConfigBindingServiceProperties { } + public Tca getTca() { + Tca tca = new Tca(); + tca.setPolicy(environment.getProperty(ConfigBindingServiceConstants.POLICY)); + tca.setProcessingBatchSize(environment.getProperty(ConfigBindingServiceConstants.PROCESSINGBATCHSIZE, Integer.class)); + tca.setEnableAbatement(environment.getProperty(ConfigBindingServiceConstants.ENABLEABATEMENT, Boolean.class)); + tca.setEnableEcompLogging(environment.getProperty(ConfigBindingServiceConstants.EnableEcompLogging, Boolean.class)); + + Aai aai = tca.getAai(); + aai.setEnableEnrichment(environment.getProperty(ConfigBindingServiceConstants.EnableEnrichment, Boolean.class)); + aai.setUrl(environment.getProperty(ConfigBindingServiceConstants.AAIURL)); + aai.setUsername(environment.getProperty(ConfigBindingServiceConstants.AAIUSERNAME)); + aai.setPassword(environment.getProperty(ConfigBindingServiceConstants.AAIPASSWORD)); + aai.setGenericVnfPath(ConfigBindingServiceConstants.AAIGENERICVNFPATH); + aai.setNodeQueryPath(environment.getProperty(ConfigBindingServiceConstants.AAINODEQUERYPATH)); + tca.setAai(aai); + + return tca; + } + + @Override + public Map<String, PublisherDetails> getStreamsPublishes() { + DmaapInfo dmaapInfo = new DmaapInfo(); + dmaapInfo.setTopicUrl(environment.getProperty(ConfigBindingServiceConstants.PUBTOPICURL)); + + PublisherDetails detail = new PublisherDetails(); + detail.setType(environment.getProperty(ConfigBindingServiceConstants.PUBTYPE)); + detail.setDmaapInfo(dmaapInfo); + streamsPublishes.put(ConfigBindingServiceConstants.PUBKEY, detail); + return streamsPublishes; + } + + @Override + public Map<String, SubscriberDetails> getStreamsSubscribes() { + DmaapInfo dmaapInfo = new DmaapInfo(); + dmaapInfo.setTopicUrl(environment.getProperty(ConfigBindingServiceConstants.SUBTOPICURL)); + + AutoAdjusting autoAdjust = new AutoAdjusting(); + autoAdjust.setStepUp(environment.getProperty(ConfigBindingServiceConstants.SUBAUTOADJUSTINGSTEPUP, Integer.class)); + autoAdjust.setStepDown(environment.getProperty(ConfigBindingServiceConstants.SUBAUTOADJUSTINGSTEPDOWN, Integer.class)); + autoAdjust.setMax(environment.getProperty(ConfigBindingServiceConstants.SUBAUTOADJUSTINGMAX, Integer.class)); + autoAdjust.setMin(environment.getProperty(ConfigBindingServiceConstants.SUBAUTOADJUSTINGMIN, Integer.class)); + + Polling poll = new Polling(); + poll.setAutoAdjusting(autoAdjust); + poll.setFixedRate(environment.getProperty(ConfigBindingServiceConstants.SUBFIXEDRATE, Integer.class)); + + SubscriberDetails detail = new SubscriberDetails(); + detail.setType(environment.getProperty(ConfigBindingServiceConstants.SUBTYPE)); + detail.setDmaapInfo(dmaapInfo); + detail.setPolling(poll); + + detail.setConsumerGroup(environment.getProperty(ConfigBindingServiceConstants.SUBCONSUMERGROUP)); + detail.setMessageLimit(environment.getProperty(ConfigBindingServiceConstants.SUBMESSAGELIMIT, Integer.class)); + detail.setTimeout(environment.getProperty(ConfigBindingServiceConstants.SUBTIMEOUT, Integer.class)); + List<String> consumerIds = new ArrayList<>(); + consumerIds.add(environment.getProperty(ConfigBindingServiceConstants.SUBCONSUMERIDS0)); + consumerIds.add(environment.getProperty(ConfigBindingServiceConstants.SUBCONSUMERIDS1)); + detail.setConsumerIds(consumerIds); + + streamsSubscribes.put(ConfigBindingServiceConstants.SUBKEY, detail); + return streamsSubscribes; + } -} + public boolean isConfigBindingServiceProfileActive() { + return Stream.of(environment.getActiveProfiles()) + .anyMatch(profile -> + profile.equalsIgnoreCase(AnalyticsProfile.CONFIG_BINDING_SERVICE_PROFILE_NAME)); + + } +}
\ No newline at end of file diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java index 64cb6eb..e330914 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java @@ -73,7 +73,6 @@ public class TcaMrConfig { return new TcaAlertTransformer(tcaAppProperties); } - @Bean public IntegrationFlow tcaMrFlow(final TcaPolicyWrapper tcaPolicyWrapper, final QueueChannel mrSubscriberOutputChannel, diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaWebConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaWebConfig.java index 7be20cc..a3ca7a8 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaWebConfig.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaWebConfig.java @@ -19,12 +19,6 @@ package org.onap.dcae.analytics.tca.web.config; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.util.stream.Stream; - -import org.onap.dcae.analytics.model.AnalyticsProfile; -import org.onap.dcae.analytics.model.common.ConfigSource; import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext; import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext; import org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion; @@ -34,23 +28,28 @@ import org.onap.dcae.analytics.tca.web.service.TcaProcessingService; import org.onap.dcae.analytics.tca.web.service.TcaProcessingServiceImpl; import org.onap.dcae.analytics.tca.web.validation.TcaAppPropertiesValidator; import org.onap.dcae.analytics.web.config.AnalyticsWebConfig; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.core.env.Environment; import org.springframework.validation.Validator; +import com.fasterxml.jackson.databind.ObjectMapper; + /** * @author Rajiv Singla */ @Configuration -@EnableConfigurationProperties(value = TcaAppProperties.class) @Import(value = {AnalyticsWebConfig.class, TcaMrConfig.class, TcaAaiConfig.class, TcaMongoAbatementConfig.class, TcaSimpleAbatementConfig.class, SwaggerConfig.class, ControllerConfig.class}) public class TcaWebConfig { @Bean + public TcaAppProperties tcaAppProperties(final Environment environment) { + return new TcaAppProperties(environment); + } + + @Bean public static Validator configurationPropertiesValidator() { return new TcaAppPropertiesValidator(); } @@ -61,18 +60,8 @@ public class TcaWebConfig { } @Bean - public TcaPolicyWrapper tcaPolicyWrapper(final TcaAppProperties tcaAppProperties, - final Environment environment) { - final String policy = tcaAppProperties.getTca().getPolicy(); - final boolean isConfigBindingServiceProfileActive = - Stream.of(environment.getActiveProfiles()) - .anyMatch(profile -> - profile.equalsIgnoreCase(AnalyticsProfile.CONFIG_BINDING_SERVICE_PROFILE_NAME)); - if (isConfigBindingServiceProfileActive) { - return new TcaPolicyWrapper(policy, ConfigSource.CONFIG_BINDING_SERVICE); - } else { - return new TcaPolicyWrapper(policy, ConfigSource.CLASSPATH); - } + public TcaPolicyWrapper tcaPolicyWrapper(final TcaAppProperties tcaAppProperties) { + return new TcaPolicyWrapper(tcaAppProperties); } @Bean diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java index e85932a..c54d27c 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java @@ -21,78 +21,96 @@ package org.onap.dcae.analytics.tca.web.domain; import static org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion.TCA_POLICY_JSON_FUNCTION; -import lombok.Getter; -import lombok.ToString; - import java.time.ZonedDateTime; import java.util.concurrent.atomic.AtomicInteger; import org.onap.dcae.analytics.model.common.ConfigSource; import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; import org.onap.dcae.analytics.tca.model.policy.TcaPolicyModel; -import org.onap.dcae.analytics.tca.web.validation.TcaPolicyValidator; +import org.onap.dcae.analytics.tca.web.TcaAppProperties; import org.onap.dcae.analytics.web.exception.AnalyticsParsingException; -import org.onap.dcae.analytics.web.util.ValidationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author Rajiv Singla */ -@Getter -@ToString public class TcaPolicyWrapper implements TcaPolicyModel { - private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory.getLogger(TcaPolicyWrapper.class); private final ZonedDateTime creationTime; private ZonedDateTime updateDateTime; - private TcaPolicy tcaPolicy; + private String tcaPolicy; private ConfigSource configSource; private AtomicInteger policyUpdateSequence; private String policyVersion; - public TcaPolicyWrapper(final String tcaPolicyString, final ConfigSource configSource) { - createOrUpdatePolicy(getTcaPolicy(tcaPolicyString), configSource); - this.creationTime = ZonedDateTime.now(); - } + private final TcaAppProperties tcaAppProperties; - public void setTcaPolicy(final String tcaPolicyString, final ConfigSource configSource) { - createOrUpdatePolicy(getTcaPolicy(tcaPolicyString), configSource); - } - - public void setTcaPolicy(final TcaPolicy tcaPolicy, final ConfigSource configSource) { - createOrUpdatePolicy(tcaPolicy, configSource); + public TcaPolicyWrapper(final TcaAppProperties tcaAppProperties) { + this.tcaAppProperties = tcaAppProperties; + this.creationTime = ZonedDateTime.now(); + this.tcaPolicy = tcaAppProperties.getTca().getPolicy(); + policyUpdateSequence = new AtomicInteger(0); + this.updateDateTime = ZonedDateTime.now(); + this.policyVersion = getPolicyVersion(new AtomicInteger(0)); } - private void createOrUpdatePolicy(final TcaPolicy tcaPolicy, final ConfigSource configSource) { - ValidationUtils.validate(tcaPolicy, new TcaPolicyValidator()); - this.tcaPolicy = tcaPolicy; - this.configSource = configSource; - this.updateDateTime = ZonedDateTime.now(); - if (policyUpdateSequence == null) { - policyUpdateSequence = new AtomicInteger(0); + public TcaPolicy getTcaPolicy() { + String tcaPolicyString = tcaAppProperties.getTca().getPolicy(); + boolean isConfigBindingServiceProfileActive = tcaAppProperties.isConfigBindingServiceProfileActive(); + if (isConfigBindingServiceProfileActive) { + this.configSource = ConfigSource.CONFIG_BINDING_SERVICE; } else { + this.configSource = ConfigSource.CLASSPATH; + } + + if (!tcaPolicyString.equals(tcaPolicy)) { + this.tcaPolicy = tcaPolicyString; + this.updateDateTime = ZonedDateTime.now(); policyUpdateSequence.getAndUpdate(sequence -> sequence + 1); + this.policyVersion = getPolicyVersion(policyUpdateSequence); + logger.info("Updated Tca Policy Wrapper with policy: {}, from Source: {}, policy Version: {}", + tcaPolicy, configSource.name(), policyVersion); } - this.policyVersion = getPolicyVersion(policyUpdateSequence); - final String configSourceName = configSource.name(); - logger.info("Updated Tca Policy Wrapper with policy: {}, from Source: {}, policy Version: {}", - tcaPolicy, configSourceName, policyVersion); + + return convertTcaPolicy(tcaPolicyString); } + public void setTcaPolicy(TcaPolicy tcaPolicy, ConfigSource configSource) { + this.tcaPolicy = tcaPolicy.toString(); + this.configSource = configSource; + } - private TcaPolicy getTcaPolicy(final String tcaPolicyString) { + public TcaPolicy convertTcaPolicy(String tcaPolicyString) { return TCA_POLICY_JSON_FUNCTION.apply(tcaPolicyString).orElseThrow( () -> new AnalyticsParsingException("Unable to parse Tca Policy String: " + tcaPolicyString, new IllegalArgumentException())); } - private static String getPolicyVersion(final AtomicInteger policyUpdateSequence) { return "version-" + policyUpdateSequence.intValue(); } + public ZonedDateTime getCreationTime() { + return creationTime; + } + + public ZonedDateTime getUpdateDateTime() { + return updateDateTime; + } + + public ConfigSource getConfigSource() { + return configSource; + } + + public AtomicInteger getPolicyUpdateSequence() { + return policyUpdateSequence; + } + + public String getPolicyVersion() { + return policyVersion; + } + } 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; + } + +} |