From 6dc2a63d4ed8324058b4ee527ff438a6b97094d8 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Mon, 17 Sep 2018 16:54:52 +0530 Subject: added test case to ResponseHandlerTest.java to increase code coverage Issue-ID: SO-153 Change-Id: I0829b1c49756eb5f30a618d3ef7d22dbb242126d Signed-off-by: Sandeep J --- .../so/apihandler/common/ResponseHandlerTest.java | 30 ++++++++++++++-------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-common/src/test') diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/ResponseHandlerTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/ResponseHandlerTest.java index 117c8a2c27..0d4778b5b6 100644 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/ResponseHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/ResponseHandlerTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -17,7 +19,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - + package org.onap.so.apihandler.common; @@ -27,8 +29,6 @@ import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.io.IOException; - import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.ProtocolVersion; @@ -38,13 +38,7 @@ import org.apache.http.message.BasicStatusLine; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.onap.so.apihandler.common.ErrorNumbers; -import org.onap.so.apihandler.common.ResponseHandler; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; import org.onap.so.apihandlerinfra.exceptions.ApiException; -import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; /** @@ -68,13 +62,27 @@ public class ResponseHandlerTest{ HttpResponse response = createResponse (200, body, "application/json"); ResponseHandler respHandler = new ResponseHandler (response, 1); - + int status = respHandler.getStatus (); assertEquals (status, HttpStatus.SC_ACCEPTED); assertEquals (respHandler.getResponse ().getMessage (), "Successfully started the process"); } + + @Test + public void tesParseCamundaResponseForCamundaTaskType () throws ApiException { + String body = "{ \"response\": \"xml\"," + "\"messageCode\": 200," + + "\"message\": \"Successfully started the process\"}"; + HttpResponse response = createResponse (200, body, "application/json"); + + ResponseHandler respHandler = new ResponseHandler (response, 2); + + int status = respHandler.getStatus (); + assertEquals (status, HttpStatus.SC_ACCEPTED); + assertEquals (respHandler.getResponseBody(), body); + + } @Test public void tesParseBpelResponse () throws ApiException{ String body = "" @@ -99,7 +107,7 @@ public class ResponseHandlerTest{ thrown.expectMessage(startsWith("Cannot parse Camunda Response")); thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST))); thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); - + HttpResponse response = createResponse (HttpStatus.SC_NOT_FOUND, "error", "text/html"); ResponseHandler respHandler = new ResponseHandler (response, 1); -- cgit 1.2.3-korg