summaryrefslogtreecommitdiffstats
path: root/restapi-call-node/provider/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'restapi-call-node/provider/src/test/java')
-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
2 files changed, 17 insertions, 13 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 dbca5ad7..5526be81 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 544d259e..e8567d59 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();
}