summaryrefslogtreecommitdiffstats
path: root/restapi-call-node
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-05-24 15:18:57 +0000
committerGerrit Code Review <gerrit@onap.org>2019-05-24 15:18:57 +0000
commitb9ee871047eadd4c151adeeba97265431c8da616 (patch)
tree52e906b8611e4ccfa305c909fd491a11dda1ec60 /restapi-call-node
parentbea0f101d0a4c7d1fbe8cb9d4a27491ba7d66dbf (diff)
parentc75880b15cebc206d43721b35299453f49406f20 (diff)
Merge "rest api call node unit tests"
Diffstat (limited to 'restapi-call-node')
-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 b4a30d3ab..7e1e0d505 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 9646272b4..00b5c324d 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 5526be81f..e4ec9147c 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 3752a9c3f..bdf67dc45 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 11eeba7f0..9812f2a11 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 c6bf4a8b9..326c9ca89 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 000000000..7f2377813
--- /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}
+ }
+ }
+}
+