diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java | 65 | ||||
-rw-r--r-- | src/test/resources/measurement5x.json | 98 | ||||
-rw-r--r-- | src/test/resources/measurement7x.json | 107 |
3 files changed, 269 insertions, 1 deletions
diff --git a/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java b/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java index 09517ae3..310e8be3 100644 --- a/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java +++ b/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java @@ -20,6 +20,7 @@ package org.onap.dcae.vestest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import java.io.FileReader;
import java.io.IOException;
@@ -116,8 +117,70 @@ public class TestConfigProcessor { System.out.println("responseData==" + responseData);
assertEquals(receiveDiscards, responseData);
}
+
+ @Test
+ public void testMapRenameObject() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();
+ System.out.println("event==" + jsonObject.toString());
+ //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.faultFields.faultVFScalingFields\",\"oldField\": \"event.faultFields.errors\",\"mapType\":\"renameObject\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ final String receiveDiscards = cpEvent.getEventObjectVal("event.faultFields.errors").toString();
+ System.out.println("receiveDiscards==" + receiveDiscards);
+ cpEvent.map(jsonArgs);
+ final String responseData = cpEvent
+ .getEventObjectVal("event.faultFields.faultVFScalingFields")
+ .toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals(receiveDiscards, responseData);
+ }
+ @Test
+ public void testMapHashmapToNameValueArray() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();
+ System.out.println("event==" + jsonObject.toString());
+ //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.faultFields.errors\",\"mapType\":\"hashmapToNameValueArray\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ final String receiveDiscards = cpEvent.getEventObjectVal("event.faultFields.errors").toString();
+ System.out.println("receiveDiscards==" + receiveDiscards);
+ cpEvent.map(jsonArgs);
+ final String responseData = cpEvent
+ .getEventObjectVal("event.faultFields.errors")
+ .toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertNotEquals(receiveDiscards, responseData);
+ }
@Test
+ public void testMapNameValueArrayToHashmap() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();
+ System.out.println("event==" + jsonObject.toString());
+ //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.faultFields.alarmAdditionalInformation\",\"mapType\":\"nameValueArrayToHashmap\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ final String receiveDiscards = cpEvent.getEventObjectVal("event.faultFields.alarmAdditionalInformation").toString();
+ System.out.println("receiveDiscards==" + receiveDiscards);
+ cpEvent.map(jsonArgs);
+ final String responseData = cpEvent
+ .getEventObjectVal("event.faultFields.alarmAdditionalInformation")
+ .toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertNotEquals(receiveDiscards, responseData);
+ }
+
+ @Test
public void testAttrAdd() {
final JSONObject jsonObject = getFileAsJsonObject();
@@ -304,6 +367,6 @@ public class TestConfigProcessor { System.out.println("responseData==" + responseData);
assertEquals("true", responseData);
- }
+ }
}
diff --git a/src/test/resources/measurement5x.json b/src/test/resources/measurement5x.json new file mode 100644 index 00000000..585ec370 --- /dev/null +++ b/src/test/resources/measurement5x.json @@ -0,0 +1,98 @@ + { + "VESversion":"v5", + "event": { + "commonEventHeader": { + "startEpochMicrosec": 1534868302434191, + "eventId": "measurementsForVfScaling_vAfx_127.0.0.1", + "nfcNamingCode": "AFX", + "reportingEntityId": "bgtnj05vmh01afx", + "eventType": "applicationVnf", + "priority": "Normal", + "version": 3, + "reportingEntityName": "AFXM", + "sequence": 0, + "domain": "measurementsForVfScaling", + "lastEpochMicrosec": 1534868602564759, + "eventName": "measurementsForVfScaling_vAfx", + "sourceName": "bgtnj05vmh01afx", + "nfNamingCode": "AFX" + }, + "measurementsForVfScalingFields": { + "cpuUsageArray": [{ + "cpuUsageNice": 0, + "percentUsage": 0.39, + "cpuIdentifier": "all", + "cpuIdle": 99.61, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.22 + }, { + "cpuUsageNice": 0, + "percentUsage": 0.36, + "cpuIdentifier": "cpu0", + "cpuIdle": 99.64, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.21 + }, { + "cpuUsageNice": 0, + "percentUsage": 0.34, + "cpuIdentifier": "cpu1", + "cpuIdle": 99.66, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.2 + }, { + "cpuUsageNice": 0, + "percentUsage": 0.52, + "cpuIdentifier": "cpu2", + "cpuIdle": 99.48, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.3 + }, { + "cpuUsageNice": 0, + "percentUsage": 0.33, + "cpuIdentifier": "cpu3", + "cpuIdle": 99.67, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.19 + }], + "measurementInterval": 300, + "measurementsForVfScalingVersion": 2, + "vNicPerformanceArray": [{ + "transmittedOctetsDelta": 1533682, + "receivedMulticastPacketsAccumulated": 0, + "receivedMulticastPacketsDelta": 0, + "receivedOctetsAccumulated": 1.215192543E9, + "receivedTotalPacketsDelta": 7988, + "vNicIdentifier": "ens2 DNS2_RSLOTPORT_VLAN_CLASSTYPE", + "valuesAreSuspect": "true", + "transmittedTotalPacketsDelta": 9326, + "transmittedTotalPacketsAccumulated": 7460880, + "receivedOctetsDelta": 548159, + "transmittedOctetsAccumulated": 1.055825979E9, + "receivedTotalPacketsAccumulated": 1.3555845E7 + }, { + "transmittedOctetsDelta": 0, + "receivedMulticastPacketsAccumulated": 0, + "receivedMulticastPacketsDelta": 0, + "receivedOctetsAccumulated": 5412138, + "receivedTotalPacketsDelta": 0, + "vNicIdentifier": "lo DNS1_RSLOTPORT_VLAN_CLASSTYPE", + "valuesAreSuspect": "true", + "transmittedTotalPacketsDelta": 0, + "transmittedTotalPacketsAccumulated": 53567, + "receivedOctetsDelta": 0, + "transmittedOctetsAccumulated": 5412138, + "receivedTotalPacketsAccumulated": 53567 + }], + "memoryUsageArray": [{ + "memorySlabUnrecl": 17560, + "memoryCached": 976988, + "memoryFree": 6446628, + "memorySlabRecl": 83908, + "memoryBuffered": 198020, + "memoryUsed": 353492, + "vmIdentifier": "RAM", + "memoryConfigured": 8076596 + }] + } + } + }
\ No newline at end of file diff --git a/src/test/resources/measurement7x.json b/src/test/resources/measurement7x.json new file mode 100644 index 00000000..6e9fd1f4 --- /dev/null +++ b/src/test/resources/measurement7x.json @@ -0,0 +1,107 @@ + { + "VESversion":"v7", + "event": { + "commonEventHeader": { + "startEpochMicrosec": 1534868302434191, + "eventId": "measurementsForVfScaling_vAfx_127.0.0.1", + "nfcNamingCode": "AFX", + "reportingEntityId": "bgtnj05vmh01afx", + "eventType": "applicationVnf", + "priority": "Normal", + "version": "4.0.1", + "reportingEntityName": "AFXM", + "sequence": 0, + "domain": "measurement", + "lastEpochMicrosec": 1534868602564759, + "eventName": "measurement", + "sourceName": "bgtnj05vmh01afx", + "nfNamingCode": "AFX", + "vesEventListenerVersion" : "7.0.1" + }, + "measurementFields": { + "cpuUsageArray": [{ + "cpuUsageNice": 0, + "percentUsage": 0.39, + "cpuIdentifier": "all", + "cpuIdle": 99.61, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.22, + "cpuCapacityContention": 0, + "cpuDemandAvg": 0, + "cpuDemandMhz": 0, + "cpuDemandPct": 0, + "cpuLatencyAvg": 0, + "cpuOverheadAvg": 0, + "cpuSwapWaitTime": 0 + + }, { + "cpuUsageNice": 0, + "percentUsage": 0.36, + "cpuIdentifier": "cpu0", + "cpuIdle": 99.64, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.21 + }, { + "cpuUsageNice": 0, + "percentUsage": 0.34, + "cpuIdentifier": "cpu1", + "cpuIdle": 99.66, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.2 + }, { + "cpuUsageNice": 0, + "percentUsage": 0.52, + "cpuIdentifier": "cpu2", + "cpuIdle": 99.48, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.3 + }, { + "cpuUsageNice": 0, + "percentUsage": 0.33, + "cpuIdentifier": "cpu3", + "cpuIdle": 99.67, + "cpuUsageSystem": 0, + "cpuUsageUser": 0.19 + }], + "measurementInterval": 300, + "measurementFieldsVersion": "4.0", + "nicPerformanceArray": [{ + "transmittedOctetsDelta": 1533682, + "receivedMulticastPacketsAccumulated": 0, + "receivedMulticastPacketsDelta": 0, + "receivedOctetsAccumulated": 1.215192543E9, + "receivedTotalPacketsDelta": 7988, + "nicIdentifier": "ens2 DNS2_RSLOTPORT_VLAN_CLASSTYPE", + "valuesAreSuspect": "true", + "transmittedTotalPacketsDelta": 9326, + "transmittedTotalPacketsAccumulated": 7460880, + "receivedOctetsDelta": 548159, + "transmittedOctetsAccumulated": 1.055825979E9, + "receivedTotalPacketsAccumulated": 1.3555845E7 + }, { + "transmittedOctetsDelta": 0, + "receivedMulticastPacketsAccumulated": 0, + "receivedMulticastPacketsDelta": 0, + "receivedOctetsAccumulated": 5412138, + "receivedTotalPacketsDelta": 0, + "nicIdentifier": "lo DNS1_RSLOTPORT_VLAN_CLASSTYPE", + "valuesAreSuspect": "true", + "transmittedTotalPacketsDelta": 0, + "transmittedTotalPacketsAccumulated": 53567, + "receivedOctetsDelta": 0, + "transmittedOctetsAccumulated": 5412138, + "receivedTotalPacketsAccumulated": 53567 + }], + "memoryUsageArray": [{ + "memorySlabUnrecl": 17560, + "memoryCached": 976988, + "memoryFree": 6446628, + "memorySlabRecl": 83908, + "memoryBuffered": 198020, + "memoryUsed": 353492, + "vmIdentifier": "RAM", + "memoryConfigured": 8076596 + }] + } + } + }
\ No newline at end of file |