summaryrefslogtreecommitdiffstats
path: root/restapi-call-node/provider/src/test/java
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-09-21 14:45:41 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-21 14:45:41 +0000
commit89fa6ae72d5085295b917d48e6cbe0566ebe2fc7 (patch)
tree9e55ca27c85c262c65838e71f715deb7db752201 /restapi-call-node/provider/src/test/java
parente599a8ec658120298ed16a1e9e47e23c485cde6b (diff)
parent72e394582ceeb86e35d2c5cb34b244b38ae5659f (diff)
Merge "Refinements and test additions to XmlParser"
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/TestXmlParser.java46
1 files changed, 46 insertions, 0 deletions
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 e8567d591..c6bf4a8b9 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
@@ -21,6 +21,9 @@
package jtest.org.onap.ccsdk.sli.plugins.restapicall;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
@@ -31,6 +34,7 @@ import java.util.Map;
import java.util.Set;
import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.plugins.restapicall.XmlParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,6 +66,48 @@ public class TestXmlParser {
in.close();
}
+ @Test
+ public void testValidLength() throws Exception {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Set<String> listNameList = new HashSet<String>();
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport");
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport");
+
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
+
+ assertThat(mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[5]"), is("SET_RESET_LP"));
+ assertThat(mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport[0]"), is("SET_BVOIP_IN"));
+
+ logProperties(mm);
+ in.close();
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testInvalidLength() throws Exception {
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(ClassLoader.getSystemResourceAsStream("invalidlength.xml"))
+ );
+ StringBuilder b = new StringBuilder();
+ String line;
+ while ((line = in.readLine()) != null)
+ b.append(line).append('\n');
+
+ Set<String> listNameList = new HashSet<String>();
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport");
+ listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport");
+
+ Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList);
+ logProperties(mm);
+ in.close();
+ }
+
private void logProperties(Map<String, String> mm) {
List<String> ll = new ArrayList<>();
for (Object o : mm.keySet())