summaryrefslogtreecommitdiffstats
path: root/restapi-call-node/provider/src/test/java
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2019-12-19 11:07:59 -0500
committerSingal, Kapil (ks220y) <ks220y@att.com>2019-12-19 11:07:59 -0500
commitc185a9bf56303dc4ad9feb4ba5b6227a038f4153 (patch)
tree38cacc09ba79d7405569a75b4fba5476c51e67f7 /restapi-call-node/provider/src/test/java
parent767b8eac24dba80a8aa815879c13b721015b7ab4 (diff)
Fixing JSONParser for JSONArray element
Refactoring Related JUnit and fixing test JSON Files Change-Id: I1cd7ba04f53798e4b3f5451de6bfed24054d3ea5 Issue-ID: CCSDK-2008 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Diffstat (limited to 'restapi-call-node/provider/src/test/java')
-rw-r--r--restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java18
-rwxr-xr-xrestapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java15
2 files changed, 13 insertions, 20 deletions
diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java
index 21b66b22..569719d6 100644
--- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java
+++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -68,14 +68,7 @@ public class TestJsonParser {
String path = "src/test/resources/ArrayMenu.json";
String content = new String(Files.readAllBytes(Paths.get(path)));
Map<String, String> mm = JsonParser.convertToProperties(content);
- assertEquals("plain", mm.get("name"));
- assertEquals("true", mm.get("vegetarian"));
- assertEquals("1", mm.get("id"));
- assertEquals("1000", mm.get("calories"));
- assertEquals("pizza", mm.get("type"));
-
- // The below statements are how I expected it to work, but it does not work this way
-/*
+
assertEquals("1000", mm.get("[0].calories"));
assertEquals("1", mm.get("[0].id"));
assertEquals("plain", mm.get("[0].name"));
@@ -104,7 +97,6 @@ public class TestJsonParser {
assertEquals("pizza", mm.get("[2].type"));
assertEquals("true", mm.get("[2].vegetarian"));
assertEquals("3", mm.get("_length"));
-*/
}
@Test
@@ -222,8 +214,8 @@ public class TestJsonParser {
// Break the embedded json object into properties
mm = JsonParser.convertToProperties(mm.get("input.parameters[0].value"));
- assertEquals("0.2.0.0/16", mm.get("id"));
- // assertEquals("ge04::/64", mm.get("id")); this second value gets lost
+ assertEquals("0.2.0.0/16", mm.get("[0].id"));
+ assertEquals("ge04::/64", mm.get("[1].id"));
}
}
diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
index 0704d297..8cabaadc 100755
--- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
+++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
@@ -29,15 +29,11 @@ import java.util.HashMap;
import java.util.Map;
import org.codehaus.jettison.json.JSONObject;
-import org.glassfish.grizzly.http.server.HttpServer;
-import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
-import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,6 +42,11 @@ public class TestRestapiCallNode {
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class);
+ @Before
+ public void init() {
+ System.setProperty("SDNC_CONFIG_DIR", "src/test/resources");
+ }
+
@Test
public void testDelete() throws SvcLogicException {
SvcLogicContext ctx = new SvcLogicContext();
@@ -476,7 +477,7 @@ public class TestRestapiCallNode {
assertEquals(partnerTwoUsername,details.username);
assertEquals(partnerTwoPassword,details.password);
assertNull(rcn.partnerStore.get("partnerThree"));
-
+
//In this scenario the caller expects username, password and url to be picked up from the partners json
Map<String, String> paramMap = new HashMap<String,String>();
paramMap.put("partner", partnerTwoKey);
@@ -497,7 +498,7 @@ public class TestRestapiCallNode {
assertEquals(partnerTwoPassword,p.restapiPassword);
assertEquals("http://localhost:7002/networking/v1/instance/3",p.restapiUrl);
}
-
+
@Test
public void retryPolicyBean() throws Exception {
Integer retries = 3;