aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/adapter/rest/impl/TestRestAdapterImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/adapter/rest/impl/TestRestAdapterImpl.java')
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/adapter/rest/impl/TestRestAdapterImpl.java37
1 files changed, 36 insertions, 1 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 ca5a89874..e0fdd7924 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
@@ -8,6 +8,8 @@
* =============================================================================
* Copyright (C) 2017 Intel Corp.
* =============================================================================
+ * Modifications Copyright (C) 2018 Samsung
+ * ================================================================================
* 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
@@ -111,7 +113,40 @@ public class TestRestAdapterImpl {
assertEquals("http://example.com:8081/puttest", httpPut.getURI().toURL().toString());
assertEquals("{\"name\":\"MyNode2\", \"width\":300, \"height\":300}", EntityUtils.toString(httpPut.getEntity()));
}
-
+
+ @Test
+ public void testCreateRequestNoParamPut() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> params = new HashMap<>();
+
+ adapter.commonPut(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 testCreateRequestInvalidParamPut() 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.commonPut(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 testCreateHttpRequestDelete() throws IOException, IllegalStateException, IllegalArgumentException,
ZoneException, APPCException {