From 3c3c7ad09c02852cd0b4db03ecc9cc5c429cab08 Mon Sep 17 00:00:00 2001 From: Zlatko Murgoski Date: Thu, 9 May 2019 11:21:14 +0200 Subject: VES Collector - Event Ordering https://jira.onap.org/browse/DCAEGEN2-1483 Change-Id: I28b0e871ce570a3cf4c0d2e08d040b66eb6db3aa Issue-ID: DCAEGEN2-1483 Signed-off-by: Zlatko Murgoski --- .../java/org/onap/dcae/ApplicationSettingsTest.java | 19 ------------------- src/test/java/org/onap/dcae/TLSTestBase.java | 5 +++-- .../java/org/onap/dcae/common/EventSenderTest.java | 12 +++++++++--- 3 files changed, 12 insertions(+), 24 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/onap/dcae/ApplicationSettingsTest.java b/src/test/java/org/onap/dcae/ApplicationSettingsTest.java index 60287aef..6b0023f8 100644 --- a/src/test/java/org/onap/dcae/ApplicationSettingsTest.java +++ b/src/test/java/org/onap/dcae/ApplicationSettingsTest.java @@ -234,25 +234,6 @@ public class ApplicationSettingsTest { assertEquals(sanitizePath("etc/DmaapConfig.json"), dmaapConfigFileLocation); } - @Test - public void shouldReturnMaximumAllowedQueuedEvents() throws IOException { - // when - int maximumAllowedQueuedEvents = fromTemporaryConfiguration("collector.inputQueue.maxPending=10000") - .maximumAllowedQueuedEvents(); - - // then - assertEquals(10000, maximumAllowedQueuedEvents); - } - - @Test - public void shouldReturnDefaultMaximumAllowedQueuedEvents() throws IOException { - // when - int maximumAllowedQueuedEvents = fromTemporaryConfiguration().maximumAllowedQueuedEvents(); - - // then - assertEquals(1024 * 4, maximumAllowedQueuedEvents); - } - @Test public void shouldTellIfSchemaValidationIsEnabled() throws IOException { // when diff --git a/src/test/java/org/onap/dcae/TLSTestBase.java b/src/test/java/org/onap/dcae/TLSTestBase.java index 4dada129..df10ead9 100644 --- a/src/test/java/org/onap/dcae/TLSTestBase.java +++ b/src/test/java/org/onap/dcae/TLSTestBase.java @@ -24,6 +24,7 @@ package org.onap.dcae; import org.json.JSONObject; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; +import org.onap.dcae.common.EventSender; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; @@ -69,8 +70,8 @@ public class TLSTestBase { protected abstract class TestClassBase { @MockBean - @Qualifier("inputQueue") - protected LinkedBlockingQueue queue; + @Qualifier("eventSender") + protected EventSender eventSender; @LocalServerPort private int port; diff --git a/src/test/java/org/onap/dcae/common/EventSenderTest.java b/src/test/java/org/onap/dcae/common/EventSenderTest.java index aba3c2a9..f49d3cd8 100644 --- a/src/test/java/org/onap/dcae/common/EventSenderTest.java +++ b/src/test/java/org/onap/dcae/common/EventSenderTest.java @@ -28,6 +28,7 @@ import static org.mockito.Mockito.when; import io.vavr.collection.HashMap; import io.vavr.collection.Map; +import org.json.JSONArray; import org.json.JSONObject; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,7 +40,6 @@ import org.onap.dcae.common.publishing.EventPublisher; @RunWith(MockitoJUnitRunner.Silent.class) public class EventSenderTest { - private String event = "{\"VESversion\":\"v7\",\"VESuniqueId\":\"fd69d432-5cd5-4c15-9d34-407c81c61c6a-0\",\"event\":{\"commonEventHeader\":{\"startEpochMicrosec\":1544016106000000,\"eventId\":\"fault33\",\"timeZoneOffset\":\"UTC+00.00\",\"priority\":\"Normal\",\"version\":\"4.0.1\",\"nfVendorName\":\"Ericsson\",\"reportingEntityName\":\"1\",\"sequence\":1,\"domain\":\"fault\",\"lastEpochMicrosec\":1544016106000000,\"eventName\":\"Fault_KeyFileFault\",\"vesEventListenerVersion\":\"7.0.1\",\"sourceName\":\"1\"},\"faultFields\":{\"eventSeverity\":\"CRITICAL\",\"alarmCondition\":\"KeyFileFault\",\"faultFieldsVersion\":\"4.0\",\"eventCategory\":\"PROCESSINGERRORALARM\",\"specificProblem\":\"License Key File Fault_1\",\"alarmAdditionalInformation\":{\"probableCause\":\"ConfigurationOrCustomizationError\",\"additionalText\":\"test_1\",\"source\":\"ManagedElement=1,SystemFunctions=1,Lm=1\"},\"eventSourceType\":\"Lm\",\"vfStatus\":\"Active\"}}}\n"; @Mock @@ -54,7 +54,10 @@ public class EventSenderTest { public void shouldntSendEventWhenStreamIdsIsEmpty() { when(settings.dMaaPStreamsMapping()).thenReturn(HashMap.empty()); eventSender = new EventSender(eventPublisher, settings ); - eventSender.send(new JSONObject(event)); + JSONObject jsonObject = new JSONObject(event); + JSONArray jsonArray = new JSONArray(); + jsonArray.put(jsonObject); + eventSender.send(jsonArray); verify(eventPublisher,never()).sendEvent(any(),any()); } @@ -63,7 +66,10 @@ public class EventSenderTest { Map streams = HashMap.of("fault", new String[]{"ves-fault", "fault-ves"}); when(settings.dMaaPStreamsMapping()).thenReturn(streams); eventSender = new EventSender(eventPublisher, settings ); - eventSender.send(new JSONObject(event)); + JSONObject jsonObject = new JSONObject(event); + JSONArray jsonArray = new JSONArray(); + jsonArray.put(jsonObject); + eventSender.send(jsonArray); verify(eventPublisher, times(2)).sendEvent(any(),any()); } } \ No newline at end of file -- cgit 1.2.3-korg