From 97afdabeb7d1f2095f3fa170f0f78fb366c91644 Mon Sep 17 00:00:00 2001 From: Venkata Molluru Date: Sat, 30 Oct 2021 08:51:05 +0000 Subject: Add support to 7.1 VES data-stream in-parallel to 5.4 Issue-ID: HOLMES-308 Signed-off-by: Venkata Molluru Change-Id: I2a45548659e63171d80fdaab85318f0890b94345 --- .../dsa/dmaappolling/DMaaPResponseUtilTest.java | 180 +++++++++++++++------ .../holmes/dsa/dmaappolling/SubscriberTest.java | 44 +++-- .../holmes/engine/dmaap/DMaaPAlarmPollingTest.java | 2 +- 3 files changed, 153 insertions(+), 73 deletions(-) (limited to 'engine-d/src/test') diff --git a/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java b/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java index 3b46fed..ded50b0 100644 --- a/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java +++ b/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtilTest.java @@ -24,8 +24,9 @@ import org.onap.holmes.common.api.stat.VesAlarm; import org.powermock.core.classloader.annotations.PrepareForTest; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; +import java.util.Map; +import java.util.TimeZone; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; @@ -62,7 +63,7 @@ public class DMaaPResponseUtilTest { + "\"sourceId\":\"3345556444\"," + "\"sourceName\":\"nihoahh\"," + "\"startEpochMicrosec\":54545454," - + "\"version\":998989879" + + "\"version\":\"4.0\"" + "}," + "\"faultFields\":{" + "\"alarmAdditionalInformation\":[" @@ -80,7 +81,7 @@ public class DMaaPResponseUtilTest { + "\"eventCategory\":\"Event category\"," + "\"eventSeverity\":\"CRITICAL\"," + "\"eventSourceType\":\"type of event source\"," - + "\"faultFieldsVersion\":567567567," + + "\"faultFieldsVersion\":\"2.0\"," + "\"specificProblem\":\"short description\"," + "\"vfStatus\":\"Preparing to terminate\"" + "}" @@ -101,25 +102,122 @@ public class DMaaPResponseUtilTest { expected.setSourceId("3345556444"); expected.setSourceName("nihoahh"); expected.setStartEpochMicrosec((long) 54545454); - expected.setVersion((long) 998989879); - - List alarmAdditionalFields = new ArrayList<>(); - AlarmAdditionalField alarmAdditionalField1 = new AlarmAdditionalField(); - alarmAdditionalField1.setName("niaho"); - alarmAdditionalField1.setName("1111"); - alarmAdditionalFields.add(alarmAdditionalField1); - AlarmAdditionalField alarmAdditionalField2 = new AlarmAdditionalField(); - alarmAdditionalField2.setName("tian"); - alarmAdditionalField2.setName("22222"); - alarmAdditionalFields.add(alarmAdditionalField2); + expected.setVersion("4.0"); + + Map alarmAdditionalFields = new HashMap(); + alarmAdditionalFields.put("niaho", "1111"); + alarmAdditionalFields.put("titan", "22222"); expected.setAlarmAdditionalInformation(alarmAdditionalFields); + expected.setAlarmCondition("fadilel"); + expected.setAlarmInterfaceA("generating the alarm"); + expected.setEventCategory("Event category"); + expected.setEventSeverity("CRITICAL"); + expected.setEventSourceType("type of event source"); + expected.setFaultFieldsVersion("2.0"); + expected.setSpecificProblem("short description"); + expected.setVfStatus("Preparing to terminate"); + + VesAlarm result = dMaaPResponseUtil.convertJsonToVesAlarm(json); + + assertThat(expected.getDomain(), equalTo(result.getDomain())); + assertThat(expected.getEventId(), equalTo(result.getEventId())); + assertThat(expected.getEventName(), equalTo(result.getEventName())); + assertThat(expected.getEventType(), equalTo(result.getEventType())); + assertThat(expected.getLastEpochMicrosec(), equalTo(result.getLastEpochMicrosec())); + assertThat(expected.getNfcNamingCode(), equalTo(result.getNfcNamingCode())); + assertThat(expected.getNfNamingCode(), equalTo(result.getNfNamingCode())); + assertThat(expected.getPriority(), equalTo(result.getPriority())); + assertThat(expected.getReportingEntityId(), equalTo(result.getReportingEntityId())); + assertThat(expected.getReportingEntityName(), equalTo(result.getReportingEntityName())); + assertThat(expected.getSequence(), equalTo(result.getSequence())); + assertThat(expected.getSourceId(), equalTo(result.getSourceId())); + assertThat(expected.getSourceName(), equalTo(result.getSourceName())); + assertThat(expected.getStartEpochMicrosec(), equalTo(result.getStartEpochMicrosec())); + assertThat(expected.getVersion(), equalTo(result.getVersion())); + + assertThat(expected.getAlarmCondition(), equalTo(result.getAlarmCondition())); + assertThat(expected.getAlarmInterfaceA(), equalTo(result.getAlarmInterfaceA())); + assertThat(expected.getEventCategory(), equalTo(result.getEventCategory())); + assertThat(expected.getEventSeverity(), equalTo(result.getEventSeverity())); + assertThat(expected.getEventSourceType(), equalTo(result.getEventSourceType())); + assertThat(expected.getFaultFieldsVersion(), equalTo(result.getFaultFieldsVersion())); + assertThat(expected.getSpecificProblem(), equalTo(result.getSpecificProblem())); + assertThat(expected.getVfStatus(), equalTo(result.getVfStatus())); + + } + + @Test + public void testDMaaPResponseUtil_v7_input_normal() throws IOException { + String json = "{\"event\":{" + + "\"commonEventHeader\":{" + + "\"domain\":\"fault\"," + + "\"eventId\":\"112355255-24345\"," + + "\"eventName\":\"4333454333\"," + + "\"eventType\":\"remote\"," + + "\"lastEpochMicrosec\":333434333," + + "\"nfcNamingCode\":\"567422\"," + + "\"nfNamingCode\":\"qweertrr\"," + + "\"priority\":\"High\"," + + "\"reportingEntityId\":\"99888888888\"," + + "\"reportingEntityName\":\"tianshisdlsdjf\"," + + "\"sequence\":34566," + + "\"sourceId\":\"3345556444\"," + + "\"sourceName\":\"nihoahh\"," + + "\"startEpochMicrosec\":54545454," + + "\"version\":\"998989879\"," + + "\"timeZoneOffset\":\"UTC-05:30\"," + + "\"nfVendorName\": \"Ericsson\"," + + "\"vesEventListenerVersion\": \"7.2.1\"" + + "}," + + "\"faultFields\":{" + + "\"alarmAdditionalInformation\":" + + "{" + + "\"niaho\":\"1111\"," + + "\"titan\":\"2222\"" + + "}" + + "," + + "\"alarmCondition\":\"fadilel\"," + + "\"alarmInterfaceA\":\"generating the alarm\"," + + "\"eventCategory\":\"Event category\"," + + "\"eventSeverity\":\"CRITICAL\"," + + "\"eventSourceType\":\"type of event source\"," + + "\"faultFieldsVersion\":4.0," + + "\"specificProblem\":\"short description\"," + + "\"vfStatus\":\"Preparing to terminate\"" + + "}" + + "}" + + "}"; + VesAlarm expected = new VesAlarm(); + expected.setDomain("fault"); + expected.setEventId("112355255-24345"); + expected.setEventName("4333454333"); + expected.setEventType("remote"); + expected.setLastEpochMicrosec((long) 333434333); + expected.setNfcNamingCode("567422"); + expected.setNfNamingCode("qweertrr"); + expected.setPriority("High"); + expected.setReportingEntityId("99888888888"); + expected.setReportingEntityName("tianshisdlsdjf"); + expected.setSequence(34566); + expected.setSourceId("3345556444"); + expected.setSourceName("nihoahh"); + expected.setStartEpochMicrosec((long) 54545454); + expected.setVersion("998989879"); + expected.setNfVendorName("Ericsson"); + expected.setVesEventListenerVersion("7.2.1"); + TimeZone timeZone = TimeZone.getTimeZone("UTC-05:30"); + expected.setTimeZoneOffset(timeZone); + Map alarmAdditionalFields = new HashMap(); + alarmAdditionalFields.put("niaho", "1111"); + alarmAdditionalFields.put("titan", "22222"); + expected.setAlarmAdditionalInformation(alarmAdditionalFields); expected.setAlarmCondition("fadilel"); expected.setAlarmInterfaceA("generating the alarm"); expected.setEventCategory("Event category"); expected.setEventSeverity("CRITICAL"); expected.setEventSourceType("type of event source"); - expected.setFaultFieldsVersion((long) 567567567); + expected.setFaultFieldsVersion("4.0"); expected.setSpecificProblem("short description"); expected.setVfStatus("Preparing to terminate"); @@ -149,6 +247,9 @@ public class DMaaPResponseUtilTest { assertThat(expected.getFaultFieldsVersion(), equalTo(result.getFaultFieldsVersion())); assertThat(expected.getSpecificProblem(), equalTo(result.getSpecificProblem())); assertThat(expected.getVfStatus(), equalTo(result.getVfStatus())); + assertThat(expected.getVesEventListenerVersion(), equalTo(result.getVesEventListenerVersion())); + assertThat(expected.getNfVendorName(), equalTo(result.getNfVendorName())); + assertThat(expected.getTimeZoneOffset(), equalTo(result.getTimeZoneOffset())); } @@ -180,7 +281,7 @@ public class DMaaPResponseUtilTest { + "\"sequence\":34566," + "\"sourceName\":\"nihoahh\"," + "\"startEpochMicrosec\":54545454," - + "\"version\":998989879" + + "\"version\":\"4.0\"" + "}," + "\"faultFields\":{" + "\"alarmAdditionalInformation\":[" @@ -196,7 +297,7 @@ public class DMaaPResponseUtilTest { + "\"alarmCondition\":\"fadilel\"," + "\"eventSeverity\":\"CRITICAL\"," + "\"eventSourceType\":\"type of event source\"," - + "\"faultFieldsVersion\":567567567," + + "\"faultFieldsVersion\":\"2.0\"," + "\"specificProblem\":\"short description\"," + "\"vfStatus\":\"Preparing to terminate\"" + "}" @@ -211,23 +312,16 @@ public class DMaaPResponseUtilTest { expected.setSequence(34566); expected.setSourceName("nihoahh"); expected.setStartEpochMicrosec((long) 54545454); - expected.setVersion((long) 998989879); - - List alarmAdditionalFields = new ArrayList<>(); - AlarmAdditionalField alarmAdditionalField1 = new AlarmAdditionalField(); - alarmAdditionalField1.setName("niaho"); - alarmAdditionalField1.setName("1111"); - alarmAdditionalFields.add(alarmAdditionalField1); - AlarmAdditionalField alarmAdditionalField2 = new AlarmAdditionalField(); - alarmAdditionalField2.setName("tian"); - alarmAdditionalField2.setName("22222"); - alarmAdditionalFields.add(alarmAdditionalField2); + expected.setVersion("4.0"); + Map alarmAdditionalFields = new HashMap(); + alarmAdditionalFields.put("niaho", "1111"); + alarmAdditionalFields.put("titan", "22222"); expected.setAlarmAdditionalInformation(alarmAdditionalFields); expected.setAlarmCondition("fadilel"); expected.setEventSeverity("CRITICAL"); expected.setEventSourceType("type of event source"); - expected.setFaultFieldsVersion((long) 567567567); + expected.setFaultFieldsVersion("2.0"); expected.setSpecificProblem("short description"); expected.setVfStatus("Preparing to terminate"); @@ -265,7 +359,7 @@ public class DMaaPResponseUtilTest { + "\"sequence\":34566," + "\"sourceName\":\"nihoahh\"," + "\"startEpochMicrosec\":54545454," - + "\"version\":998989879" + + "\"version\":\"4.0\"" + "}," + "\"faultFields\":{" + "\"alarmAdditionalInformation\":[" @@ -281,7 +375,7 @@ public class DMaaPResponseUtilTest { + "\"alarmCondition\":\"fadilel\"," + "\"eventSeverity\":\"CRITICAL\"," + "\"eventSourceType\":\"type of event source\"," - + "\"faultFieldsVersion\":567567567," + + "\"faultFieldsVersion\":\"2.0\"," + "\"specificProblem\":\"short description\"," + "\"vfStatus\":\"Preparing to terminate\"" + "}" @@ -296,23 +390,15 @@ public class DMaaPResponseUtilTest { expected.setSequence(34566); expected.setSourceName("nihoahh"); expected.setStartEpochMicrosec((long) 54545454); - expected.setVersion((long) 998989879); - - List alarmAdditionalFields = new ArrayList<>(); - AlarmAdditionalField alarmAdditionalField = new AlarmAdditionalField(); - alarmAdditionalField.setName(null); - alarmAdditionalField.setValue("1111"); - alarmAdditionalFields.add(alarmAdditionalField); - alarmAdditionalField = new AlarmAdditionalField(); - alarmAdditionalField.setName("tian"); - alarmAdditionalField.setValue("22222"); - alarmAdditionalFields.add(alarmAdditionalField); + expected.setVersion("4.0"); + Map alarmAdditionalFields = new HashMap(); + alarmAdditionalFields.put(null, "1111"); expected.setAlarmAdditionalInformation(alarmAdditionalFields); expected.setAlarmCondition("fadilel"); expected.setEventSeverity("CRITICAL"); expected.setEventSourceType("type of event source"); - expected.setFaultFieldsVersion((long) 567567567); + expected.setFaultFieldsVersion("2.0"); expected.setSpecificProblem("short description"); expected.setVfStatus("Preparing to terminate"); @@ -327,11 +413,9 @@ public class DMaaPResponseUtilTest { assertThat(expected.getSourceName(), equalTo(result.getSourceName())); assertThat(expected.getStartEpochMicrosec(), equalTo(result.getStartEpochMicrosec())); assertThat(expected.getVersion(), equalTo(result.getVersion())); + assertThat(expected.getAlarmAdditionalInformation().get("niaho"), + equalTo(result.getAlarmAdditionalInformation().get("niaho"))); - assertThat(expected.getAlarmAdditionalInformation().get(0).getName(), - equalTo(result.getAlarmAdditionalInformation().get(0).getName())); - assertThat(expected.getAlarmAdditionalInformation().get(0).getValue(), - equalTo(result.getAlarmAdditionalInformation().get(0).getValue())); assertThat(expected.getAlarmCondition(), equalTo(result.getAlarmCondition())); assertThat(expected.getEventSeverity(), equalTo(result.getEventSeverity())); diff --git a/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/SubscriberTest.java b/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/SubscriberTest.java index f88ddfb..339a23e 100644 --- a/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/SubscriberTest.java +++ b/engine-d/src/test/java/org/onap/holmes/dsa/dmaappolling/SubscriberTest.java @@ -33,6 +33,8 @@ import org.powermock.modules.junit4.PowerMockRunner; import java.util.ArrayList; import java.util.List; +import java.util.HashMap; +import java.util.Map; import static org.easymock.EasyMock.*; import static org.hamcrest.CoreMatchers.*; @@ -73,19 +75,16 @@ public class SubscriberTest { vesAlarm.setSourceId("Source-123"); vesAlarm.setSourceName("Source-123"); vesAlarm.setStartEpochMicrosec(500L); - vesAlarm.setVersion(1L); - List alarmAdditionalFields = new ArrayList<>(); - AlarmAdditionalField field = new AlarmAdditionalField(); - field.setName("addInfo"); - field.setValue("addInfo"); - alarmAdditionalFields.add(field); - vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields); - vesAlarm.setAlarmCondition("alarmCondition"); + vesAlarm.setVersion("4.0"); + Map alarmAdditionalFields = new HashMap(); + alarmAdditionalFields.put("addInfo", "addInfo"); + vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields); + vesAlarm.setAlarmCondition("alarmCondition"); vesAlarm.setAlarmInterfaceA("alarmInterfaceA"); vesAlarm.setEventCategory("eventCategory"); vesAlarm.setEventSeverity("eventSeverity"); vesAlarm.setEventSourceType("eventSourceType"); - vesAlarm.setFaultFieldsVersion(1L); + vesAlarm.setFaultFieldsVersion("2.0"); vesAlarm.setSpecificProblem("specificProblem"); vesAlarm.setVfStatus("vfStatus"); @@ -104,16 +103,16 @@ public class SubscriberTest { "\"sourceId\": \"Source-123\"," + "\"sourceName\": \"Source-123\"," + "\"startEpochMicrosec\": 500," + - "\"version\": 1" + + "\"version\": \"4.0\"" + "}," + " \"faultFields\" : {" + - "\"alarmAdditionalInformation\": [{\"name\":\"addInfo\", \"value\":\"addInfo\"}]," + + "\"alarmAdditionalInformatiddon\":[{\"name\":\"addInfo\", \"value\":\"addInfo\"}]," + "\"alarmCondition\": \"alarmCondition\"," + "\"alarmInterfaceA\": \"alarmInterfaceA\"," + "\"eventCategory\": \"eventCategory\"," + "\"eventSeverity\": \"eventSeverity\"," + "\"eventSourceType\": \"eventSourceType\"," + - "\"faultFieldsVersion\": 1," + + "\"faultFieldsVersion\": \"2.0\"," + "\"specificProblem\": \"specificProblem\"," + "\"vfStatus\": \"vfStatus\"" + "}}}"; @@ -160,19 +159,16 @@ public class SubscriberTest { vesAlarm.setSourceId("Source-123"); vesAlarm.setSourceName("Source-123"); vesAlarm.setStartEpochMicrosec(500L); - vesAlarm.setVersion(1L); - List alarmAdditionalFields = new ArrayList<>(); - AlarmAdditionalField field = new AlarmAdditionalField(); - field.setName("addInfo"); - field.setValue("addInfo"); - alarmAdditionalFields.add(field); - vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields); - vesAlarm.setAlarmCondition("alarmCondition"); + vesAlarm.setVersion("4.0"); + Map alarmAdditionalFields = new HashMap(); + alarmAdditionalFields.put("addInfo", "addInfo"); + vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields); + vesAlarm.setAlarmCondition("alarmCondition"); vesAlarm.setAlarmInterfaceA("alarmInterfaceA"); vesAlarm.setEventCategory("eventCategory"); vesAlarm.setEventSeverity("eventSeverity"); vesAlarm.setEventSourceType("eventSourceType"); - vesAlarm.setFaultFieldsVersion(1L); + vesAlarm.setFaultFieldsVersion("2.0"); vesAlarm.setSpecificProblem("specificProblem"); vesAlarm.setVfStatus("vfStatus"); @@ -191,7 +187,7 @@ public class SubscriberTest { "\"sourceId\": \"Source-123\"," + "\"sourceName\": \"Source-123\"," + "\"startEpochMicrosec\": 500," + - "\"version\": 1" + + "\"version\": \"4.0\"" + "}," + " \"faultFields\" : {" + "\"alarmAdditionalInformation\": [{\"name\":\"addInfo\", \"value\":\"addInfo\"}]," + @@ -200,7 +196,7 @@ public class SubscriberTest { "\"eventCategory\": \"eventCategory\"," + "\"eventSeverity\": \"eventSeverity\"," + "\"eventSourceType\": \"eventSourceType\"," + - "\"faultFieldsVersion\": 1," + + "\"faultFieldsVersion\": \"2.0\"," + "\"specificProblem\": \"specificProblem\"," + "\"vfStatus\": \"vfStatus\"" + "}}}"; @@ -257,4 +253,4 @@ public class SubscriberTest { PowerMock.verifyAll(); } -} \ No newline at end of file +} diff --git a/engine-d/src/test/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPollingTest.java b/engine-d/src/test/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPollingTest.java index 896a384..74765f5 100644 --- a/engine-d/src/test/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPollingTest.java +++ b/engine-d/src/test/java/org/onap/holmes/engine/dmaap/DMaaPAlarmPollingTest.java @@ -85,4 +85,4 @@ public class DMaaPAlarmPollingTest { assertThat(alarmInfo.getRootFlag(), is(0)); } -} \ No newline at end of file +} -- cgit 1.2.3-korg