Skip to content

Commit

Permalink
Issue #471 Move hasEntryPoint to Renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
prmr committed Sep 14, 2022
1 parent 3918ce4 commit 1a040c8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
14 changes: 0 additions & 14 deletions src/org/jetuml/diagram/ControlFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ public Optional<CallNode> getCaller(Node pNode)
.findFirst();
}

/**
* @return True if there is at least one call node in the diagram.
*/
public boolean hasEntryPoint()
{
return aDiagram.rootNodes().stream().anyMatch(ControlFlow::hasCallNode);
}

private static boolean hasCallNode(Node pNode)
{
return pNode.getClass() == ImplicitParameterNode.class &&
!pNode.getChildren().isEmpty();
}

/**
* @param pNode The node to check.
* @return True if pNode is a CallNode and is at the end of a ConstructorEdge.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static Constraint singleEntryPoint()
{
return !(pEdge.getClass() == CallEdge.class &&
pStart.getClass() == ImplicitParameterNode.class &&
new ControlFlow(pRenderer.diagram()).hasEntryPoint());
((SequenceDiagramRenderer)pRenderer).hasEntryPoint());
};
}
}
14 changes: 14 additions & 0 deletions src/org/jetuml/rendering/SequenceDiagramRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,18 @@ private int getDropDistance()
return DROP_MIN + 10;
}
}

/**
* @return True if there is at least one call node in the diagram.
*/
public boolean hasEntryPoint()
{
return diagram().rootNodes().stream().anyMatch(SequenceDiagramRenderer::hasCallNode);
}

private static boolean hasCallNode(Node pNode)
{
return pNode.getClass() == ImplicitParameterNode.class &&
!pNode.getChildren().isEmpty();
}
}
12 changes: 0 additions & 12 deletions test/org/jetuml/diagram/TestControlFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,6 @@ private void createSampleDiagram1()
aDiagramAccessor.connectAndAdd(aCallEdge3, aCall2, aCall5);
}

@Test
void testHasEntryPoint_No()
{
assertFalse(new ControlFlow(new Diagram(DiagramType.SEQUENCE)).hasEntryPoint());
}

@Test
void testHasEntryPoint_Yes()
{
assertTrue(aFlow.hasEntryPoint());
}

@Test
void testGetCallerNoCaller()
{
Expand Down

0 comments on commit 1a040c8

Please sign in to comment.