X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=bpmn%2Fmso-infrastructure-bpmn%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fso%2Fbpmn%2Fcommon%2FReceiveWorkflowMessageTest.java;h=d8e3264091b38e95de6caceede8abc042c32404d;hb=f47919f1fe367b612fa9c96d34c59f01a541e882;hp=7f3e884601bbbbbefe221ec457365a6deb3f4dda;hpb=54452b80a1cf4d22ef750bc1377f8c1b05431d57;p=so.git diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ReceiveWorkflowMessageTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ReceiveWorkflowMessageTest.java index 7f3e884601..d8e3264091 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ReceiveWorkflowMessageTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ReceiveWorkflowMessageTest.java @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - + package org.onap.so.bpmn.common; import static org.junit.Assert.assertEquals; @@ -25,12 +25,10 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.UUID; - import org.camunda.bpm.engine.test.Deployment; import org.junit.Ignore; import org.junit.Test; @@ -44,102 +42,85 @@ import org.onap.so.bpmn.core.WorkflowException; @Ignore public class ReceiveWorkflowMessageTest extends WorkflowTest { - private static final String EOL = "\n"; - - private final CallbackSet callbacks = new CallbackSet(); - - public ReceiveWorkflowMessageTest() throws IOException { - callbacks.put("sdnc-event-success", JSON, "SDNCAEvent", - "{" + EOL + - " \"SDNCEvent\": {" + EOL + - " \"eventType\": \"evenType\"," + EOL + - " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL + - " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + - " \"params\": {" + EOL + - " \"success-indicator\":\"Y\"" + EOL + - " }" +EOL + - " }" + EOL + - "}" + EOL); - - callbacks.put("sdnc-event-fail", JSON, "SDNCAEvent", - "{" + EOL + - " \"SDNCEvent\": {" + EOL + - " \"eventType\": \"evenType\"," + EOL + - " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL + - " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + - " \"params\": {" + EOL + - " \"success-indicator\":\"N\"," + EOL + - " \"error-message\":\"SOMETHING BAD HAPPENED\"" + EOL + - " }" +EOL + - " }" + EOL + - "}" + EOL); - } - - /** - * Test the happy path. - */ - @Test - @Deployment(resources = { - "subprocess/ReceiveWorkflowMessage.bpmn" - }) - public void happyPath() throws Exception { - - logStart(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312"); - variables.put("isDebugLogEnabled", "true"); - variables.put("RCVWFMSG_timeout", "PT1M"); - variables.put("RCVWFMSG_messageType", "SDNCAEvent"); - variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31"); - - invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables); - injectWorkflowMessages(callbacks, "sdnc-event-success"); - waitForProcessEnd(businessKey, 10000); - - String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse"); - System.out.println("Response:\n" + response); - assertTrue(response.contains("\"SDNCEvent\"")); - assertTrue((boolean)getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator")); - - logEnd(); - } - - /** - * Test the timeout scenario. - */ - @Test - @Deployment(resources = { - "subprocess/ReceiveWorkflowMessage.bpmn" - }) - public void timeout() throws Exception { - - logStart(); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap<>(); - variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312"); - variables.put("isDebugLogEnabled", "true"); - variables.put("RCVWFMSG_timeout", "PT5S"); - variables.put("RCVWFMSG_messageType", "SDNCAEvent"); - variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31"); - - invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables); - - // No injection - - waitForProcessEnd(businessKey, 10000); - - // There is no response from SDNC, so the flow doesn't set WorkflowResponse. - String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse"); - assertNull(response); - WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - assertNotNull(wfe); - System.out.println(wfe.toString()); - assertEquals("Receive Workflow Message Timeout Error", wfe.getErrorMessage()); - assertFalse((boolean)getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator")); - - logEnd(); - } + private static final String EOL = "\n"; + + private final CallbackSet callbacks = new CallbackSet(); + + public ReceiveWorkflowMessageTest() throws IOException { + callbacks.put("sdnc-event-success", JSON, "SDNCAEvent", + "{" + EOL + " \"SDNCEvent\": {" + EOL + " \"eventType\": \"evenType\"," + EOL + + " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL + + " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + " \"params\": {" + EOL + + " \"success-indicator\":\"Y\"" + EOL + " }" + EOL + " }" + EOL + "}" + EOL); + + callbacks.put("sdnc-event-fail", JSON, "SDNCAEvent", "{" + EOL + " \"SDNCEvent\": {" + EOL + + " \"eventType\": \"evenType\"," + EOL + " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL + + " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + " \"params\": {" + EOL + + " \"success-indicator\":\"N\"," + EOL + " \"error-message\":\"SOMETHING BAD HAPPENED\"" + + EOL + " }" + EOL + " }" + EOL + "}" + EOL); + } + + /** + * Test the happy path. + */ + @Test + @Deployment(resources = {"subprocess/ReceiveWorkflowMessage.bpmn"}) + public void happyPath() throws Exception { + + logStart(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312"); + variables.put("isDebugLogEnabled", "true"); + variables.put("RCVWFMSG_timeout", "PT1M"); + variables.put("RCVWFMSG_messageType", "SDNCAEvent"); + variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31"); + + invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables); + injectWorkflowMessages(callbacks, "sdnc-event-success"); + waitForProcessEnd(businessKey, 10000); + + String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse"); + System.out.println("Response:\n" + response); + assertTrue(response.contains("\"SDNCEvent\"")); + assertTrue((boolean) getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator")); + + logEnd(); + } + + /** + * Test the timeout scenario. + */ + @Test + @Deployment(resources = {"subprocess/ReceiveWorkflowMessage.bpmn"}) + public void timeout() throws Exception { + + logStart(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312"); + variables.put("isDebugLogEnabled", "true"); + variables.put("RCVWFMSG_timeout", "PT5S"); + variables.put("RCVWFMSG_messageType", "SDNCAEvent"); + variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31"); + + invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables); + + // No injection + + waitForProcessEnd(businessKey, 10000); + + // There is no response from SDNC, so the flow doesn't set WorkflowResponse. + String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse"); + assertNull(response); + WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + assertNotNull(wfe); + System.out.println(wfe.toString()); + assertEquals("Receive Workflow Message Timeout Error", wfe.getErrorMessage()); + assertFalse((boolean) getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator")); + + logEnd(); + } }