}
}
private boolean processNodes(String name, Node currentNode, String testCode, Map<String, String> cases, Map<String, String> ongoingCases) {
if (currentNode instanceof Split) {
Split split = (Split) currentNode;
switch (split.getType()) {
case Split.TYPE_AND:
boolean done = false;
String startTestCode = testCode;
int counter = 1;
for (Connection c: split.getDefaultOutgoingConnections()) {
if (processNodes(name + counter++, c.getTo(), startTestCode, cases, ongoingCases)) {
done = true;
}
}
if (!done) {
String implicitCompleteTestCode = startTestCode;
for (String ongoingCase: ongoingCases.values()) {
implicitCompleteTestCode += ongoingCase.substring(startTestCode.length(), ongoingCase.length());
}
ongoingCases.clear();
ongoingCases.put(name, implicitCompleteTestCode);
}
return done;
case Split.TYPE_XOR:
case Split.TYPE_OR:
int i = 1;
done = true;
for (Connection c: split.getDefaultOutgoingConnections()) {
String newTestCode = testCode +
" // please make sure that the following constraint is selected to node " + c.getTo().getName() + ":\n" +
" // " + split.getConstraint(c).getConstraint() + "\n";
if (!processNodes(name + "Constraint" + i++, c.getTo(), newTestCode, cases, ongoingCases)) {
done = false;
}
}
return done;
default:
throw new IllegalArgumentException("Unknown split type " + split.getType());
}
} else if (currentNode instanceof EndNode) {
EndNode endNode = (EndNode) currentNode;
if (endNode.isTerminate()) {
cases.put(name, testCode);