summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>2019-05-22 16:34:44 +0000
committerKevin Smokowski <kevin.smokowski@att.com>2019-05-22 18:44:50 +0000
commitc75880b15cebc206d43721b35299453f49406f20 (patch)
tree4ba29ff7901c825c191930cd7bca860e8136c547
parent06c30ec3fa1dbdf26b7e1abce89c68e3efc632c7 (diff)
rest api call node unit tests
rest api call node unit test added for the case in which a template mixes simple and complex json objects. Change-Id: I6921d6e328b3593464d82b7a45b1844cd88c3476 Issue-ID: CCSDK-1355 Signed-off-by: Smokowski, Kevin (ks6305) <kevin.smokowski@att.com>
-rw-r--r--restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java (renamed from restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java)2
-rw-r--r--restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java (renamed from restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java)2
-rw-r--r--restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java (renamed from restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java)2
-rw-r--r--restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java (renamed from restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java)19
-rw-r--r--restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java (renamed from restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java)2
-rw-r--r--restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java (renamed from restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java)2
-rw-r--r--restapi-call-node/provider/src/test/resources/testEmbeddedTemplate.json20
7 files changed, 43 insertions, 6 deletions
diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java
index b4a30d3a..7e1e0d50 100644
--- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java
+++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MockCookieAuthServer.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package jtest.org.onap.ccsdk.sli.plugins.restapicall;
+package org.onap.ccsdk.sli.plugins.restapicall;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java
index 9646272b..00b5c324 100644
--- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java
+++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/MultipartServerMock.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package jtest.org.onap.ccsdk.sli.plugins.restapicall;
+package org.onap.ccsdk.sli.plugins.restapicall;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
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/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java
index 5526be81..e4ec9147 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/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package jtest.org.onap.ccsdk.sli.plugins.restapicall;
+package org.onap.ccsdk.sli.plugins.restapicall;
import java.io.BufferedReader;
import java.io.IOException;
diff --git a/restapi-call-node/provider/src/test/java/jtest/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 3752a9c3..bdf67dc4 100644
--- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
+++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
@@ -19,13 +19,14 @@
* ============LICENSE_END=========================================================
*/
-package jtest.org.onap.ccsdk.sli.plugins.restapicall;
+package org.onap.ccsdk.sli.plugins.restapicall;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import java.net.URI;
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;
@@ -721,4 +722,20 @@ public class TestRestapiCallNode {
assertThat(ctx.getAttribute("header.Set-Cookie"), is("cookieResponse=cookieValueInReturn;Version=1"));
server.shutdownNow();
}
+
+ @Test
+ public void testEmbeddedJsonTemplate() throws Exception {
+ SvcLogicContext ctx = new SvcLogicContext();
+ String complexObj = "{\"image_name\":\"Ubuntu 14.04\",\"service-instance-id\":\"1\",\"vnf-model-customization-uuid\":\"2f\",\"vnf-id\":\"3b\"}";
+ ctx.setAttribute("reqId", "1235");
+ ctx.setAttribute("subReqId", "054243");
+ ctx.setAttribute("actionName", "CREATE");
+ ctx.setAttribute("myPrefix", "2016-09-09 16:30:35.0");
+ ctx.setAttribute("complexObj", complexObj);
+ RestapiCallNode rcn = new RestapiCallNode();
+ String request = rcn.buildXmlJsonRequest(ctx, rcn.readFile("src/test/resources/testEmbeddedTemplate.json"), Format.JSON);
+ //This will throw a JSONException and fail the test case if rest api call node doesn't form valid JSON
+ JSONObject requestObj = new JSONObject(request);
+ }
+
}
diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java
index 11eeba7f..9812f2a1 100644
--- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java
+++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package jtest.org.onap.ccsdk.sli.plugins.restapicall;
+package org.onap.ccsdk.sli.plugins.restapicall;
import java.util.HashMap;
import java.util.Map;
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/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java
index c6bf4a8b..326c9ca8 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/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package jtest.org.onap.ccsdk.sli.plugins.restapicall;
+package org.onap.ccsdk.sli.plugins.restapicall;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
diff --git a/restapi-call-node/provider/src/test/resources/testEmbeddedTemplate.json b/restapi-call-node/provider/src/test/resources/testEmbeddedTemplate.json
new file mode 100644
index 00000000..7f237781
--- /dev/null
+++ b/restapi-call-node/provider/src/test/resources/testEmbeddedTemplate.json
@@ -0,0 +1,20 @@
+{
+ "commonHeader": {
+ "origin": "earth",
+ "requestId": ${reqId},
+ "subRequestId": ${subReqId}
+ },
+ "actions": {
+ "actionName": ${actionName},
+ "mode": "sync"
+ },
+ "payload": {
+ "assignment-request": {
+ "prefix": [
+ ${myPrefix}
+ ],
+ "assignment-properties": ${'"complexObj}
+ }
+ }
+}
+