summaryrefslogtreecommitdiffstats
path: root/pomba/network-discovery/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'pomba/network-discovery/src/test')
-rw-r--r--pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java2
-rw-r--r--pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/util/TransformationUtilTest.java65
-rw-r--r--pomba/network-discovery/src/test/resources/jolt/l3network-expected.json51
-rw-r--r--pomba/network-discovery/src/test/resources/jolt/vserver-expected.json80
4 files changed, 118 insertions, 80 deletions
diff --git a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java
index 31b1abe..39239e9 100644
--- a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java
+++ b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java
@@ -213,7 +213,7 @@ public class NetworkDiscoveryTest {
@Test
public void testDiscoverVserver() throws Exception {
- String vserverId = UUID.randomUUID().toString();
+ String vserverId = "2c311eae-f542-4173-8a01-582922abd495";
String resourcePath = MessageFormat.format("/v2.1/servers/{0}",
new Object[] { vserverId });
diff --git a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/util/TransformationUtilTest.java b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/util/TransformationUtilTest.java
index dc4775f..f43fa60 100644
--- a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/util/TransformationUtilTest.java
+++ b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/util/TransformationUtilTest.java
@@ -18,21 +18,15 @@
package org.onap.sdnc.apps.pomba.networkdiscovery.unittest.service.util;
-import static org.junit.Assert.assertThat;
-
import com.bazaarvoice.jolt.JsonUtils;
import com.bazaarvoice.jolt.exception.JsonUnmarshalException;
+import com.google.gson.Gson;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Attribute;
+import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Resource;
import org.onap.sdnc.apps.pomba.networkdiscovery.service.util.TransformationUtil;
public class TransformationUtilTest {
@@ -49,11 +43,15 @@ public class TransformationUtilTest {
String resultJson = TransformationUtil.transform(JsonUtils.toJsonString(sourceObject), "vserver");
+ Gson gson = new Gson();
+ Resource resourceInst = gson.fromJson(resultJson, Resource.class);
+ String resourceInstJson = gson.toJson(resourceInst);
+
Object expectedObject = JsonUtils.filepathToObject(TEST_RESOURCES + "vserver-expected.json");
Assert.assertEquals("Json transformation result does not match expected content",
JsonUtils.toPrettyJsonString(expectedObject),
- JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(resultJson)));
+ JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(resourceInstJson)));
}
@@ -63,11 +61,15 @@ public class TransformationUtilTest {
Object sourceObject = JsonUtils.filepathToObject(TEST_RESOURCES + "l3network-input.json");
String resultJson = TransformationUtil.transform(JsonUtils.toJsonString(sourceObject), "l3-network");
+ Gson gson = new Gson();
+ Resource resourceInst = gson.fromJson(resultJson, Resource.class);
+ String resourceInstJson = gson.toJson(resourceInst);
+
Object expectedObject = JsonUtils.filepathToObject(TEST_RESOURCES + "l3network-expected.json");
Assert.assertEquals("Json transformation result does not match expected content",
JsonUtils.toPrettyJsonString(expectedObject),
- JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(resultJson)));
+ JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(resourceInstJson)));
}
@@ -89,47 +91,4 @@ public class TransformationUtilTest {
TransformationUtil.transform("xxx", "foobar");
}
- @Test
- public void testToAttributeList() {
- Map<String, String> expectedAttributes = new HashMap<String, String>();
- expectedAttributes.put("name", "norm_bouygues");
- expectedAttributes.put("hostId", "ea1660efbbedda164379afacdc622305c4b88cebfb84119472d286a8");
- expectedAttributes.put("hostStatus", "UP");
- expectedAttributes.put("id", "2c311eae-f542-4173-8a01-582922abd495");
- expectedAttributes.put("status", "ACTIVE");
- expectedAttributes.put("vmState", "active");
- expectedAttributes.put("hostname", "norm-bouygues");
- expectedAttributes.put("inMaintenance", "true");
- expectedAttributes.put("imageId", "c0022890-d91f-422c-91c5-3866edeae768");
- expectedAttributes.put("tenantId", "15ad36d394e744838e947ca90609f805");
- expectedAttributes.put("host", "Setup-NCSO-OTT-E-C2");
-
- Object inputJson = JsonUtils.filepathToObject(TEST_RESOURCES + "vserver-expected.json");
- List<Attribute> resultAttributeList = TransformationUtil.toAttributeList(JsonUtils.toJsonString(inputJson));
-
- Map<String, String> resultAttributes = new HashMap<>();
-
- for (Attribute attribute : resultAttributeList) {
- resultAttributes.put(attribute.getName(), attribute.getValue());
- }
- assertThat(expectedAttributes, CoreMatchers.is(resultAttributes));
- }
-
- @Test
- public void testToAttributeListNullJsonValue() {
- Map<String, String> expectedAttributes = new HashMap<String, String>();
- expectedAttributes.put("name", "");
-
- String inputJson = "{\"server\": { \"name\": null }}";
-
- List<Attribute> resultAttributeList = TransformationUtil.toAttributeList(inputJson);
-
- Map<String, String> resultAttributes = new HashMap<>();
-
- for (Attribute attribute : resultAttributeList) {
- resultAttributes.put(attribute.getName(), attribute.getValue());
- }
- assertThat(expectedAttributes, CoreMatchers.is(resultAttributes));
- }
-
}
diff --git a/pomba/network-discovery/src/test/resources/jolt/l3network-expected.json b/pomba/network-discovery/src/test/resources/jolt/l3network-expected.json
index be4ad9d..e9e37dd 100644
--- a/pomba/network-discovery/src/test/resources/jolt/l3network-expected.json
+++ b/pomba/network-discovery/src/test/resources/jolt/l3network-expected.json
@@ -1,14 +1,39 @@
{
- "l3-network": {
- "id": "8df84f0a-737a-4628-be9c-c3c78454f9d9",
- "name": "NET_503",
- "AdminState": true,
- "sharedNetwork": true,
- "status": "ACTIVE",
- "subnets": [
- "d0e6ecad-7bc9-4138-b9e8-e742bdf9afd5"
- ],
- "tenantId": "c44b872f6830498b88c4989d67b2a6b7",
- "host-status": "UNKNOWN"
- }
-}
+ "id" : "8df84f0a-737a-4628-be9c-c3c78454f9d9",
+ "name" : "NET_503",
+ "type" : "l3-network",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ {
+ "name" : "adminState",
+ "value" : "true",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "sharedNetwork",
+ "value" : "true",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "status",
+ "value" : "ACTIVE",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "subnets",
+ "value" : "d0e6ecad-7bc9-4138-b9e8-e742bdf9afd5",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "tenantId",
+ "value" : "c44b872f6830498b88c4989d67b2a6b7",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ } ]
+} \ No newline at end of file
diff --git a/pomba/network-discovery/src/test/resources/jolt/vserver-expected.json b/pomba/network-discovery/src/test/resources/jolt/vserver-expected.json
index 53d4a79..2ad9f81 100644
--- a/pomba/network-discovery/src/test/resources/jolt/vserver-expected.json
+++ b/pomba/network-discovery/src/test/resources/jolt/vserver-expected.json
@@ -1,15 +1,69 @@
{
- "vserver" : {
- "id" : "2c311eae-f542-4173-8a01-582922abd495",
- "name" : "norm_bouygues",
- "inMaintenance" : true,
- "hostname" : "norm-bouygues",
- "imageId" : "c0022890-d91f-422c-91c5-3866edeae768",
- "status" : "ACTIVE",
- "vmState" : "active",
- "tenantId" : "15ad36d394e744838e947ca90609f805",
- "hostId" : "ea1660efbbedda164379afacdc622305c4b88cebfb84119472d286a8",
- "host" : "Setup-NCSO-OTT-E-C2",
- "hostStatus" : "UP"
- }
+ "id" : "2c311eae-f542-4173-8a01-582922abd495",
+ "name" : "norm_bouygues",
+ "type" : "vserver",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ {
+ "name" : "inMaintenance",
+ "value" : "true",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "hostname",
+ "value" : "norm-bouygues",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "imageId",
+ "value" : "c0022890-d91f-422c-91c5-3866edeae768",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "status",
+ "value" : "ACTIVE",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "vmState",
+ "value" : "active",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "userId",
+ "value" : "bdaf4fcde1574450bfa488b3221033d8",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "tenantId",
+ "value" : "15ad36d394e744838e947ca90609f805",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "hostId",
+ "value" : "ea1660efbbedda164379afacdc622305c4b88cebfb84119472d286a8",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "host",
+ "value" : "Setup-NCSO-OTT-E-C2",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "hostStatus",
+ "value" : "UP",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ } ]
} \ No newline at end of file