sdnc common tasks returns response

fix the post200Test by returning the correct response
fix the unit test that expected the json response
fixed the sdnc common tasks to return json response

Change-Id: I80392cbd9aa90955c47661eeee6c605c213525e7
Issue-ID: SO-1296
Signed-off-by: Kalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
index fedec4f..58c6db1 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
@@ -32,6 +32,7 @@
 import org.springframework.stereotype.Component;
 
 import com.jayway.jsonpath.JsonPath;
+import com.jayway.jsonpath.PathNotFoundException;
  
 @Component
 public class SDNCRequestTasks {
@@ -61,6 +62,9 @@
 			String response = sdncClient.post(request.getSDNCPayload(),request.getTopology());
 			String finalMessageIndicator = JsonPath.read(response, "$.output.ack-final-indicator");		
 			execution.setVariable("isSDNCCompleted", convertIndicatorToBoolean(finalMessageIndicator));
+		} catch(PathNotFoundException e) {
+			logger.error("Error Parsing SDNC Response", e);
+			exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Error Parsing SDNC Response");
 		} catch (MapperException e) {
 			logger.error("Error Parsing SDNC Response", e);
 			exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Error Parsing SDNC Response");
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
index 37e13fb..13ba107 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
@@ -105,12 +105,20 @@
         	responseCode = (String) embeddedResponse.get(RESPONSE_CODE);
             responseMessage = (String) embeddedResponse.get(RESPONSE_MESSAGE);
         }
-        
+        ObjectMapper objMapper = new ObjectMapper();
+        String jsonResponse;
+		try {
+			jsonResponse = objMapper.writeValueAsString(output);
+			msoLogger.debug(jsonResponse);
+		} catch (JsonProcessingException e) {
+			msoLogger.warnSimple("Could not convert SDNC Response to String", e);
+			jsonResponse = "";
+		}
 		msoLogger.info("ResponseCode: " + responseCode + " ResponseMessage: " + responseMessage);
 		int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0;
 		if (isHttpCodeSuccess(code)) {
 			msoLogger.info("Successful Response from SDNC");
-			return responseMessage;
+			return jsonResponse;
 		} else {
 			String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage);
 			msoLogger.error(MessageEnum.RA_RESPONSE_FROM_SDNC, errorMessage, "BPMN", MsoLogger.getServiceName(),
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
index e30fe66..2636aec 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java
@@ -60,12 +60,13 @@
 
     @Test
     public void validateSDNResponseTest() throws BadResponseException {
+    	String jsonResponse = "{\"output\":{\"response-code\":\"0\",\"response-message\":\"success\"}}";
         LinkedHashMap<String, Object> responseMap = new LinkedHashMap<>();
         LinkedHashMap<String, Object> output = new LinkedHashMap<>();
         output.put("response-code", "0");
         output.put("response-message", "success");
         responseMap.put("output", output);
-        assertEquals("success", sdnCommonTasks.validateSDNResponse(responseMap));
+        assertEquals(jsonResponse, sdnCommonTasks.validateSDNResponse(responseMap));
     }
 
     @Test
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
index cc1c5c5..9117b8e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java
@@ -77,6 +77,6 @@
                         .withHeader("Content-Type", "application/json").withBody(responseJson)));
     	
         String response = SPY_sdncClient.post("", SDNCTopology.NETWORK);
-        JSONAssert.assertEquals("", response, false);
+        JSONAssert.assertEquals(responseJson, response, true);
     }
 }