Source:
<code><START> public void testSortNodes_SubStage() throws Exception { <END> final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram = mock(Diagram.class); final Graph<DefinitionSet, Node> graph = mock(Graph.class); when(diagram.getGraph()).thenReturn(graph); final List<Node> nodes = new LinkedList<>(); when(graph.nodes()).thenReturn(nodes); final Node root = createNode(CaseManagementDiagram.class); final Node start = createNode(StartNoneEvent.class); final Node end = createNode(EndNoneEvent.class); final Node stage = createNode(AdHocSubprocess.class); nodes.add(root); nodes.add(start); nodes.add(end); nodes.add(stage); createChildEdge(root, end); createChildEdge(root, start); createChildEdge(root, stage); createSequenceFlow(start, stage); createSequenceFlow(stage, end); final Node ss1 = createNode(UserTask.class, 3.0); final Node ss2 = createNode(CaseReusableSubprocess.class, 2.0); final Node ss3 = createNode(ProcessReusableSubprocess.class, 1.0); nodes.add(ss1); nodes.add(ss2); nodes.add(ss3); createChildEdge(stage, ss1); createChildEdge(stage, ss2); createChildEdge(stage, ss3); tested.sortNodes(diagram); final List<Edge> rEdges = root.getOutEdges(); assertEquals(3, rEdges.size()); assertEquals(start, rEdges.get(0).getTargetNode()); assertEquals(stage, rEdges.get(1).getTargetNode()); assertEquals(end, rEdges.get(2).getTargetNode()); final List<Edge> sEdges = stage.getOutEdges(); assertEquals(4, sEdges.size()); assertEquals(ss3, sEdges.get(0).getTargetNode()); assertEquals(ss2, sEdges.get(1).getTargetNode()); assertEquals(ss1, sEdges.get(2).getTargetNode()); }</code><technical_language>Exception is thrown</technical_language>

Target:
public void testSortNodes_SubStage() { final Diagram<Graph<DefinitionSet, Node>, Metadata> diagram = mock(Diagram.class); final Graph<DefinitionSet, Node> graph = mock(Graph.class); when(diagram.getGraph()).thenReturn(graph); final List<Node> nodes = new LinkedList<>(); when(graph.nodes()).thenReturn(nodes); final Node root = createNode(CaseManagementDiagram.class); final Node start = createNode(StartNoneEvent.class); final Node end = createNode(EndNoneEvent.class); final Node stage = createNode(AdHocSubprocess.class); nodes.add(root); nodes.add(start); nodes.add(end); nodes.add(stage); createChildEdge(root, end); createChildEdge(root, start); createChildEdge(root, stage); createSequenceFlow(start, stage); createSequenceFlow(stage, end); final Node ss1 = createNode(UserTask.class, 3.0); final Node ss2 = createNode(CaseReusableSubprocess.class, 2.0); final Node ss3 = createNode(ProcessReusableSubprocess.class, 1.0); nodes.add(ss1); nodes.add(ss2); nodes.add(ss3); createChildEdge(stage, ss1); createChildEdge(stage, ss2); createChildEdge(stage, ss3); tested.sortNodes(diagram); final List<Edge> rEdges = root.getOutEdges(); assertEquals(3, rEdges.size()); assertEquals(start, rEdges.get(0).getTargetNode()); assertEquals(stage, rEdges.get(1).getTargetNode()); assertEquals(end, rEdges.get(2).getTargetNode()); final List<Edge> sEdges = stage.getOutEdges(); assertEquals(4, sEdges.size()); assertEquals(ss3, sEdges.get(0).getTargetNode()); assertEquals(ss2, sEdges.get(1).getTargetNode()); assertEquals(ss1, sEdges.get(2).getTargetNode()); }