Search in sources :

Example 11 with JSIDMNEdge

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge in project kie-wb-common by kiegroup.

the class NodeConnectorTest method testGetSourceNode_WhenThereIsOnlyASingleNode.

@Test
public void testGetSourceNode_WhenThereIsOnlyASingleNode() {
    final JSIDMNEdge jsiDMNEdge = mock(JSIDMNEdge.class);
    final NodeEntry nodeEntry = mock(NodeEntry.class);
    final Node node = mock(Node.class);
    final List nodeEntries = singletonList(nodeEntry);
    when(nodeEntry.getNode()).thenReturn(node);
    Optional<Node> sourceNode = nodeConnector.getSourceNode(jsiDMNEdge, nodeEntries);
    assertTrue(sourceNode.isPresent());
    assertEquals(sourceNode.get(), node);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 12 with JSIDMNEdge

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge in project kie-wb-common by kiegroup.

the class NodeConnectorTest method testIsEdgeConnectedWithNode_WhenIsConnectedByTarget.

@Test
public void testIsEdgeConnectedWithNode_WhenIsConnectedByTarget() {
    final JSIDMNEdge jsiDMNEdge = mock(JSIDMNEdge.class);
    final List nodeEntries = mock(List.class);
    final Node sourceNode = mock(Node.class);
    doReturn(Optional.of(currentNode)).when(nodeConnector).getTargetNode(jsiDMNEdge, nodeEntries);
    doReturn(Optional.of(sourceNode)).when(nodeConnector).getSourceNode(jsiDMNEdge, nodeEntries);
    assertTrue(nodeConnector.isEdgeConnectedWithNode(jsiDMNEdge, currentNode, nodeEntries));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 13 with JSIDMNEdge

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge in project kie-wb-common by kiegroup.

the class NodeConnectorTest method testIsEdgeConnectedWithNode_WhenIsConnectedBySource.

@Test
public void testIsEdgeConnectedWithNode_WhenIsConnectedBySource() {
    final JSIDMNEdge jsiDMNEdge = mock(JSIDMNEdge.class);
    final List nodeEntries = mock(List.class);
    final Node targetNode = mock(Node.class);
    doReturn(Optional.of(targetNode)).when(nodeConnector).getTargetNode(jsiDMNEdge, nodeEntries);
    doReturn(Optional.of(currentNode)).when(nodeConnector).getSourceNode(jsiDMNEdge, nodeEntries);
    assertTrue(nodeConnector.isEdgeConnectedWithNode(jsiDMNEdge, currentNode, nodeEntries));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 14 with JSIDMNEdge

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge in project kie-wb-common by kiegroup.

the class NodeConnectorTest method testGetSourceNode.

@Test
public void testGetSourceNode() {
    final JSIDMNEdge jsiDMNEdge = mock(JSIDMNEdge.class);
    final double sourceX = 1.0;
    final double sourceY = 2.0;
    final JSIPoint sourcePoint = createPoint(sourceX, sourceY);
    final JSIPoint targetPoint = createPoint(7, 8);
    final List<JSIPoint> waypoints = Arrays.asList(sourcePoint, targetPoint);
    final List nodeEntries = mock(List.class);
    final Point2D sourcePoint2D = new Point2D(sourceX, sourceY);
    when(jsiDMNEdge.getWaypoint()).thenReturn(waypoints);
    doReturn(Optional.of(mock(Node.class))).when(nodeConnector).getNodeFromPoint(sourcePoint2D, nodeEntries);
    nodeConnector.getSourceNode(jsiDMNEdge, nodeEntries);
    verify(nodeConnector).getNodeFromPoint(sourcePoint2D, nodeEntries);
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 15 with JSIDMNEdge

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge in project kie-wb-common by kiegroup.

the class NodeConnectorTest method testIsEdgeConnectedWithNode.

@Test
public void testIsEdgeConnectedWithNode() {
    final JSIDMNEdge jsiDMNEdge = mock(JSIDMNEdge.class);
    final List nodeEntries = mock(List.class);
    final Node targetNode = mock(Node.class);
    final Node sourceNode = mock(Node.class);
    doReturn(Optional.of(targetNode)).when(nodeConnector).getTargetNode(jsiDMNEdge, nodeEntries);
    doReturn(Optional.of(sourceNode)).when(nodeConnector).getSourceNode(jsiDMNEdge, nodeEntries);
    assertFalse(nodeConnector.isEdgeConnectedWithNode(jsiDMNEdge, currentNode, nodeEntries));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Aggregations

JSIDMNEdge (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge)26 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)13 List (java.util.List)11 Node (org.kie.workbench.common.stunner.core.graph.Node)10 Collections.singletonList (java.util.Collections.singletonList)8 Edge (org.kie.workbench.common.stunner.core.graph.Edge)8 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)7 JSIPoint (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)6 QName (javax.xml.namespace.QName)4 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)4 ControlPoint (org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint)4 JSIBounds (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds)3 JSIDiagramElement (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIDiagramElement)3 JSITDMNElement (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElement)3 JSIDMNDiagram (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDiagram)3 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)3 DiscreteConnection (org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection)3 Point2D (com.ait.lienzo.client.core.types.Point2D)2