diff options
author | an4828 <nekrassov@att.com> | 2018-01-22 17:17:34 -0500 |
---|---|---|
committer | an4828 <nekrassov@att.com> | 2018-01-22 17:20:00 -0500 |
commit | c489a2eb22484e798c39a978bc8b61821b92322f (patch) | |
tree | 5aafe90efc15f8ced47e0d14c5f23a86a07f03e1 /dcae-analytics-common/src/test | |
parent | baaecfc19132034168beb64a0c1e7813c7c17c4a (diff) |
TCA: Replace any openecomp reference by onap
Change-Id: I7c6d812ab5c1d7b30c63653d1974b0b1abc099be
Signed-off-by: an4828 <nekrassov@att.com>
Issue-ID: DCAEGEN2-224
Signed-off-by: an4828 <nekrassov@att.com>
Diffstat (limited to 'dcae-analytics-common/src/test')
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java) | 162 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/filter/GenericJsonMessageFilterTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/filter/GenericJsonMessageFilterTest.java) | 302 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/AbstractMessageProcessorTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractMessageProcessorTest.java) | 136 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/AbstractProcessorContextTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractProcessorContextTest.java) | 158 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java) | 192 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/GenericProcessorInfoTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericProcessorInfoTest.java) | 106 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java) | 78 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java) | 82 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java) | 82 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestProcessorContext.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestProcessorContext.java) | 168 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/utils/HTTPUtilsTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/utils/HTTPUtilsTest.java) | 96 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/utils/MessageProcessorUtilsTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/utils/MessageProcessorUtilsTest.java) | 124 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/utils/PersistenceUtilsTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/utils/PersistenceUtilsTest.java) | 80 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/validation/GenericValidationResponseTest.java (renamed from dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/validation/GenericValidationResponseTest.java) | 258 | ||||
-rw-r--r-- | dcae-analytics-common/src/test/resources/logback-test.xml | 110 |
15 files changed, 1067 insertions, 1067 deletions
diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java index fd28624..e30e0af 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java @@ -1,81 +1,81 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Suppliers;
-import org.junit.BeforeClass;
-import org.openecomp.dcae.apod.analytics.common.service.processor.TestEarlyTerminatingProcessor;
-import org.openecomp.dcae.apod.analytics.common.service.processor.TestMessageProcessor1;
-import org.openecomp.dcae.apod.analytics.common.service.processor.TestMessageProcessor2;
-import org.openecomp.dcae.apod.analytics.model.util.json.AnalyticsModelObjectMapperSupplier;
-import org.openecomp.dcae.apod.analytics.test.BaseDCAEAnalyticsUnitTest;
-
-/**
- * Base class from all DCEA Analytics Common Module Unit Tests
- * <p>
- * @author Rajiv Singla . Creation Date: 10/6/2016.
- */
-public abstract class BaseAnalyticsCommonUnitTest extends BaseDCAEAnalyticsUnitTest {
-
-
- protected static final String TEST_MESSAGE_PROCESSOR_MESSAGE = "Test Processor Message";
-
- protected static final String CEF_MESSAGE_FILE_PATH = "data/json/cef/cef_message.json";
-
- protected static ObjectMapper objectMapper;
-
- /**
- * Before running test cases need to assign object mapper.
- */
- @BeforeClass
- public static void beforeClass() {
- final AnalyticsModelObjectMapperSupplier analyticsModelObjectMapperSupplier =
- new AnalyticsModelObjectMapperSupplier();
- objectMapper = Suppliers.memoize(analyticsModelObjectMapperSupplier).get();
- }
-
- /*
- * Test implementation for {@link CDAPAppSettings}
- */
- protected class CDAPTestAppSettings {
-
- private String settingsField;
-
- public String getSettingsField() {
- return settingsField;
- }
-
- public void setSettingsField(String settingsField) {
- this.settingsField = settingsField;
- }
- }
-
- protected TestMessageProcessor1 getTestMessageProcessor1() {
- return new TestMessageProcessor1();
- }
- protected TestMessageProcessor2 getTestMessageProcessor2() {
- return new TestMessageProcessor2();
- }
- protected TestEarlyTerminatingProcessor getTestEarlyTerminationProcessor() {
- return new TestEarlyTerminatingProcessor();
- }
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Suppliers; +import org.junit.BeforeClass; +import org.onap.dcae.apod.analytics.common.service.processor.TestEarlyTerminatingProcessor; +import org.onap.dcae.apod.analytics.common.service.processor.TestMessageProcessor1; +import org.onap.dcae.apod.analytics.common.service.processor.TestMessageProcessor2; +import org.onap.dcae.apod.analytics.model.util.json.AnalyticsModelObjectMapperSupplier; +import org.onap.dcae.apod.analytics.test.BaseDCAEAnalyticsUnitTest; + +/** + * Base class from all DCEA Analytics Common Module Unit Tests + * <p> + * @author Rajiv Singla . Creation Date: 10/6/2016. + */ +public abstract class BaseAnalyticsCommonUnitTest extends BaseDCAEAnalyticsUnitTest { + + + protected static final String TEST_MESSAGE_PROCESSOR_MESSAGE = "Test Processor Message"; + + protected static final String CEF_MESSAGE_FILE_PATH = "data/json/cef/cef_message.json"; + + protected static ObjectMapper objectMapper; + + /** + * Before running test cases need to assign object mapper. + */ + @BeforeClass + public static void beforeClass() { + final AnalyticsModelObjectMapperSupplier analyticsModelObjectMapperSupplier = + new AnalyticsModelObjectMapperSupplier(); + objectMapper = Suppliers.memoize(analyticsModelObjectMapperSupplier).get(); + } + + /* + * Test implementation for {@link CDAPAppSettings} + */ + protected class CDAPTestAppSettings { + + private String settingsField; + + public String getSettingsField() { + return settingsField; + } + + public void setSettingsField(String settingsField) { + this.settingsField = settingsField; + } + } + + protected TestMessageProcessor1 getTestMessageProcessor1() { + return new TestMessageProcessor1(); + } + protected TestMessageProcessor2 getTestMessageProcessor2() { + return new TestMessageProcessor2(); + } + protected TestEarlyTerminatingProcessor getTestEarlyTerminationProcessor() { + return new TestEarlyTerminatingProcessor(); + } +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/filter/GenericJsonMessageFilterTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/filter/GenericJsonMessageFilterTest.java index 918407a..bca3730 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/filter/GenericJsonMessageFilterTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/filter/GenericJsonMessageFilterTest.java @@ -1,151 +1,151 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.service.filter;
-
-import com.google.common.collect.ImmutableList;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
-import org.openecomp.dcae.apod.analytics.common.service.processor.GenericMessageChainProcessor;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Rajiv Singla . Creation Date: 2/10/2017.
- */
-public class GenericJsonMessageFilterTest extends BaseAnalyticsCommonUnitTest {
-
- private String jsonMessage;
-
- @Before
- public void before() throws Exception {
- jsonMessage = fromStream(CEF_MESSAGE_FILE_PATH);
-
- }
-
- @Test
- public void testJsonMessageFilterWhenAllFiltersPassed() throws Exception {
-
- final JsonMessageFilterProcessorContext finalMessageProcessorContext =
- processJsonMessageFilterChain(jsonMessage,
- "domainFilter", "$.event.commonEventHeader.domain", "measurementsForVfScaling",
- "eventNameFilter", "$.event.commonEventHeader.eventName", "Mfvs_eNodeB_RANKPI");
-
- assertJsonMessageAssertions(jsonMessage, finalMessageProcessorContext, true, true, 2);
-
- }
-
- @Test
- public void testJsonMessageFilterWhenJsonPathValueIsANumber() throws Exception {
-
- final JsonMessageFilterProcessorContext finalMessageProcessorContext =
- processJsonMessageFilterChain(jsonMessage,
- "domainFilter", "$.event.commonEventHeader.sequence", "0",
- "eventNameFilter", "$.event.commonEventHeader.eventName", "Mfvs_eNodeB_RANKPI");
-
- assertJsonMessageAssertions(jsonMessage, finalMessageProcessorContext, true, true, 2);
- }
-
- @Test
- public void testJsonMessageFilterWhenOneFilterDoesNotMatch() throws Exception {
-
- final JsonMessageFilterProcessorContext finalMessageProcessorContext =
- processJsonMessageFilterChain(jsonMessage,
- "domainFilter", "$.event.commonEventHeader.domain", "xxxxxxxxxxx",
- "functionalRoleFilter", "$.event.commonEventHeader.eventName", "vFirewall");
-
- assertJsonMessageAssertions(jsonMessage, finalMessageProcessorContext, false, false, 1);
- }
-
- @Test
- public void testJsonMessageFilterWhenJsonPathDoesNotExist() throws Exception {
-
- final JsonMessageFilterProcessorContext finalMessageProcessorContext =
- processJsonMessageFilterChain(jsonMessage,
- "domainFilter", "$.event.commonEventHeader.xxxxxxx", "measurementsForVfScaling",
- "functionalRoleFilter", "$.event.commonEventHeader.eventName", "vFirewall");
-
- assertJsonMessageAssertions(jsonMessage, finalMessageProcessorContext, false, false, 1);
- }
-
- @Test
- public void testJsonMessageFilterWhenIncomingMessageIsBlank() throws Exception {
-
- final JsonMessageFilterProcessorContext finalMessageProcessorContext =
- processJsonMessageFilterChain("",
- "domainFilter", "$.event.commonEventHeader.domain", "measurementsForVfScaling",
- "functionalRoleFilter", "$.event.commonEventHeader.eventName", "vFirewall");
-
- assertJsonMessageAssertions("", finalMessageProcessorContext, false, null, 1);
-
- }
-
- @Test
- public void testJsonMessageFilterWhenIncomingMessageIsNotValidJson() throws Exception {
-
- final JsonMessageFilterProcessorContext finalMessageProcessorContext =
- processJsonMessageFilterChain("invalidJson",
- "domainFilter", "$.event.commonEventHeader.domain", "measurementsForVfScaling",
- "functionalRoleFilter", "$.event.commonEventHeader.eventName", "vFirewall");
-
- assertJsonMessageAssertions("invalidJson", finalMessageProcessorContext, false, null, 1);
-
- }
-
-
- private static void assertJsonMessageAssertions(
- final String jsonMessage, final JsonMessageFilterProcessorContext finalMessageProcessorContext,
- final Boolean canProcessingContinueFlag, final Boolean matchedFlag,
- final int messageProcessorCount) throws Exception {
-
- assertJson(jsonMessage, finalMessageProcessorContext.getMessage());
- Assert.assertEquals(canProcessingContinueFlag, finalMessageProcessorContext.canProcessingContinue());
- assertEquals(matchedFlag, finalMessageProcessorContext.getMatched());
- Assert.assertEquals(finalMessageProcessorContext.getMessageProcessors().size(), messageProcessorCount);
-
- }
-
-
- private static JsonMessageFilterProcessorContext processJsonMessageFilterChain(
- final String jsonMessage,
- final String firstFilterName, final String firstFilterPath, final String firstFilterValue,
- final String secondFilterName, final String secondFilterPath, final String secondFilterValue) {
-
- // create processors
- final GenericJsonMessageFilter firstFilter = new GenericJsonMessageFilter(firstFilterName, firstFilterPath,
- firstFilterValue);
- final GenericJsonMessageFilter secondFilter = new GenericJsonMessageFilter(secondFilterName,
- secondFilterPath, secondFilterValue);
-
- // create initial processor context containing the json message that need to be processed
- final JsonMessageFilterProcessorContext initialProcessorContext =
- new JsonMessageFilterProcessorContext(jsonMessage);
-
- // create a generic message chain processor and feed it list of processors and initialProcessor context
- final GenericMessageChainProcessor<JsonMessageFilterProcessorContext> messageChainProcessor =
- new GenericMessageChainProcessor<>(ImmutableList.of(firstFilter, secondFilter),
- initialProcessorContext);
-
- // process the generic message chain
- return messageChainProcessor.processChain();
- }
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.service.filter; + +import com.google.common.collect.ImmutableList; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; +import org.onap.dcae.apod.analytics.common.service.processor.GenericMessageChainProcessor; + +import static org.junit.Assert.assertEquals; + +/** + * @author Rajiv Singla . Creation Date: 2/10/2017. + */ +public class GenericJsonMessageFilterTest extends BaseAnalyticsCommonUnitTest { + + private String jsonMessage; + + @Before + public void before() throws Exception { + jsonMessage = fromStream(CEF_MESSAGE_FILE_PATH); + + } + + @Test + public void testJsonMessageFilterWhenAllFiltersPassed() throws Exception { + + final JsonMessageFilterProcessorContext finalMessageProcessorContext = + processJsonMessageFilterChain(jsonMessage, + "domainFilter", "$.event.commonEventHeader.domain", "measurementsForVfScaling", + "eventNameFilter", "$.event.commonEventHeader.eventName", "Mfvs_eNodeB_RANKPI"); + + assertJsonMessageAssertions(jsonMessage, finalMessageProcessorContext, true, true, 2); + + } + + @Test + public void testJsonMessageFilterWhenJsonPathValueIsANumber() throws Exception { + + final JsonMessageFilterProcessorContext finalMessageProcessorContext = + processJsonMessageFilterChain(jsonMessage, + "domainFilter", "$.event.commonEventHeader.sequence", "0", + "eventNameFilter", "$.event.commonEventHeader.eventName", "Mfvs_eNodeB_RANKPI"); + + assertJsonMessageAssertions(jsonMessage, finalMessageProcessorContext, true, true, 2); + } + + @Test + public void testJsonMessageFilterWhenOneFilterDoesNotMatch() throws Exception { + + final JsonMessageFilterProcessorContext finalMessageProcessorContext = + processJsonMessageFilterChain(jsonMessage, + "domainFilter", "$.event.commonEventHeader.domain", "xxxxxxxxxxx", + "functionalRoleFilter", "$.event.commonEventHeader.eventName", "vFirewall"); + + assertJsonMessageAssertions(jsonMessage, finalMessageProcessorContext, false, false, 1); + } + + @Test + public void testJsonMessageFilterWhenJsonPathDoesNotExist() throws Exception { + + final JsonMessageFilterProcessorContext finalMessageProcessorContext = + processJsonMessageFilterChain(jsonMessage, + "domainFilter", "$.event.commonEventHeader.xxxxxxx", "measurementsForVfScaling", + "functionalRoleFilter", "$.event.commonEventHeader.eventName", "vFirewall"); + + assertJsonMessageAssertions(jsonMessage, finalMessageProcessorContext, false, false, 1); + } + + @Test + public void testJsonMessageFilterWhenIncomingMessageIsBlank() throws Exception { + + final JsonMessageFilterProcessorContext finalMessageProcessorContext = + processJsonMessageFilterChain("", + "domainFilter", "$.event.commonEventHeader.domain", "measurementsForVfScaling", + "functionalRoleFilter", "$.event.commonEventHeader.eventName", "vFirewall"); + + assertJsonMessageAssertions("", finalMessageProcessorContext, false, null, 1); + + } + + @Test + public void testJsonMessageFilterWhenIncomingMessageIsNotValidJson() throws Exception { + + final JsonMessageFilterProcessorContext finalMessageProcessorContext = + processJsonMessageFilterChain("invalidJson", + "domainFilter", "$.event.commonEventHeader.domain", "measurementsForVfScaling", + "functionalRoleFilter", "$.event.commonEventHeader.eventName", "vFirewall"); + + assertJsonMessageAssertions("invalidJson", finalMessageProcessorContext, false, null, 1); + + } + + + private static void assertJsonMessageAssertions( + final String jsonMessage, final JsonMessageFilterProcessorContext finalMessageProcessorContext, + final Boolean canProcessingContinueFlag, final Boolean matchedFlag, + final int messageProcessorCount) throws Exception { + + assertJson(jsonMessage, finalMessageProcessorContext.getMessage()); + Assert.assertEquals(canProcessingContinueFlag, finalMessageProcessorContext.canProcessingContinue()); + assertEquals(matchedFlag, finalMessageProcessorContext.getMatched()); + Assert.assertEquals(finalMessageProcessorContext.getMessageProcessors().size(), messageProcessorCount); + + } + + + private static JsonMessageFilterProcessorContext processJsonMessageFilterChain( + final String jsonMessage, + final String firstFilterName, final String firstFilterPath, final String firstFilterValue, + final String secondFilterName, final String secondFilterPath, final String secondFilterValue) { + + // create processors + final GenericJsonMessageFilter firstFilter = new GenericJsonMessageFilter(firstFilterName, firstFilterPath, + firstFilterValue); + final GenericJsonMessageFilter secondFilter = new GenericJsonMessageFilter(secondFilterName, + secondFilterPath, secondFilterValue); + + // create initial processor context containing the json message that need to be processed + final JsonMessageFilterProcessorContext initialProcessorContext = + new JsonMessageFilterProcessorContext(jsonMessage); + + // create a generic message chain processor and feed it list of processors and initialProcessor context + final GenericMessageChainProcessor<JsonMessageFilterProcessorContext> messageChainProcessor = + new GenericMessageChainProcessor<>(ImmutableList.of(firstFilter, secondFilter), + initialProcessorContext); + + // process the generic message chain + return messageChainProcessor.processChain(); + } +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractMessageProcessorTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/AbstractMessageProcessorTest.java index 5445150..ea7b2d6 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractMessageProcessorTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/AbstractMessageProcessorTest.java @@ -1,68 +1,68 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.service.processor;
-
-import org.junit.Test;
-import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
-import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Rajiv Singla . Creation Date: 12/12/2016.
- */
-public class AbstractMessageProcessorTest extends BaseAnalyticsCommonUnitTest {
-
-
- @Test
- public void testPreProcessorWhenProcessingContextFlagIsTrue() throws Exception {
- TestMessageProcessor1 messageProcessor1 = new TestMessageProcessor1();
- final TestProcessorContext processorContext =
- new TestProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);
- final TestProcessorContext testProcessorContext = messageProcessor1.preProcessor(processorContext);
- assertThat("Processing flag must be true",
- testProcessorContext.canProcessingContinue(), is(true));
- }
-
- @Test(expected = MessageProcessingException.class)
- public void testPreProcessorWhenProcessingContextFlagIsFalse() throws Exception {
- TestMessageProcessor1 messageProcessor1 = new TestMessageProcessor1();
- final TestProcessorContext testProcessorContext =
- new TestProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, false);
- messageProcessor1.preProcessor(testProcessorContext);
- }
-
- @Test
- public void testPostProcessorWhenProcessingStateIsNotFinishedSuccessfully() throws Exception {
- TestMessageProcessor1 messageProcessor1 = new TestMessageProcessor1();
- final ProcessingState processingState = messageProcessor1.getProcessingState();
- assertTrue("Processing state is not processing finished successfully",
- processingState != ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY);
- final TestProcessorContext processorContext =
- new TestProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);
- final TestProcessorContext testProcessorContext = messageProcessor1.postProcessor(processorContext);
- assertThat("Processing flag must be false",
- testProcessorContext.canProcessingContinue(), is(false));
- }
-
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.service.processor; + +import org.junit.Test; +import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; +import org.onap.dcae.apod.analytics.common.exception.MessageProcessingException; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +/** + * @author Rajiv Singla . Creation Date: 12/12/2016. + */ +public class AbstractMessageProcessorTest extends BaseAnalyticsCommonUnitTest { + + + @Test + public void testPreProcessorWhenProcessingContextFlagIsTrue() throws Exception { + TestMessageProcessor1 messageProcessor1 = new TestMessageProcessor1(); + final TestProcessorContext processorContext = + new TestProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true); + final TestProcessorContext testProcessorContext = messageProcessor1.preProcessor(processorContext); + assertThat("Processing flag must be true", + testProcessorContext.canProcessingContinue(), is(true)); + } + + @Test(expected = MessageProcessingException.class) + public void testPreProcessorWhenProcessingContextFlagIsFalse() throws Exception { + TestMessageProcessor1 messageProcessor1 = new TestMessageProcessor1(); + final TestProcessorContext testProcessorContext = + new TestProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, false); + messageProcessor1.preProcessor(testProcessorContext); + } + + @Test + public void testPostProcessorWhenProcessingStateIsNotFinishedSuccessfully() throws Exception { + TestMessageProcessor1 messageProcessor1 = new TestMessageProcessor1(); + final ProcessingState processingState = messageProcessor1.getProcessingState(); + assertTrue("Processing state is not processing finished successfully", + processingState != ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY); + final TestProcessorContext processorContext = + new TestProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true); + final TestProcessorContext testProcessorContext = messageProcessor1.postProcessor(processorContext); + assertThat("Processing flag must be false", + testProcessorContext.canProcessingContinue(), is(false)); + } + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractProcessorContextTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/AbstractProcessorContextTest.java index b65a4f2..2710b75 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractProcessorContextTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/AbstractProcessorContextTest.java @@ -1,79 +1,79 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.service.processor;
-
-import org.junit.Test;
-import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * @author Rajiv Singla . Creation Date: 12/12/2016.
- */
-public class AbstractProcessorContextTest extends BaseAnalyticsCommonUnitTest {
-
- class TestAbstractMessageProcessorContext extends AbstractProcessorContext {
-
- public TestAbstractMessageProcessorContext(String message, boolean canProcessingContinue) {
- super(message, canProcessingContinue);
- }
- }
-
-
- @Test
- public void testGetMessage() throws Exception {
- TestAbstractMessageProcessorContext testProcessorContext =
- new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);
- final String message = testProcessorContext.getMessage();
- assertThat("Message Processor message must match", message, is(TEST_MESSAGE_PROCESSOR_MESSAGE));
- }
-
- @Test
- public void testCanProcessingContinue() throws Exception {
- TestAbstractMessageProcessorContext testProcessorContext =
- new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);
- final boolean canProcessingContinue = testProcessorContext.canProcessingContinue();
- assertThat("Message Can Processing flag must be true", canProcessingContinue, is(true));
- }
-
- @Test
- public void testSetProcessingContinueFlag() throws Exception {
- TestAbstractMessageProcessorContext testProcessorContext =
- new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);
- testProcessorContext.setProcessingContinueFlag(false);
- assertThat("Message Can processing flag must be false",
- testProcessorContext.canProcessingContinue(), is(false));
-
- }
-
- @Test
- public void testGetMessageProcessors() throws Exception {
- TestAbstractMessageProcessorContext testProcessorContext =
- new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);
- final List<? super MessageProcessor<? extends ProcessorContext>> messageProcessors =
- testProcessorContext.getMessageProcessors();
- assertThat("Message processor processing message must match", messageProcessors.size(), is(0));
- }
-
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.service.processor; + +import org.junit.Test; +import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; + +import java.util.List; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +/** + * @author Rajiv Singla . Creation Date: 12/12/2016. + */ +public class AbstractProcessorContextTest extends BaseAnalyticsCommonUnitTest { + + class TestAbstractMessageProcessorContext extends AbstractProcessorContext { + + public TestAbstractMessageProcessorContext(String message, boolean canProcessingContinue) { + super(message, canProcessingContinue); + } + } + + + @Test + public void testGetMessage() throws Exception { + TestAbstractMessageProcessorContext testProcessorContext = + new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true); + final String message = testProcessorContext.getMessage(); + assertThat("Message Processor message must match", message, is(TEST_MESSAGE_PROCESSOR_MESSAGE)); + } + + @Test + public void testCanProcessingContinue() throws Exception { + TestAbstractMessageProcessorContext testProcessorContext = + new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true); + final boolean canProcessingContinue = testProcessorContext.canProcessingContinue(); + assertThat("Message Can Processing flag must be true", canProcessingContinue, is(true)); + } + + @Test + public void testSetProcessingContinueFlag() throws Exception { + TestAbstractMessageProcessorContext testProcessorContext = + new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true); + testProcessorContext.setProcessingContinueFlag(false); + assertThat("Message Can processing flag must be false", + testProcessorContext.canProcessingContinue(), is(false)); + + } + + @Test + public void testGetMessageProcessors() throws Exception { + TestAbstractMessageProcessorContext testProcessorContext = + new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true); + final List<? super MessageProcessor<? extends ProcessorContext>> messageProcessors = + testProcessorContext.getMessageProcessors(); + assertThat("Message processor processing message must match", messageProcessors.size(), is(0)); + } + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java index afb3ed2..3a466c2 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java @@ -1,96 +1,96 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.service.processor;
-
-import com.google.common.collect.ImmutableList;
-import org.junit.Test;
-import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
-import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
-
-/**
- *
- * @author Rajiv Singla . Creation Date: 11/8/2016.
- */
-public class GenericMessageChainProcessorTest extends BaseAnalyticsCommonUnitTest {
-
-
- @Test
- public void testProcessChainWhenProcessChainHasNoEarlyTermination() throws Exception {
-
- final TestMessageProcessor1 testMessageProcessor1 = getTestMessageProcessor1();
- final TestMessageProcessor2 testMessageProcessor2 = getTestMessageProcessor2();
- final ImmutableList<? extends MessageProcessor<TestProcessorContext>> testMessageChain =
- ImmutableList.of(testMessageProcessor1, testMessageProcessor2);
-
- final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true);
-
- final GenericMessageChainProcessor<TestProcessorContext> genericMessageChainProcessor =
- new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext);
-
- final TestProcessorContext finalProcessorContext = genericMessageChainProcessor.processChain();
-
- final String result = finalProcessorContext.getResult();
- assertThat("Final Result must be Hello World! Again", result, is("Hello World! Again"));
- assertThat("TestProcessor1 state is correct", testMessageProcessor1.getProcessingState(),
- is(ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY));
- assertThat("TestProcessor2 state is correct", testMessageProcessor2.getProcessingState(),
- is(ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY));
- }
-
-
- @Test
- public void testProcessChainWhenProcessChainEarlyTermination() throws Exception {
-
- final TestEarlyTerminatingProcessor testEarlyTerminatingProcessor = getTestEarlyTerminationProcessor();
- final ImmutableList<? extends MessageProcessor<TestProcessorContext>> testMessageChain =
- ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2());
- final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true);
-
- final GenericMessageChainProcessor<TestProcessorContext> genericMessageChainProcessor =
- new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext);
-
- final TestProcessorContext finalProcessorContext = genericMessageChainProcessor.processChain();
- final String result = finalProcessorContext.getResult();
- assertNull("Final Result must be null", result);
- assertThat("TestEarlyTerminatingProcessor state is correct",
- testEarlyTerminatingProcessor.getProcessingState(), is(ProcessingState.PROCESSING_TERMINATED_EARLY));
- }
-
- @Test(expected = MessageProcessingException.class)
- public void testProcessChainWhenIncomingMessageContextIsNull() throws Exception {
-
- final TestEarlyTerminatingProcessor testEarlyTerminatingProcessor = getTestEarlyTerminationProcessor();
- final ImmutableList<? extends MessageProcessor<TestProcessorContext>> testMessageChain =
- ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2());
- final TestProcessorContext testProcessorContext = null;
-
- final GenericMessageChainProcessor<TestProcessorContext> genericMessageChainProcessor =
- new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext);
-
- genericMessageChainProcessor.processChain();
- }
-
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.service.processor; + +import com.google.common.collect.ImmutableList; +import org.junit.Test; +import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; +import org.onap.dcae.apod.analytics.common.exception.MessageProcessingException; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; + + +/** + * + * @author Rajiv Singla . Creation Date: 11/8/2016. + */ +public class GenericMessageChainProcessorTest extends BaseAnalyticsCommonUnitTest { + + + @Test + public void testProcessChainWhenProcessChainHasNoEarlyTermination() throws Exception { + + final TestMessageProcessor1 testMessageProcessor1 = getTestMessageProcessor1(); + final TestMessageProcessor2 testMessageProcessor2 = getTestMessageProcessor2(); + final ImmutableList<? extends MessageProcessor<TestProcessorContext>> testMessageChain = + ImmutableList.of(testMessageProcessor1, testMessageProcessor2); + + final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true); + + final GenericMessageChainProcessor<TestProcessorContext> genericMessageChainProcessor = + new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext); + + final TestProcessorContext finalProcessorContext = genericMessageChainProcessor.processChain(); + + final String result = finalProcessorContext.getResult(); + assertThat("Final Result must be Hello World! Again", result, is("Hello World! Again")); + assertThat("TestProcessor1 state is correct", testMessageProcessor1.getProcessingState(), + is(ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY)); + assertThat("TestProcessor2 state is correct", testMessageProcessor2.getProcessingState(), + is(ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY)); + } + + + @Test + public void testProcessChainWhenProcessChainEarlyTermination() throws Exception { + + final TestEarlyTerminatingProcessor testEarlyTerminatingProcessor = getTestEarlyTerminationProcessor(); + final ImmutableList<? extends MessageProcessor<TestProcessorContext>> testMessageChain = + ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2()); + final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true); + + final GenericMessageChainProcessor<TestProcessorContext> genericMessageChainProcessor = + new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext); + + final TestProcessorContext finalProcessorContext = genericMessageChainProcessor.processChain(); + final String result = finalProcessorContext.getResult(); + assertNull("Final Result must be null", result); + assertThat("TestEarlyTerminatingProcessor state is correct", + testEarlyTerminatingProcessor.getProcessingState(), is(ProcessingState.PROCESSING_TERMINATED_EARLY)); + } + + @Test(expected = MessageProcessingException.class) + public void testProcessChainWhenIncomingMessageContextIsNull() throws Exception { + + final TestEarlyTerminatingProcessor testEarlyTerminatingProcessor = getTestEarlyTerminationProcessor(); + final ImmutableList<? extends MessageProcessor<TestProcessorContext>> testMessageChain = + ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2()); + final TestProcessorContext testProcessorContext = null; + + final GenericMessageChainProcessor<TestProcessorContext> genericMessageChainProcessor = + new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext); + + genericMessageChainProcessor.processChain(); + } + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericProcessorInfoTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/GenericProcessorInfoTest.java index eb7bae3..f0bc30e 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericProcessorInfoTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/GenericProcessorInfoTest.java @@ -1,53 +1,53 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.service.processor;
-
-import org.junit.Test;
-import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * @author Rajiv Singla . Creation Date: 12/12/2016.
- */
-public class GenericProcessorInfoTest extends BaseAnalyticsCommonUnitTest {
-
-
- @Test
- public void getProcessorName() throws Exception {
- final String processorName = "testProcessorName";
- final String processorDescription = "testProcessorDescription";
- GenericProcessorInfo genericProcessorInfo = new GenericProcessorInfo(processorName, processorDescription);
- assertThat("Processor Name must match", genericProcessorInfo.getProcessorName(), is(processorName));
-
- }
-
- @Test
- public void getProcessorDescription() throws Exception {
- final String processorName = "testProcessorName";
- final String processorDescription = "testProcessorDescription";
- GenericProcessorInfo genericProcessorInfo = new GenericProcessorInfo(processorName, processorDescription);
- assertThat("Processor Description must match", genericProcessorInfo.getProcessorDescription(),
- is(processorDescription));
- }
-
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.service.processor; + +import org.junit.Test; +import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +/** + * @author Rajiv Singla . Creation Date: 12/12/2016. + */ +public class GenericProcessorInfoTest extends BaseAnalyticsCommonUnitTest { + + + @Test + public void getProcessorName() throws Exception { + final String processorName = "testProcessorName"; + final String processorDescription = "testProcessorDescription"; + GenericProcessorInfo genericProcessorInfo = new GenericProcessorInfo(processorName, processorDescription); + assertThat("Processor Name must match", genericProcessorInfo.getProcessorName(), is(processorName)); + + } + + @Test + public void getProcessorDescription() throws Exception { + final String processorName = "testProcessorName"; + final String processorDescription = "testProcessorDescription"; + GenericProcessorInfo genericProcessorInfo = new GenericProcessorInfo(processorName, processorDescription); + assertThat("Processor Description must match", genericProcessorInfo.getProcessorDescription(), + is(processorDescription)); + } + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java index 807d890..80d2341 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java @@ -1,39 +1,39 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.service.processor;
-
-/**
- *
- * @author Rajiv Singla . Creation Date: 11/8/2016.
- */
-public class TestEarlyTerminatingProcessor extends AbstractMessageProcessor<TestProcessorContext> {
-
- @Override
- public String getProcessorDescription() {
- return "Terminates the chain early";
- }
-
- @Override
- public TestProcessorContext processMessage(TestProcessorContext processorContext) {
- setTerminatingProcessingMessage("Terminating early", processorContext);
- return processorContext;
- }
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.service.processor; + +/** + * + * @author Rajiv Singla . Creation Date: 11/8/2016. + */ +public class TestEarlyTerminatingProcessor extends AbstractMessageProcessor<TestProcessorContext> { + + @Override + public String getProcessorDescription() { + return "Terminates the chain early"; + } + + @Override + public TestProcessorContext processMessage(TestProcessorContext processorContext) { + setTerminatingProcessingMessage("Terminating early", processorContext); + return processorContext; + } +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java index b663b69..4850ad5 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java @@ -1,41 +1,41 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.service.processor;
-
-/**
- *
- * @author Rajiv Singla . Creation Date: 11/8/2016.
- */
-public class TestMessageProcessor1 extends AbstractMessageProcessor<TestProcessorContext> {
-
- @Override
- public String getProcessorDescription() {
- return "Appends \" World!\" to the message string and set it to result string";
- }
-
- @Override
- public TestProcessorContext processMessage(TestProcessorContext processorContext) {
- final String message = processorContext.getMessage();
- processorContext.setResult(message + " World!");
- setFinishedProcessingMessage("Finished Appending world", processorContext);
- return processorContext;
- }
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.service.processor; + +/** + * + * @author Rajiv Singla . Creation Date: 11/8/2016. + */ +public class TestMessageProcessor1 extends AbstractMessageProcessor<TestProcessorContext> { + + @Override + public String getProcessorDescription() { + return "Appends \" World!\" to the message string and set it to result string"; + } + + @Override + public TestProcessorContext processMessage(TestProcessorContext processorContext) { + final String message = processorContext.getMessage(); + processorContext.setResult(message + " World!"); + setFinishedProcessingMessage("Finished Appending world", processorContext); + return processorContext; + } +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java index e8a29ff..7c0312a 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java @@ -1,41 +1,41 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.service.processor;
-
-/**
- *
- * @author Rajiv Singla . Creation Date: 11/8/2016.
- */
-public class TestMessageProcessor2 extends AbstractMessageProcessor<TestProcessorContext> {
-
- @Override
- public String getProcessorDescription() {
- return "Appends \" Again\" to the result string";
- }
-
- @Override
- public TestProcessorContext processMessage(TestProcessorContext processorContext) {
- final String result = processorContext.getResult();
- processorContext.setResult(result + " Again");
- setFinishedProcessingMessage("Finished Appending again to result", processorContext);
- return processorContext;
- }
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.service.processor; + +/** + * + * @author Rajiv Singla . Creation Date: 11/8/2016. + */ +public class TestMessageProcessor2 extends AbstractMessageProcessor<TestProcessorContext> { + + @Override + public String getProcessorDescription() { + return "Appends \" Again\" to the result string"; + } + + @Override + public TestProcessorContext processMessage(TestProcessorContext processorContext) { + final String result = processorContext.getResult(); + processorContext.setResult(result + " Again"); + setFinishedProcessingMessage("Finished Appending again to result", processorContext); + return processorContext; + } +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestProcessorContext.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestProcessorContext.java index caaae82..6f849f5 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestProcessorContext.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/service/processor/TestProcessorContext.java @@ -1,84 +1,84 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.service.processor;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- *
- * @author Rajiv Singla . Creation Date: 11/8/2016.
- */
-public class TestProcessorContext implements ProcessorContext {
-
- private String message;
- private boolean continueProcessingFlag;
- private String result;
- private List<? super MessageProcessor<? extends ProcessorContext>> messageProcessors;
-
- public TestProcessorContext(String message, boolean continueProcessingFlag) {
- this.message = message;
- this.continueProcessingFlag = continueProcessingFlag;
- this.messageProcessors = new LinkedList<>();
- }
-
- @Override
- public String getMessage() {
- return message;
- }
-
- @Override
- public boolean canProcessingContinue() {
- return continueProcessingFlag;
- }
-
- @Override
- public void setProcessingContinueFlag(boolean canProcessingContinue) {
- this.continueProcessingFlag = canProcessingContinue;
- }
-
- @Override
- public List<? super MessageProcessor<? extends ProcessorContext>> getMessageProcessors() {
- return messageProcessors;
- }
-
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public boolean isContinueProcessingFlag() {
- return continueProcessingFlag;
- }
-
- public void setContinueProcessingFlag(boolean continueProcessingFlag) {
- this.continueProcessingFlag = continueProcessingFlag;
- }
-
- public String getResult() {
- return result;
- }
-
- public void setResult(String result) {
- this.result = result;
- }
-
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.service.processor; + +import java.util.LinkedList; +import java.util.List; + +/** + * + * @author Rajiv Singla . Creation Date: 11/8/2016. + */ +public class TestProcessorContext implements ProcessorContext { + + private String message; + private boolean continueProcessingFlag; + private String result; + private List<? super MessageProcessor<? extends ProcessorContext>> messageProcessors; + + public TestProcessorContext(String message, boolean continueProcessingFlag) { + this.message = message; + this.continueProcessingFlag = continueProcessingFlag; + this.messageProcessors = new LinkedList<>(); + } + + @Override + public String getMessage() { + return message; + } + + @Override + public boolean canProcessingContinue() { + return continueProcessingFlag; + } + + @Override + public void setProcessingContinueFlag(boolean canProcessingContinue) { + this.continueProcessingFlag = canProcessingContinue; + } + + @Override + public List<? super MessageProcessor<? extends ProcessorContext>> getMessageProcessors() { + return messageProcessors; + } + + + public void setMessage(String message) { + this.message = message; + } + + public boolean isContinueProcessingFlag() { + return continueProcessingFlag; + } + + public void setContinueProcessingFlag(boolean continueProcessingFlag) { + this.continueProcessingFlag = continueProcessingFlag; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/utils/HTTPUtilsTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/utils/HTTPUtilsTest.java index 9c5fe14..0e02c2a 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/utils/HTTPUtilsTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/utils/HTTPUtilsTest.java @@ -1,48 +1,48 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.utils;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
-
-import static org.hamcrest.CoreMatchers.is;
-
-/**
- * @author Rajiv Singla . Creation Date: 12/12/2016.
- */
-public class HTTPUtilsTest extends BaseAnalyticsCommonUnitTest {
-
-
- @Test
- public void testIsSuccessfulResponseCodeWhenResponseCodeIsSuccessful() throws Exception {
- final boolean successfulResponseCode = HTTPUtils.isSuccessfulResponseCode(200);
- Assert.assertThat("200 Response code must return true", successfulResponseCode, is(true));
- }
-
- @Test
- public void testIsSuccessfulResponseCodeWhenResponseCodeIsNotSuccessful() throws Exception {
- final boolean successfulResponseCode = HTTPUtils.isSuccessfulResponseCode(301);
- Assert.assertThat("301 Response code must return false", successfulResponseCode, is(false));
- }
-
-
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.utils; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; + +import static org.hamcrest.CoreMatchers.is; + +/** + * @author Rajiv Singla . Creation Date: 12/12/2016. + */ +public class HTTPUtilsTest extends BaseAnalyticsCommonUnitTest { + + + @Test + public void testIsSuccessfulResponseCodeWhenResponseCodeIsSuccessful() throws Exception { + final boolean successfulResponseCode = HTTPUtils.isSuccessfulResponseCode(200); + Assert.assertThat("200 Response code must return true", successfulResponseCode, is(true)); + } + + @Test + public void testIsSuccessfulResponseCodeWhenResponseCodeIsNotSuccessful() throws Exception { + final boolean successfulResponseCode = HTTPUtils.isSuccessfulResponseCode(301); + Assert.assertThat("301 Response code must return false", successfulResponseCode, is(false)); + } + + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/utils/MessageProcessorUtilsTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/utils/MessageProcessorUtilsTest.java index 1a44571..5edf851 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/utils/MessageProcessorUtilsTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/utils/MessageProcessorUtilsTest.java @@ -1,62 +1,62 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.utils;
-
-import com.google.common.collect.ImmutableSet;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
-import org.openecomp.dcae.apod.analytics.common.service.filter.JsonMessageFilterProcessorContext;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Rajiv Singla . Creation Date: 3/3/2017.
- */
-public class MessageProcessorUtilsTest extends BaseAnalyticsCommonUnitTest {
-
-
- @Test
- public void testProcessJsonFilterMappings() throws Exception {
- final String jsonMessage = fromStream(CEF_MESSAGE_FILE_PATH);
-
- final Map<String, Set<String>> jsonFilterMappings = new HashMap<>();
- jsonFilterMappings.put("$.event.commonEventHeader.domain", ImmutableSet.of("measurementsForVfScaling"));
- jsonFilterMappings.put("$.event.commonEventHeader.eventName",
- ImmutableSet.of("vFirewall", "vLoadBalancer", "Mfvs_eNodeB_RANKPI"));
-
- final JsonMessageFilterProcessorContext jsonMessageFilterProcessorContext =
- MessageProcessorUtils.processJsonFilterMappings(jsonMessage, jsonFilterMappings);
- final Boolean matched = jsonMessageFilterProcessorContext.getMatched();
- Assert.assertNotNull(matched);
- Assert.assertTrue(matched);
- }
-
- @Test(expected = IllegalStateException.class)
- public void testProcessJsonFilterMappingsWhenMappingsAreEmpty() throws Exception {
- final String jsonMessage = fromStream(CEF_MESSAGE_FILE_PATH);
- final Map<String, Set<String>> jsonFilterMappings = new HashMap<>();
- MessageProcessorUtils.processJsonFilterMappings(jsonMessage, jsonFilterMappings);
- }
-
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.utils; + +import com.google.common.collect.ImmutableSet; +import org.junit.Assert; +import org.junit.Test; +import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; +import org.onap.dcae.apod.analytics.common.service.filter.JsonMessageFilterProcessorContext; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * @author Rajiv Singla . Creation Date: 3/3/2017. + */ +public class MessageProcessorUtilsTest extends BaseAnalyticsCommonUnitTest { + + + @Test + public void testProcessJsonFilterMappings() throws Exception { + final String jsonMessage = fromStream(CEF_MESSAGE_FILE_PATH); + + final Map<String, Set<String>> jsonFilterMappings = new HashMap<>(); + jsonFilterMappings.put("$.event.commonEventHeader.domain", ImmutableSet.of("measurementsForVfScaling")); + jsonFilterMappings.put("$.event.commonEventHeader.eventName", + ImmutableSet.of("vFirewall", "vLoadBalancer", "Mfvs_eNodeB_RANKPI")); + + final JsonMessageFilterProcessorContext jsonMessageFilterProcessorContext = + MessageProcessorUtils.processJsonFilterMappings(jsonMessage, jsonFilterMappings); + final Boolean matched = jsonMessageFilterProcessorContext.getMatched(); + Assert.assertNotNull(matched); + Assert.assertTrue(matched); + } + + @Test(expected = IllegalStateException.class) + public void testProcessJsonFilterMappingsWhenMappingsAreEmpty() throws Exception { + final String jsonMessage = fromStream(CEF_MESSAGE_FILE_PATH); + final Map<String, Set<String>> jsonFilterMappings = new HashMap<>(); + MessageProcessorUtils.processJsonFilterMappings(jsonMessage, jsonFilterMappings); + } + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/utils/PersistenceUtilsTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/utils/PersistenceUtilsTest.java index f8251b0..54e3770 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/utils/PersistenceUtilsTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/utils/PersistenceUtilsTest.java @@ -1,40 +1,40 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.utils;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
-
-/**
- * @author Rajiv Singla . Creation Date: 12/12/2016.
- */
-public class PersistenceUtilsTest extends BaseAnalyticsCommonUnitTest {
-
- @Test
- public void testGetCurrentTimeReverseSubKey() throws Exception {
-
- final String currentTimeReverseSubKey = PersistenceUtils.getCurrentTimeReverseSubKey();
- Assert.assertNotNull("Sub Key must not be null", currentTimeReverseSubKey);
- Assert.assertTrue("Sub Key Length must be 25", currentTimeReverseSubKey.length() == 25);
- }
-
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.utils; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; + +/** + * @author Rajiv Singla . Creation Date: 12/12/2016. + */ +public class PersistenceUtilsTest extends BaseAnalyticsCommonUnitTest { + + @Test + public void testGetCurrentTimeReverseSubKey() throws Exception { + + final String currentTimeReverseSubKey = PersistenceUtils.getCurrentTimeReverseSubKey(); + Assert.assertNotNull("Sub Key must not be null", currentTimeReverseSubKey); + Assert.assertTrue("Sub Key Length must be 25", currentTimeReverseSubKey.length() == 25); + } + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/validation/GenericValidationResponseTest.java b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/validation/GenericValidationResponseTest.java index 190dce7..e8e505e 100644 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/validation/GenericValidationResponseTest.java +++ b/dcae-analytics-common/src/test/java/org/onap/dcae/apod/analytics/common/validation/GenericValidationResponseTest.java @@ -1,129 +1,129 @@ -/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * Copyright © 2017 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.openecomp.dcae.apod.analytics.common.validation;
-
-import org.junit.Test;
-import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * @author Rajiv Singla . Creation Date: 12/12/2016.
- */
-public class GenericValidationResponseTest extends BaseAnalyticsCommonUnitTest {
-
-
- @Test
- public void testHasErrorsWhenResponseHasErrors() throws Exception {
-
- final String fieldName = "testField";
- final String errorMessage = "Some error message";
- final GenericValidationResponse<CDAPTestAppSettings> validationResponse =
- createTestValidationResponse(fieldName, errorMessage);
-
- validationResponse.addErrorMessage("testField", "Some error message");
- assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true));
- }
-
- @Test
- public void testHasErrorsWhenResponseDoesNotHaveErrors() throws Exception {
- GenericValidationResponse<CDAPTestAppSettings> validationResponse = new
- GenericValidationResponse<>();
- assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(false));
- }
-
- @Test
- public void testGetFieldNamesWithError() throws Exception {
-
- final String fieldName = "testField";
- final String errorMessage = "Some error message";
- final GenericValidationResponse<CDAPTestAppSettings> validationResponse =
- createTestValidationResponse(fieldName, errorMessage);
-
- assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true));
- assertThat("Validation Field Name must match",
- validationResponse.getFieldNamesWithError().iterator().next(), is(fieldName));
- }
-
- @Test
- public void testGetErrorMessages() throws Exception {
-
- final String fieldName = "testField";
- final String errorMessage = "Some error message";
- final GenericValidationResponse<CDAPTestAppSettings> validationResponse =
- createTestValidationResponse(fieldName, errorMessage);
-
- assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true));
- assertThat("Validation Error Message must match",
- validationResponse.getErrorMessages().iterator().next(), is(errorMessage));
- }
-
- @Test
- public void getValidationResultsAsMap() throws Exception {
- final String fieldName = "testField";
- final String errorMessage = "Some error message";
- final GenericValidationResponse<CDAPTestAppSettings> validationResponse =
- createTestValidationResponse(fieldName, errorMessage);
- assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true));
- assertThat("Validation Field Name must match",
- validationResponse.getValidationResultsAsMap().keySet().iterator().next(), is(fieldName));
- assertThat("Validation Error Message must match",
- validationResponse.getValidationResultsAsMap().values().iterator().next(), is(errorMessage));
- }
-
- @Test
- public void getAllErrorMessage() throws Exception {
- final String fieldName = "testField";
- final String errorMessage = "Some error message";
- final GenericValidationResponse<CDAPTestAppSettings> validationResponse =
- createTestValidationResponse(fieldName, errorMessage);
- final String allErrorMessage = validationResponse.getAllErrorMessage();
- assertThat("All Error messages should match", allErrorMessage, is(errorMessage));
- }
-
- @Test
- public void addErrorMessage() throws Exception {
- final String fieldName = "testField";
- final String errorMessage = "Some error message";
- GenericValidationResponse<CDAPTestAppSettings> validationResponse = new
- GenericValidationResponse<>();
- validationResponse.addErrorMessage(fieldName, errorMessage);
-
- assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true));
- assertThat("Validation Field Name must match",
- validationResponse.getValidationResultsAsMap().keySet().iterator().next(), is(fieldName));
- assertThat("Validation Error Message must match",
- validationResponse.getValidationResultsAsMap().values().iterator().next(), is(errorMessage));
- }
-
- private static GenericValidationResponse<CDAPTestAppSettings> createTestValidationResponse(
- final String fieldName, final String errorMessage) {
- GenericValidationResponse<CDAPTestAppSettings> validationResponse = new
- GenericValidationResponse<>();
- if (fieldName != null || errorMessage != null) {
- validationResponse.addErrorMessage(fieldName, errorMessage);
- }
-
- return validationResponse;
- }
-
-}
+/* + * ===============================LICENSE_START====================================== + * dcae-analytics + * ================================================================================ + * Copyright © 2017 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.apod.analytics.common.validation; + +import org.junit.Test; +import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +/** + * @author Rajiv Singla . Creation Date: 12/12/2016. + */ +public class GenericValidationResponseTest extends BaseAnalyticsCommonUnitTest { + + + @Test + public void testHasErrorsWhenResponseHasErrors() throws Exception { + + final String fieldName = "testField"; + final String errorMessage = "Some error message"; + final GenericValidationResponse<CDAPTestAppSettings> validationResponse = + createTestValidationResponse(fieldName, errorMessage); + + validationResponse.addErrorMessage("testField", "Some error message"); + assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true)); + } + + @Test + public void testHasErrorsWhenResponseDoesNotHaveErrors() throws Exception { + GenericValidationResponse<CDAPTestAppSettings> validationResponse = new + GenericValidationResponse<>(); + assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(false)); + } + + @Test + public void testGetFieldNamesWithError() throws Exception { + + final String fieldName = "testField"; + final String errorMessage = "Some error message"; + final GenericValidationResponse<CDAPTestAppSettings> validationResponse = + createTestValidationResponse(fieldName, errorMessage); + + assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true)); + assertThat("Validation Field Name must match", + validationResponse.getFieldNamesWithError().iterator().next(), is(fieldName)); + } + + @Test + public void testGetErrorMessages() throws Exception { + + final String fieldName = "testField"; + final String errorMessage = "Some error message"; + final GenericValidationResponse<CDAPTestAppSettings> validationResponse = + createTestValidationResponse(fieldName, errorMessage); + + assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true)); + assertThat("Validation Error Message must match", + validationResponse.getErrorMessages().iterator().next(), is(errorMessage)); + } + + @Test + public void getValidationResultsAsMap() throws Exception { + final String fieldName = "testField"; + final String errorMessage = "Some error message"; + final GenericValidationResponse<CDAPTestAppSettings> validationResponse = + createTestValidationResponse(fieldName, errorMessage); + assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true)); + assertThat("Validation Field Name must match", + validationResponse.getValidationResultsAsMap().keySet().iterator().next(), is(fieldName)); + assertThat("Validation Error Message must match", + validationResponse.getValidationResultsAsMap().values().iterator().next(), is(errorMessage)); + } + + @Test + public void getAllErrorMessage() throws Exception { + final String fieldName = "testField"; + final String errorMessage = "Some error message"; + final GenericValidationResponse<CDAPTestAppSettings> validationResponse = + createTestValidationResponse(fieldName, errorMessage); + final String allErrorMessage = validationResponse.getAllErrorMessage(); + assertThat("All Error messages should match", allErrorMessage, is(errorMessage)); + } + + @Test + public void addErrorMessage() throws Exception { + final String fieldName = "testField"; + final String errorMessage = "Some error message"; + GenericValidationResponse<CDAPTestAppSettings> validationResponse = new + GenericValidationResponse<>(); + validationResponse.addErrorMessage(fieldName, errorMessage); + + assertThat("Validation Response must has errors", validationResponse.hasErrors(), is(true)); + assertThat("Validation Field Name must match", + validationResponse.getValidationResultsAsMap().keySet().iterator().next(), is(fieldName)); + assertThat("Validation Error Message must match", + validationResponse.getValidationResultsAsMap().values().iterator().next(), is(errorMessage)); + } + + private static GenericValidationResponse<CDAPTestAppSettings> createTestValidationResponse( + final String fieldName, final String errorMessage) { + GenericValidationResponse<CDAPTestAppSettings> validationResponse = new + GenericValidationResponse<>(); + if (fieldName != null || errorMessage != null) { + validationResponse.addErrorMessage(fieldName, errorMessage); + } + + return validationResponse; + } + +} diff --git a/dcae-analytics-common/src/test/resources/logback-test.xml b/dcae-analytics-common/src/test/resources/logback-test.xml index 9e40f24..fb02c74 100644 --- a/dcae-analytics-common/src/test/resources/logback-test.xml +++ b/dcae-analytics-common/src/test/resources/logback-test.xml @@ -1,55 +1,55 @@ -<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ ===============================LICENSE_START======================================
- ~ dcae-analytics
- ~ ================================================================================
- ~ Copyright © 2017 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===========================================
- -->
-<configuration>
-
- <!--
- Disabling some chatty loggers.
- -->
- <logger name="org.apache.commons.beanutils" level="ERROR"/>
- <logger name="org.apache.zookeeper.server" level="ERROR"/>
- <logger name="org.apache.zookeeper" level="ERROR"/>
- <logger name="com.ning" level="WARN"/>
- <logger name="org.apache.spark" level="WARN"/>
- <logger name="org.spark-project" level="WARN"/>
- <logger name="org.apache.hadoop" level="WARN"/>
- <logger name="org.apache.hive" level="WARN"/>
- <logger name="org.quartz.core" level="WARN"/>
- <logger name="org.eclipse.jetty" level="WARN"/>
- <logger name="io.netty.util.internal" level="WARN"/>
-
- <logger name="org.apache.twill" level="WARN"/>
- <logger name="co.cask.cdap" level="INFO"/>
- <logger name="org.openecomp.dcae.apod.analytics" level="DEBUG"/>
-
- <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n</pattern>
- </encoder>
- </appender>
-
- <root level="ERROR">
- <appender-ref ref="Console"/>
- </root>
-
-
-</configuration>
-
+<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ ===============================LICENSE_START====================================== + ~ dcae-analytics + ~ ================================================================================ + ~ Copyright © 2017 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=========================================== + --> +<configuration> + + <!-- + Disabling some chatty loggers. + --> + <logger name="org.apache.commons.beanutils" level="ERROR"/> + <logger name="org.apache.zookeeper.server" level="ERROR"/> + <logger name="org.apache.zookeeper" level="ERROR"/> + <logger name="com.ning" level="WARN"/> + <logger name="org.apache.spark" level="WARN"/> + <logger name="org.spark-project" level="WARN"/> + <logger name="org.apache.hadoop" level="WARN"/> + <logger name="org.apache.hive" level="WARN"/> + <logger name="org.quartz.core" level="WARN"/> + <logger name="org.eclipse.jetty" level="WARN"/> + <logger name="io.netty.util.internal" level="WARN"/> + + <logger name="org.apache.twill" level="WARN"/> + <logger name="co.cask.cdap" level="INFO"/> + <logger name="org.onap.dcae.apod.analytics" level="DEBUG"/> + + <appender name="Console" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n</pattern> + </encoder> + </appender> + + <root level="ERROR"> + <appender-ref ref="Console"/> + </root> + + +</configuration> + |