summaryrefslogtreecommitdiffstats
path: root/restapi-call-node/provider/src/test
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-09-19 23:58:40 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-19 23:58:40 +0000
commit4947ee3c0a6685eeb99d7fc9f0a159d135252f28 (patch)
tree66e109f875b8add6d6158ba1ffc565564820f1e1 /restapi-call-node/provider/src/test
parent369c9ebef1fa2b182789a1d75a448d1d5f89ffb2 (diff)
parent02e1594ffee2231523d0486a5d8b590ff09581df (diff)
Merge "Refinements to RestApiCall plugin"
Diffstat (limited to 'restapi-call-node/provider/src/test')
-rw-r--r--restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java20
-rw-r--r--restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java10
-rw-r--r--restapi-call-node/provider/src/test/resources/test.json5
3 files changed, 21 insertions, 14 deletions
diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java
index dbca5ad7b..5526be81f 100644
--- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java
+++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java
@@ -22,6 +22,7 @@
package jtest.org.onap.ccsdk.sli.plugins.restapicall;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,6 +30,7 @@ import java.util.List;
import java.util.Map;
import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.plugins.restapicall.JsonParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,30 +40,34 @@ public class TestJsonParser {
private static final Logger log = LoggerFactory.getLogger(TestJsonParser.class);
@Test
- public void test() throws Exception {
+ public void test() throws SvcLogicException, IOException {
BufferedReader in = new BufferedReader(
new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json"))
);
- String ss = "";
- String line = null;
+ StringBuilder b = new StringBuilder();
+ String line;
while ((line = in.readLine()) != null)
- ss += line + '\n';
+ b.append(line).append('\n');
- Map<String, String> mm = JsonParser.convertToProperties(ss);
+ Map<String, String> mm = JsonParser.convertToProperties(b.toString());
logProperties(mm);
in.close();
}
+ @Test(expected = NullPointerException.class)
+ public void testNullString() throws SvcLogicException {
+ JsonParser.convertToProperties(null);
+ }
+
private void logProperties(Map<String, String> mm) {
List<String> ll = new ArrayList<>();
for (Object o : mm.keySet())
ll.add((String) o);
Collections.sort(ll);
-
log.info("Properties:");
for (String name : ll)
- log.info("--- " + name + ": " + mm.get(name));
+ log.info("--- {}: {}", name, mm.get(name));
}
}
diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java
index 544d259e0..e8567d591 100644
--- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java
+++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java
@@ -44,10 +44,10 @@ public class TestXmlParser {
BufferedReader in = new BufferedReader(
new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml"))
);
- String ss = "";
- String line = null;
+ StringBuilder b = new StringBuilder();
+ String line;
while ((line = in.readLine()) != null)
- ss += line + '\n';
+ b.append(line).append('\n');
Set<String> listNameList = new HashSet<String>();
listNameList.add("project.dependencies.dependency");
@@ -57,10 +57,8 @@ public class TestXmlParser {
listNameList.add("project.build.pluginManagement." +
"plugins.plugin.configuration.lifecycleMappingMetadata.pluginExecutions.pluginExecution");
- Map<String, String> mm = XmlParser.convertToProperties(ss, listNameList);
-
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
logProperties(mm);
-
in.close();
}
diff --git a/restapi-call-node/provider/src/test/resources/test.json b/restapi-call-node/provider/src/test/resources/test.json
index a34f7e2a0..b48eb6b43 100644
--- a/restapi-call-node/provider/src/test/resources/test.json
+++ b/restapi-call-node/provider/src/test/resources/test.json
@@ -27,7 +27,10 @@
"number-primary-servers": "2",
"equipment-id": "Server1",
"server-model": "Unknown",
- "server-id": "Server1"
+ "server-id": "Server1",
+ "test-node" : {
+ "test-inner-node" : "Test-Value"
+ }
}
],
"resource-state": {