Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-api-handlers / mso-api-handler-common / src / test / java / org / onap / so / apihandler / common / ResponseHandlerTest.java
index 0d4778b..2095a91 100644 (file)
@@ -19,7 +19,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.so.apihandler.common;
 
 
@@ -28,7 +28,6 @@ import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.startsWith;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.ProtocolVersion;
@@ -46,100 +45,98 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException;
  * 
  *
  */
-public class ResponseHandlerTest{
+public class ResponseHandlerTest {
 
     @Rule
     public ExpectedException thrown = ExpectedException.none();
 
     @Test
-    public void tesParseCamundaResponse () throws ApiException {
+    public void tesParseCamundaResponse() throws ApiException {
         // String body
         // ="{\"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}";
 
         String body = "{ \"response\": \"<xml>xml</xml>\"," + "\"messageCode\": 200,"
-                      + "\"message\": \"Successfully started the process\"}";
+                + "\"message\": \"Successfully started the process\"}";
 
-        HttpResponse response = createResponse (200, body, "application/json");
+        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");
+        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\"}";
+    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");
 
-        HttpResponse response = createResponse (200, body, "application/json");
+        ResponseHandler respHandler = new ResponseHandler(response, 2);
 
-        ResponseHandler respHandler = new ResponseHandler (response, 2);
-        
-        int status = respHandler.getStatus ();
-        assertEquals (status, HttpStatus.SC_ACCEPTED);
-        assertEquals (respHandler.getResponseBody(), body);
+        int status = respHandler.getStatus();
+        assertEquals(status, HttpStatus.SC_ACCEPTED);
+        assertEquals(respHandler.getResponseBody(), body);
 
     }
+
     @Test
-    public void tesParseBpelResponse () throws ApiException{
+    public void tesParseBpelResponse() throws ApiException {
         String body = "<test:service-response xmlns:test=\"http://org.onap/so/test\">"
-                      + "<test:request-id>req5</test:request-id>"
-                      + "<test:request-action>test</test:request-action>"
-                      + "<test:source>test</test:source>"
-                      + "<test:ack-final-indicator>n</test:ack-final-indicator>"
-                      + "</test:service-response>";
+                + "<test:request-id>req5</test:request-id>" + "<test:request-action>test</test:request-action>"
+                + "<test:source>test</test:source>" + "<test:ack-final-indicator>n</test:ack-final-indicator>"
+                + "</test:service-response>";
 
-        HttpResponse response = createResponse (200, body, "text/xml");
+        HttpResponse response = createResponse(200, body, "text/xml");
 
-        ResponseHandler respHandler = new ResponseHandler (response, 0);
+        ResponseHandler respHandler = new ResponseHandler(response, 0);
 
-        int status = respHandler.getStatus ();
-        assertEquals (status, HttpStatus.SC_ACCEPTED);
-        assertTrue (respHandler.getResponseBody () != null);
+        int status = respHandler.getStatus();
+        assertEquals(status, HttpStatus.SC_ACCEPTED);
+        assertTrue(respHandler.getResponseBody() != null);
     }
 
     @Test
-    public void tesMappingErrorResponse () throws ApiException {
+    public void tesMappingErrorResponse() throws ApiException {
         thrown.expect(ValidateException.class);
         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);
 
-        int status = respHandler.getStatus ();
+        HttpResponse response = createResponse(HttpStatus.SC_NOT_FOUND, "<html>error</html>", "text/html");
+        ResponseHandler respHandler = new ResponseHandler(response, 1);
+
+        int status = respHandler.getStatus();
 
-        assertEquals (HttpStatus.SC_NOT_IMPLEMENTED, status);
+        assertEquals(HttpStatus.SC_NOT_IMPLEMENTED, status);
 
     }
 
     @Test
-    public void tesGenricErrorResponse () throws ApiException {
+    public void tesGenricErrorResponse() throws ApiException {
 
         String body = "{ \"response\": \"<xml>xml</xml>\"," + "\"messageCode\": 500,"
-                      + "\"message\": \"Something went wrong\"}";
+                + "\"message\": \"Something went wrong\"}";
 
-        HttpResponse response = createResponse (500, body, "application/json");
-        ResponseHandler respHandler = new ResponseHandler (response, 1);
-        int status = respHandler.getStatus ();
-        assertEquals (status, HttpStatus.SC_BAD_GATEWAY);
-        assertEquals (respHandler.getResponse ().getMessage (), "Something went wrong");
+        HttpResponse response = createResponse(500, body, "application/json");
+        ResponseHandler respHandler = new ResponseHandler(response, 1);
+        int status = respHandler.getStatus();
+        assertEquals(status, HttpStatus.SC_BAD_GATEWAY);
+        assertEquals(respHandler.getResponse().getMessage(), "Something went wrong");
     }
 
-    private HttpResponse createResponse (int respStatus, String respBody, String contentType) {
-        HttpResponse response = new BasicHttpResponse (new BasicStatusLine (new ProtocolVersion ("HTTP", 1, 1),
-                                                                            respStatus,
-                                                                            ""));
-        response.setStatusCode (respStatus);
+    private HttpResponse createResponse(int respStatus, String respBody, String contentType) {
+        HttpResponse response =
+                new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), respStatus, ""));
+        response.setStatusCode(respStatus);
         try {
-            response.setEntity (new StringEntity (respBody));
-            response.setHeader ("Content-Type", contentType);
+            response.setEntity(new StringEntity(respBody));
+            response.setHeader("Content-Type", contentType);
         } catch (Exception e) {
-            e.printStackTrace ();
+            e.printStackTrace();
         }
         return response;
     }