diff options
author | an4828 <nekrassov@att.com> | 2017-09-15 15:28:53 -0400 |
---|---|---|
committer | an4828 <nekrassov@att.com> | 2017-09-18 09:24:04 -0400 |
commit | 4edf0fa48892bf38d0e3838d125e9bf2324b38e0 (patch) | |
tree | 7216dae042828ec2cf38cb9300af1a32a17b3b91 /dcae-analytics-model/src/test/java | |
parent | 82aaf956855507e5a72d5ef5b45e398430d04a7a (diff) |
Add support for ABATED alerts within CDAP TCA
Change-Id: Iae560a2d0a47b30b41cd31206dc481a08e4930f7
Signed-off-by: an4828 <nekrassov@att.com>
Issue-ID: DCAEGEN2-107
Signed-off-by: an4828 <nekrassov@att.com>
Diffstat (limited to 'dcae-analytics-model/src/test/java')
5 files changed, 64 insertions, 26 deletions
diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelIOUtilsTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelIOUtilsTest.java index d9d004c..ac8d823 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelIOUtilsTest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelIOUtilsTest.java @@ -42,7 +42,7 @@ public class AnalyticsModelIOUtilsTest extends BaseAnalyticsModelUnitTest { private static final String TEST_CONFIG_FILE_LOCATION = "data/json/config/testAppConfig.json"; private static final String INVALID_TEST_CONFIG_FILE_LOCATION = "data/json/config/invalidJsonConfig.json"; - private static final String TEST_PROPERTIES_FILE_LOCATION = "data/testApp.properties"; + private static final String TEST_PROPERTIES_FILE_LOCATION = "data/properties/testApp.properties"; @Test public void testConvertToJsonObjectWhenFileLocationIsValid() throws Exception { diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelJsonUtilsTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelJsonUtilsTest.java index f699ad6..584b1d6 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelJsonUtilsTest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/AnalyticsModelJsonUtilsTest.java @@ -42,7 +42,7 @@ public class AnalyticsModelJsonUtilsTest extends BaseAnalyticsModelUnitTest { }; final String cefMessagesJsonFileLocation = "data/json/cef/cef_messages.json"; - final String eventListenerJsonFileLocation = "data/json/cef/event_listener.json"; + final String eventListenerJsonFileLocation = "data/json/cef/cef_message.json"; @Test public void testReadValueWithTypeReference() throws Exception { @@ -50,7 +50,7 @@ public class AnalyticsModelJsonUtilsTest extends BaseAnalyticsModelUnitTest { Thread.currentThread().getContextClassLoader().getResourceAsStream(cefMessagesJsonFileLocation); List<EventListener> eventListeners = AnalyticsModelJsonUtils.readValue(resourceAsStream, EVENT_LISTENER_TYPE_REFERENCE); - assertThat("Event Listeners size must be 350", eventListeners.size(), is(350)); + assertThat("Event Listeners size must be 31", eventListeners.size(), is(31)); } @Test diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/cef/EventListenerMixinTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/cef/EventListenerMixinTest.java index 61259b4..008cca4 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/cef/EventListenerMixinTest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/cef/EventListenerMixinTest.java @@ -24,11 +24,10 @@ import com.fasterxml.jackson.core.type.TypeReference; import org.junit.Test; import org.openecomp.dcae.apod.analytics.model.BaseAnalyticsModelUnitTest; import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener; -import org.openecomp.dcae.apod.analytics.model.domain.cef.MeasurementsForVfScalingFields; -import org.openecomp.dcae.apod.analytics.model.domain.cef.VNicUsageArray; +import org.openecomp.dcae.apod.analytics.model.domain.cef.Field; +import org.openecomp.dcae.apod.analytics.model.domain.cef.NamedArrayOfFields; import java.util.List; -import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; @@ -38,7 +37,7 @@ import static org.junit.Assert.assertThat; */ public class EventListenerMixinTest extends BaseAnalyticsModelUnitTest { - final String eventListenerJsonFileLocation = "data/json/cef/event_listener.json"; + final String eventListenerJsonFileLocation = "data/json/cef/cef_message.json"; final String cefMessagesJsonFileLocation = "data/json/cef/cef_messages.json"; @Test @@ -46,11 +45,19 @@ public class EventListenerMixinTest extends BaseAnalyticsModelUnitTest { final EventListener eventListener = assertJsonConversions(eventListenerJsonFileLocation, EventListener.class); - Map<String, Object> dynamicProperties = eventListener.getDynamicProperties(); + final List<Field> additionalFields = + eventListener.getEvent().getMeasurementsForVfScalingFields().getAdditionalFields(); - assertThat("Dynamic Properties size must be 1", dynamicProperties.size(), is(1)); + assertThat("Additional Fields size must be 2", additionalFields.size(), is(2)); + final List<NamedArrayOfFields> additionalMeasurements = + eventListener.getEvent().getMeasurementsForVfScalingFields().getAdditionalMeasurements(); + assertThat("Additional Measurements size must be 1", additionalMeasurements.size(), is(1)); + + final List<Field> arrayOfFields = additionalMeasurements.get(0).getArrayOfFields(); + + assertThat("Array Of Field size must be 6", arrayOfFields.size(), is(6)); } @Test @@ -62,19 +69,7 @@ public class EventListenerMixinTest extends BaseAnalyticsModelUnitTest { new TypeReference<List<EventListener>>() { }; List<EventListener> eventListeners = objectMapper.readValue(cefMessageAsString, eventListenerListTypeReference); - assertThat("Event Listeners size must be 350", eventListeners.size(), is(350)); - - final MeasurementsForVfScalingFields measurementsForVfScalingFields = eventListeners.get(0).getEvent() - .getMeasurementsForVfScalingFields(); - - // Note: vNicUsageArray - due to odd naming convention have to be explicitly resolved with Mixin annotations - assertThat("vNicUsageArray is present on the first measurementForVfScaling", - measurementsForVfScalingFields.getVNicUsageArray().size(), is(1)); - final VNicUsageArray vNicUsageArray = measurementsForVfScalingFields.getVNicUsageArray().get(0); - assertThat("ByesIn is present on vNicUsageArray", vNicUsageArray.getBytesIn(), is(6086L)); - - // Note: vNicIdentifier - due to odd naming convention have to be explicity resolved with Mixin annotations - assertThat("vNicIdentifier is present on vNicUsageArray", vNicUsageArray.getVNicIdentifier(), is("eth0")); + assertThat("Event Listeners size must be 31", eventListeners.size(), is(31)); // Check serialized json will match deserialized json final String eventListenerString = objectMapper.writeValueAsString(eventListeners); diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/config/tca/TCAControllerAppConfigMixinTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/config/tca/TCAControllerAppConfigMixinTest.java new file mode 100644 index 0000000..5b1c47f --- /dev/null +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/config/tca/TCAControllerAppConfigMixinTest.java @@ -0,0 +1,43 @@ +package org.openecomp.dcae.apod.analytics.model.util.json.mixin.config.tca; + +import org.junit.Test; +import org.openecomp.dcae.apod.analytics.model.BaseAnalyticsModelUnitTest; +import org.openecomp.dcae.apod.analytics.model.config.tca.DMAAPInfo; +import org.openecomp.dcae.apod.analytics.model.config.tca.TCAControllerAppConfig; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +/** + * Author: rs153v (Rajiv Singla) . Creation Date: 8/25/2017. + */ +public class TCAControllerAppConfigMixinTest extends BaseAnalyticsModelUnitTest { + + final String tcaControllerAppConfigJsonFileLocation = "data/json/config/controller_app_config.json"; + + @Test + public void testTCAControllerConfigJsonConversions() throws Exception { + + final TCAControllerAppConfig tcaControllerAppConfig = + assertJsonConversions(tcaControllerAppConfigJsonFileLocation, TCAControllerAppConfig.class); + + assertThat("TCA Stream Publishes must not be null", + tcaControllerAppConfig.getStreamsPublishes(), is(notNullValue())); + + assertThat("TCA Stream Subscribes must not be null", + tcaControllerAppConfig.getStreamsSubscribes(), is(notNullValue())); + + final DMAAPInfo publisherDmaaPInfo = tcaControllerAppConfig.getStreamsPublishes().getTcaHandleOut() + .getDmaapInfo(); + assertThat("TCA publisher URL Info must not be null", + publisherDmaaPInfo.getTopicUrl(), is(notNullValue())); + + final DMAAPInfo subscriberDmaaPInfo = tcaControllerAppConfig.getStreamsSubscribes().getTcaHandleIn() + .getDmaapInfo(); + assertThat("TCA subscriber URL Info must not be null", + subscriberDmaaPInfo.getTopicUrl(), is(notNullValue())); + + } + +} diff --git a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/policy/tca/TCAPolicyMixinTest.java b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/policy/tca/TCAPolicyMixinTest.java index 09c9672..a42f816 100644 --- a/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/policy/tca/TCAPolicyMixinTest.java +++ b/dcae-analytics-model/src/test/java/org/openecomp/dcae/apod/analytics/model/util/json/mixin/policy/tca/TCAPolicyMixinTest.java @@ -40,11 +40,11 @@ public class TCAPolicyMixinTest extends BaseAnalyticsModelUnitTest { final TCAPolicy tcaPolicy = assertJsonConversions(tcaPolicyJsonFileLocation, TCAPolicy.class); - assertThat("TCA Policy Metrics Per functional role must be 2", - tcaPolicy.getMetricsPerFunctionalRole().size(), is(2)); + assertThat("TCA Policy Metrics Per Event Name must be 2", + tcaPolicy.getMetricsPerEventName().size(), is(2)); - assertThat("TCA Policy Thresholds for first functional role must be 2", - tcaPolicy.getMetricsPerFunctionalRole().get(0).getThresholds().size(), is(2)); + assertThat("TCA Policy Thresholds for first event name must be 3", + tcaPolicy.getMetricsPerEventName().get(0).getThresholds().size(), is(3)); testSerialization(tcaPolicy, getClass()); |