added test case to ResponseHandlerTest.java 69/66969/4
authorSandeep J <sandeejh@in.ibm.com>
Mon, 17 Sep 2018 11:24:52 +0000 (16:54 +0530)
committerSandeep Jha <sandeejh@in.ibm.com>
Tue, 18 Sep 2018 15:56:18 +0000 (15:56 +0000)
to increase code coverage

Issue-ID: SO-153
Change-Id: I0829b1c49756eb5f30a618d3ef7d22dbb242126d
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/ResponseHandlerTest.java

index 117c8a2..0d4778b 100644 (file)
@@ -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>xml</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 = "<test:service-response xmlns:test=\"http://org.onap/so/test\">"
@@ -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, "<html>error</html>", "text/html");
         ResponseHandler respHandler = new ResponseHandler (response, 1);