public void assertNodeExists(ProcessInstance process, String... nodeNames) { WorkflowProcessInstanceImpl instance = (WorkflowProcessInstanceImpl) process; List<String> names = new ArrayList<String>(); for (String nodeName : nodeNames) { names.add(nodeName); } for (Node node : instance.getNodeContainer().getNodes()) { if (names.contains(node.getName())) { names.remove(node.getName()); } } if (!names.isEmpty()) { String s = names.get(0); for (int i = 1; i < names.size(); i++) { s += ", " + names.get(i); } fail("Node(s) do not exist: " + s); } }
public void assertNumOfOutgoingConnections(ProcessInstance process, String nodeName, int num) { assertNodeExists(process, nodeName); WorkflowProcessInstanceImpl instance = (WorkflowProcessInstanceImpl) process; for (Node node : instance.getNodeContainer().getNodes()) { if (node.getName().equals(nodeName)) { if (node.getOutgoingConnections().size() != num) { fail( "Expected outgoing connections: " + num + " - found " + node.getOutgoingConnections().size()); } else { break; } } } }