aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-08-30 18:00:27 +0900
committerTakamune Cho <tc012c@att.com>2018-09-05 18:59:53 +0000
commit71c7a87ad665e900b89d231d7b4ec590e9187d9d (patch)
tree9e6ca310035c99a07d5cf4506ab0de9b4ec4a8aa /appc-adapters
parentf5035002126910aeba60cdcd070290696c3f2942 (diff)
increase coverage for restAdaptor HTTP_POST
Issue-ID: APPC-1181 Change-Id: If92c903fa520e1a609d4e4558241709a2b3f6439 Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
Diffstat (limited to 'appc-adapters')
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/adapter/rest/impl/TestRestAdapterImpl.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/adapter/rest/impl/TestRestAdapterImpl.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/adapter/rest/impl/TestRestAdapterImpl.java
index 6ddfe8817..b4c96d5d5 100644
--- a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/adapter/rest/impl/TestRestAdapterImpl.java
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/adapter/rest/impl/TestRestAdapterImpl.java
@@ -129,6 +129,39 @@ public class TestRestAdapterImpl {
assertEquals("http://example.com:8081/posttest", httpPost.getURI().toURL().toString());
assertEquals("{\"name\":\"MyNode\", \"width\":200, \"height\":100}", EntityUtils.toString(httpPost.getEntity()));
}
+
+ @Test
+ public void testCreateRequestNoParamPost() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+
+ adapter.commonPost(params, ctx);
+
+ assertEquals("failure", ctx.getStatus());
+ assertEquals("500", ctx.getAttribute("org.openecomp.rest.result.code"));
+ assertEquals("java.lang.IllegalArgumentException: HTTP request may not be null",
+ ctx.getAttribute("org.openecomp.rest.result.message"));
+ }
+
+ @Test
+ public void testCreateRequestInvalidParamPost() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+ params.put("org.onap.appc.instance.URI", "boo");
+ params.put("org.onap.appc.instance.haveHeader","false");
+ params.put("org.onap.appc.instance.requestBody", "{\"name\":\"MyNode2\", \"width\":300, \"height\":300}");
+
+ adapter.commonPost(params, ctx);
+
+ assertEquals("failure", ctx.getStatus());
+ assertEquals("500", ctx.getAttribute("org.openecomp.rest.result.code"));
+ assertEquals("org.apache.http.client.ClientProtocolException",
+ ctx.getAttribute("org.openecomp.rest.result.message"));
+ }
@Test
public void testCreateHttpRequestPut() throws IOException, IllegalStateException, IllegalArgumentException,