diff options
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn/src/test/java')
-rw-r--r-- | bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java | 166 |
1 files changed, 0 insertions, 166 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java index e71404a2ff..93f98a34a6 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java @@ -1384,172 +1384,6 @@ public abstract class WorkflowTest { } /** - * Runs a program to inject sniro workflow messages into the test environment. A program is essentially just a list - * of keys that identify event data to be injected, in sequence. For more details, see injectSNIROCallbacks(String - * contentType, String messageType, String content, long timeout) - * - * Errors are handled with junit assertions and will cause the test to fail. NOTE: Each callback must have a - * workflow message type associated with it. - * - * @param callbacks an object containing event data for the program - * @param program the program to execute - */ - protected void injectSNIROCallbacks(CallbackSet callbacks, String program) { - - String[] cmds = program.replaceAll("\\s+", "").split(","); - - for (String cmd : cmds) { - String action = cmd; - String modifier = "STD"; - - if (cmd.contains(":")) { - String[] parts = cmd.split(":"); - action = parts[0]; - modifier = parts[1]; - } - - String messageType = null; - String content = null; - String contentType = null; - - if ("STD".equals(modifier)) { - CallbackData callbackData = callbacks.get(action); - - if (callbackData == null) { - String msg = "No '" + action + "' workflow message callback is defined"; - logger.debug(msg); - fail(msg); - } - - messageType = callbackData.getMessageType(); - - if (messageType == null || messageType.trim().equals("")) { - String msg = "No workflow message type is defined in the '" + action + "' callback"; - logger.debug(msg); - fail(msg); - } - - content = callbackData.getContent(); - contentType = callbackData.getContentType(); - } else { - String msg = "Invalid workflow message program modifier: '" + modifier + "'"; - logger.debug(msg); - fail(msg); - } - - if (!injectSNIROCallbacks(contentType, messageType, content, 10000)) { - fail("Failed to inject '" + action + "' workflow message"); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - fail("Interrupted after injection of '" + action + "' workflow message"); - } - } - } - - /** - * Injects a sniro workflow message. The specified callback response may contain the placeholder strings - * ((CORRELATOR)) and ((SERVICE_RESOURCE_ID)) The ((CORRELATOR)) is replaced with the actual correlator value from - * the request. The ((SERVICE_RESOURCE_ID)) is replaced with the actual serviceResourceId value from the sniro - * request. Currently this only works with sniro request that contain only 1 resource. - * - * @param contentType the HTTP contentType for the message (possibly null) - * @param messageType the message type - * @param content the message content (possibly null) - * @param timeout the timeout in milliseconds - * @return true if the message could be injected, false otherwise - */ - protected boolean injectSNIROCallbacks(String contentType, String messageType, String content, long timeout) { - String correlator = (String) getProcessVariable("ReceiveWorkflowMessage", messageType + "_CORRELATOR", timeout); - - if (correlator == null) { - return false; - } - if (content != null) { - content = content.replace("((CORRELATOR))", correlator); - if (messageType.equalsIgnoreCase("SNIROResponse")) { - ServiceDecomposition decomp = - (ServiceDecomposition) getProcessVariable("Homing", "serviceDecomposition", timeout); - List<Resource> resourceList = decomp.getServiceResources(); - if (resourceList.size() == 1) { - String resourceId = ""; - for (Resource resource : resourceList) { - resourceId = resource.getResourceId(); - } - String homingList = getJsonValue(content, "solutionInfo.placementInfo"); - JSONArray placementArr = null; - try { - placementArr = new JSONArray(homingList); - } catch (Exception e) { - return false; - } - if (placementArr.length() == 1) { - content = content.replace("((SERVICE_RESOURCE_ID))", resourceId); - } - String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo"); - JSONArray licenseArr = null; - try { - licenseArr = new JSONArray(licenseInfoList); - } catch (Exception e) { - return false; - } - if (licenseArr.length() == 1) { - content = content.replace("((SERVICE_RESOURCE_ID))", resourceId); - } - } else { - try { - String homingList = getJsonValue(content, "solutionInfo.placementInfo"); - String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo"); - JSONArray placementArr = new JSONArray(homingList); - JSONArray licenseArr = new JSONArray(licenseInfoList); - for (Resource resource : resourceList) { - String resourceModuleName = resource.getModelInfo().getModelInstanceName(); - String resourceId = resource.getResourceId(); - - for (int i = 0; i < placementArr.length(); i++) { - JSONObject placementObj = placementArr.getJSONObject(i); - String placementModuleName = placementObj.getString("resourceModuleName"); - if (placementModuleName.equalsIgnoreCase(resourceModuleName)) { - String placementString = placementObj.toString(); - placementString = placementString.replace("((SERVICE_RESOURCE_ID))", resourceId); - JSONObject newPlacementObj = new JSONObject(placementString); - placementArr.put(i, newPlacementObj); - } - } - - for (int i = 0; i < licenseArr.length(); i++) { - JSONObject licenseObj = licenseArr.getJSONObject(i); - String licenseModuleName = licenseObj.getString("resourceModuleName"); - if (licenseModuleName.equalsIgnoreCase(resourceModuleName)) { - String licenseString = licenseObj.toString(); - licenseString = licenseString.replace("((SERVICE_RESOURCE_ID))", resourceId); - JSONObject newLicenseObj = new JSONObject(licenseString); - licenseArr.put(i, newLicenseObj); - } - } - } - String newPlacementInfos = placementArr.toString(); - String newLicenseInfos = licenseArr.toString(); - content = updJsonValue(content, "solutionInfo.placementInfo", newPlacementInfos); - content = updJsonValue(content, "solutionInfo.licenseInfo", newLicenseInfos); - } catch (Exception e) { - return false; - } - - } - } - } - logger.debug("Injecting " + messageType + " message"); - - Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content); - logger.debug("Workflow response to {} message: {}", messageType, response); - return true; - } - - - /** * Wait for the process to end. * * @param businessKey the process business key |