} else {
ongoingCases.put(name, testCode);
return false;
}
} else if (currentNode instanceof HumanTaskNode) {
HumanTaskNode taskNode = (HumanTaskNode) currentNode;
String actorId = (String) taskNode.getWork().getParameter("ActorId");
if (actorId == null) {
actorId = "";
}
String groupId = (String) taskNode.getWork().getParameter("GroupId");
if (groupId == null) {
groupId = "";
}
String[] actorIds = new String[0];
if (actorId.trim().length() > 0) {
actorIds = actorId.split(",");
}
String[] groupIds = new String[0];
if (groupId.trim().length() > 0) {
groupIds = groupId.split(",");
}
actorId = actorIds.length > 0 ? actorIds[0] : "";
if (firstHumanTask) {
testCode +=
" // execute task\n" +
" String actorId = \"" + actorId + "\";\n" +
" List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner(actorId, \"en-UK\");\n" +
" TaskSummary task = list.get(0);\n";
} else {
testCode +=
" // execute task\n" +
" actorId = \"" + actorId + "\";\n" +
" list = taskService.getTasksAssignedAsPotentialOwner(actorId, \"en-UK\");\n" +
" task = list.get(0);\n";
}
if (actorIds.length > 1 || groupIds.length > 0) {
testCode +=
" taskService.claim(task.getId(), actorId);\n";
}
if (firstHumanTask) {
testCode +=
" taskService.start(task.getId(), actorId);\n" +
" Map<String, Object> results = new HashMap<String, Object>();\n" +
" // add results here\n";
firstHumanTask = false;
} else {
testCode +=
" taskService.start(task.getId(), actorId);\n" +
" results = new HashMap<String, Object>();\n" +
" // add results here\n";
}
for (Map.Entry<String, String> entry: taskNode.getOutMappings().entrySet()) {
String type = null;
VariableScope variableScope = (VariableScope) taskNode.resolveContext(VariableScope.VARIABLE_SCOPE, entry.getValue());
if (variableScope != null) {
type = variableScope.findVariable(entry.getValue()).getType().getStringType();
}
testCode +=
" // results.put(\"" + entry.getKey() + "\", value);" + (type == null ? "" : " // type " + type) + "\n";
}
testCode +=
" taskService.complete(task.getId(), actorId, results);\n" +
"\n";
return processNodes(name, ((NodeImpl) currentNode).getTo().getTo(), testCode, cases, ongoingCases);
} else if (currentNode instanceof WorkItemNode) {
WorkItemNode taskNode = (WorkItemNode) currentNode;
testCode +=
" // if necessary, complete request for service task \"" + taskNode.getWork().getName() + "\"\n";
return processNodes(name, ((NodeImpl) currentNode).getTo().getTo(), testCode, cases, ongoingCases);
} else if (currentNode instanceof EventNode) {
EventNode eventNode = (EventNode) currentNode;
testCode +=
" ksession.signalEvent(\"" + eventNode.getType() + "\", null, processInstance.getId());\n";