From 2de7bd87825a2d743c0756d6ed44d744a757cdff Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Thu, 30 Aug 2018 17:57:18 +0900 Subject: increase coverage for restAdaptor HTTP_DELETE Issue-ID: APPC-1181 Change-Id: I50eead8d40c692cd9674fdc2f1f3ed63c9f9031a Signed-off-by: Ganesh Chandrasekaran --- .../adapter/rest/impl/TestRestAdapterImpl.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src') 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 e0fdd7924..387b6a5f9 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 @@ -161,6 +161,39 @@ public class TestRestAdapterImpl { assertEquals("http://example.com:8081/deletetest", httpDelete.getURI().toURL().toString()); } + @Test + public void testCreateRequestNoParamDelete() throws IOException, IllegalStateException, IllegalArgumentException, + ZoneException, APPCException { + + SvcLogicContext ctx = new SvcLogicContext(); + Map params = new HashMap<>(); + + adapter.commonDelete(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 testCreateRequestInvalidParamDelete() throws IOException, IllegalStateException, IllegalArgumentException, + ZoneException, APPCException { + + SvcLogicContext ctx = new SvcLogicContext(); + Map 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.commonDelete(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")); + } + private HttpRequestBase givenParams(Map params, String method){ SvcLogicContext ctx = new SvcLogicContext(); RequestContext rc = new RequestContext(ctx); -- cgit 1.2.3-korg