diff options
Diffstat (limited to 'bpmn')
-rw-r--r-- | bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java | 178 |
1 files changed, 0 insertions, 178 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 0161422b64..179d3e84aa 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 @@ -729,78 +729,6 @@ public abstract class WorkflowTest { } } - /** - * Runs a program to inject VNF callback data into the test environment. A program is essentially just a list of - * keys that identify callback data to be injected, in sequence. An example program: - * - * <pre> - * createVnf, deleteVnf - * </pre> - * - * Errors are handled with junit assertions and will cause the test to fail. - * - * @param callbacks an object containing callback data for the program - * @param program the program to execute - */ - protected void injectVNFCallbacks(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 content = null; - - if ("STD".equals(modifier)) { - CallbackData callbackData = callbacks.get(action); - - if (callbackData == null) { - String msg = "No callback defined for '" + action + "' VNF request"; - logger.debug(msg); - fail(msg); - } - - content = callbackData.getContent(); - } else if ("ERR".equals(modifier)) { - String msg = "Currently unsupported VNF program modifier: '" + modifier + "'"; - logger.debug(msg); - fail(msg); - } else { - String msg = "Invalid VNF program modifier: '" + modifier + "'"; - logger.debug(msg); - fail(msg); - } - - boolean injected = false; - - if (content.contains("createVnfNotification")) { - injected = injectCreateVNFCallback(content, 10000); - } else if (content.contains("deleteVnfNotification")) { - injected = injectDeleteVNFCallback(content, 10000); - } else if (content.contains("updateVnfNotification")) { - injected = injectUpdateVNFCallback(content, 10000); - } - - if (!injected) { - String msg = "Failed to inject VNF '" + action + "' callback"; - logger.debug(msg); - fail(msg); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - fail("Interrupted after injection of VNF '" + action + "' callback"); - } - } - } /** * Waits for the number of running processes with the specified process definition key to equal a particular count. @@ -1179,112 +1107,6 @@ public abstract class WorkflowTest { return true; } - /** - * Injects a Update VNF adapter callback request. The specified callback data may contain the placeholder string - * ((MESSAGE-ID)) which is replaced with the actual message ID. It may also contain the placeholder string - * ((REQUEST-ID)) which is replaced request ID of the original MSO request. - * - * @param content the content of the callback - * @param timeout the timeout in milliseconds - * @return true if the callback could be injected, false otherwise - * @throws JAXBException if the content does not adhere to the schema - */ - protected boolean injectUpdateVNFCallback(String content, long timeout) { - - String messageId = (String) getProcessVariable("vnfAdapterUpdate", "VNFU_messageId", timeout); - - if (messageId == null) { - return false; - } - - content = content.replace("((MESSAGE-ID))", messageId); - // Deprecated usage. All test code should switch to the (( ... )) syntax. - content = content.replace("{{MESSAGE-ID}}", messageId); - - content = content.replace("((REQUEST-ID))", msoRequestId); - // Deprecated usage. All test code should switch to the (( ... )) syntax. - content = content.replace("{{REQUEST-ID}}", msoRequestId); - - logger.debug("Injecting VNF adapter callback"); - - // Is it possible to unmarshal this with JAXB? I couldn't. - - UpdateVnfNotification updateVnfNotification = new UpdateVnfNotification(); - XPathTool xpathTool = new VnfNotifyXPathTool(); - xpathTool.setXML(content); - - try { - String completed = xpathTool.evaluate("/tns:updateVnfNotification/tns:completed/text()"); - updateVnfNotification.setCompleted("true".equals(completed)); - - NodeList entries = (NodeList) xpathTool.evaluate("/tns:updateVnfNotification/tns:outputs/tns:entry", - XPathConstants.NODESET); - - UpdateVnfNotificationOutputs outputs = new UpdateVnfNotificationOutputs(); - - for (int i = 0; i < entries.getLength(); i++) { - Node node = entries.item(i); - - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element entry = (Element) node; - String key = entry.getElementsByTagNameNS("*", "key").item(0).getTextContent(); - String value = entry.getElementsByTagNameNS("*", "value").item(0).getTextContent(); - outputs.add(key, value); - } - } - - updateVnfNotification.setOutputs(outputs); - - VnfRollback rollback = new VnfRollback(); - - String cloudSiteId = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:cloudSiteId/text()"); - rollback.setCloudSiteId(cloudSiteId); - - String cloudOwner = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:cloudOwner/text()"); - rollback.setCloudOwner(cloudOwner); - - String requestId = - xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:requestId/text()"); - String serviceInstanceId = xpathTool - .evaluate("/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:serviceInstanceId/text()"); - - if (requestId != null || serviceInstanceId != null) { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId(requestId); - msoRequest.setServiceInstanceId(serviceInstanceId); - rollback.setMsoRequest(msoRequest); - } - - String tenantCreated = - xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:tenantCreated/text()"); - rollback.setTenantCreated("true".equals(tenantCreated)); - - String tenantId = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:tenantId/text()"); - rollback.setTenantId(tenantId); - - String vnfCreated = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:vnfCreated/text()"); - rollback.setVnfCreated("true".equals(vnfCreated)); - - String rollbackVnfId = xpathTool.evaluate("/tns:updateVnfNotification/tns:rollback/tns:vnfId/text()"); - rollback.setVnfId(rollbackVnfId); - - updateVnfNotification.setRollback(rollback); - - } catch (Exception e) { - logger.debug("Failed to unmarshal VNF callback content:"); - logger.debug(content); - return false; - } - - VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl(); - - - notifyService.updateVnfNotification(messageId, updateVnfNotification.isCompleted(), - updateVnfNotification.getException(), updateVnfNotification.getErrorMessage(), - updateVnfNotification.getOutputs(), updateVnfNotification.getRollback()); - - return true; - } /** * Runs a program to inject workflow messages into the test environment. A program is essentially just a list of |