X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=appc-adapters%2Fappc-rest-adapter%2Fappc-rest-adapter-bundle%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fappc%2Fadapter%2Frest%2Fimpl%2FTestRestAdapterImpl.java;h=e0fdd792405f865db86c031de234cdbca665ba28;hb=726d7d621d21215e3822a31fbbc8a6091d7697ea;hp=ca5a89874653254ad0c994dc4495ba15d224f0af;hpb=875d836aeff308645ce59daf0ca59b77e0f13940;p=appc.git 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 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 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 {