From 013c69bcf6fe8b2f87e06149f4de33fbbb904a57 Mon Sep 17 00:00:00 2001 From: Abhishek Shekhar Date: Tue, 27 Mar 2018 18:14:25 +0530 Subject: UT Coverage for API Handler Change-Id: I7bde5bf105ecda5404875edd8de953e3d1f9d1ff Issue-ID: SO-369 Signed-off-by: Abhishek Shekhar --- .../mso/camunda/tests/CamundaClientTest.java | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp') diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java index d204afe93c..8bfc4ced76 100644 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java @@ -24,6 +24,7 @@ package org.openecomp.mso.camunda.tests; import static org.junit.Assert.assertEquals; import java.io.IOException; +import java.util.UUID; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -67,8 +68,6 @@ public class CamundaClientTest { @Test public void tesCamundaPost() throws JsonGenerationException, JsonMappingException, IOException { - - String responseBody ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; HttpResponse mockResponse = createResponse(200, responseBody); @@ -99,6 +98,30 @@ public class CamundaClientTest { assertEquals(statusCode, HttpStatus.SC_OK); } + @Test + public void testCamundaPostJson() throws IOException { + String responseBody ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; + + HttpResponse mockResponse = createResponse(200, responseBody); + mockHttpClient = Mockito.mock(HttpClient.class); + Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) + .thenReturn(mockResponse); + + String reqXML = "test"; + String orchestrationURI = "/engine-rest/process-definition/key/dummy/start"; + + MsoJavaProperties props = new MsoJavaProperties(); + props.setProperty(CommonConstants.CAMUNDA_URL, "http://localhost:8089"); + + RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); + requestClient.setClient(mockHttpClient); + HttpResponse response = requestClient.post("mso-req-id", false, 180, + "createInstance", "svc-inst-id", "vnf-id", "vf-module-id", "vg-id", "nw-id", "conf-id", "svc-type", + "vnf-type", "vf-module-type", "nw-type", "", ""); + assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); + assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_OK); + } + private HttpResponse createResponse(int respStatus, String respBody) { HttpResponse response = new BasicHttpResponse( -- cgit 1.2.3-korg