From 4ecf5ae18225d7792c337a42f1b57fbb599beda2 Mon Sep 17 00:00:00 2001 From: PATRACHARI Date: Thu, 23 Aug 2018 10:08:30 -0400 Subject: VES7.x to 5.x transformation Update transformation code based on Min's requirement. This includes all Measurement transformations. Issue-ID: DCAEGEN2-600 Change-Id: I082df846e159a4f158619e700a6dfed6de43cd95 Signed-off-by: PATRACHARI --- .../org/onap/dcae/vestest/TestConfigProcessor.java | 65 +++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'src/test/java/org') 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,7 +117,69 @@ 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() { @@ -304,6 +367,6 @@ public class TestConfigProcessor { System.out.println("responseData==" + responseData); assertEquals("true", responseData); - } + } } -- cgit 1.2.3-korg