Search in sources :

Example 21 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 testIsAutoConnection.

@Test
public void testIsAutoConnection() {
    String id = "DMNEdge-ID";
    String autoConnectionID = "#AUTO-CONNECTION";
    JSIDMNEdge jsiDMNEdge1 = mock(JSIDMNEdge.class);
    when(jsiDMNEdge1.getId()).thenReturn(id);
    JSIDMNEdge jsiDMNEdge2 = mock(JSIDMNEdge.class);
    when(jsiDMNEdge2.getId()).thenReturn(id + autoConnectionID);
    JSIDMNEdge jsiDMNEdge3 = mock(JSIDMNEdge.class);
    when(jsiDMNEdge3.getId()).thenReturn(null);
    assertFalse(nodeConnector.isAutoConnection(jsiDMNEdge1, autoConnectionID));
    assertTrue(nodeConnector.isAutoConnection(jsiDMNEdge2, autoConnectionID));
    assertFalse(nodeConnector.isAutoConnection(jsiDMNEdge3, autoConnectionID));
}
Also used : JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 22 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 testIsTargetAutoConnectionEdge.

@Test
public void testIsTargetAutoConnectionEdge() {
    String edgeId = "edge-name";
    JSIDMNEdge edge = mock(JSIDMNEdge.class);
    when(edge.getId()).thenReturn(edgeId);
    assertFalse(nodeConnector.isTargetAutoConnectionEdge(edge));
    when(edge.getId()).thenReturn(edgeId + AUTO_TARGET_CONNECTION);
    assertTrue(nodeConnector.isTargetAutoConnectionEdge(edge));
}
Also used : JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 23 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 testConnectEdgeToNodesWhenDMNDIIsPresentAndNodeIsNotConnectedWithEdge.

@Test
public void testConnectEdgeToNodesWhenDMNDIIsPresentAndNodeIsNotConnectedWithEdge() {
    final JSIDMNEdge existingEdge = mock(JSIDMNEdge.class);
    final Definition definition = mock(Definition.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final String id = "789";
    final String contentDefinitionId = "123";
    final List<NodeEntry> list = singletonList(nodeEntry);
    when(jsiDMNElementReference.getHref()).thenReturn("#123");
    when(jsiDMNElement.getId()).thenReturn(id);
    when(existingEdge.getDmnElementRef()).thenReturn(new QName("", id));
    when(definition.getDefinition()).thenReturn(drgElement);
    when(currentNode.getContent()).thenReturn(definition);
    when(drgElement.getContentDefinitionId()).thenReturn(contentDefinitionId);
    doReturn(false).when(nodeConnector).isEdgeConnectedWithNode(eq(existingEdge), eq(currentNode), eq(list));
    doReturn(Optional.of(requiredNode)).when(nodeConnector).getSourceNode(eq(existingEdge), any());
    doNothing().when(nodeConnector).connectWbEdge(any(), any(), any(), any(), any(), any());
    entriesById.put(contentDefinitionId, list);
    edges.add(existingEdge);
    isDMNDIPresent = true;
    nodeConnector.connectEdgeToNodes(connectorTypeId, jsiDMNElement, jsiDMNElementReference, entriesById, diagramId, edges, isDMNDIPresent, currentNode);
    verify(nodeConnector, never()).connectWbEdge(eq(connectorTypeId), eq(diagramId), eq(currentNode), eq(requiredNode), eq(existingEdge), eq("789"));
    verify(nodeConnector).isEdgeConnectedWithNode(eq(existingEdge), eq(currentNode), eq(list));
}
Also used : QName(javax.xml.namespace.QName) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 24 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 testConnectEdgeToNodesWhenDMNDIIsNotPresent.

@Test
public void testConnectEdgeToNodesWhenDMNDIIsNotPresent() {
    final JSIDMNEdge newEdge = mock(JSIDMNEdge.class);
    when(jsiDMNElementReference.getHref()).thenReturn("#123");
    when(jsiDMNElement.getId()).thenReturn("789");
    when(nodeEntry.getNode()).thenReturn(requiredNode);
    final View<?> view = mock(View.class);
    final Bounds bounds = mock(Bounds.class);
    when(bounds.getHeight()).thenReturn(50d);
    when(bounds.getWidth()).thenReturn(100d);
    when(view.getBounds()).thenReturn(bounds);
    when(requiredNode.getContent()).thenReturn(view);
    doReturn("456").when(nodeConnector).uuid();
    doReturn(newEdge).when(nodeConnector).newEdge(50, 25);
    doNothing().when(nodeConnector).connectWbEdge(any(), any(), any(), any(), any(), any());
    entriesById.put("123", singletonList(nodeEntry));
    isDMNDIPresent = false;
    nodeConnector.connectEdgeToNodes(connectorTypeId, jsiDMNElement, jsiDMNElementReference, entriesById, diagramId, edges, isDMNDIPresent, currentNode);
    verify(nodeConnector).connectWbEdge(eq(connectorTypeId), eq(diagramId), eq(currentNode), eq(requiredNode), eq(newEdge), eq("456"));
}
Also used : JSIBounds(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 25 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 NodeConnector method connectWbEdge.

void connectWbEdge(final String connectorTypeId, final String diagramId, final Node currentNode, final Node requiredNode, final JSIDMNEdge dmnEdge, final String id) {
    final String prefixedId = IdUtils.getPrefixedId(diagramId, id);
    final Edge wbEdge = factoryManager.newElement(prefixedId, connectorTypeId).asEdge();
    final ViewConnector connectionContent = (ViewConnector) wbEdge.getContent();
    connectEdge(wbEdge, requiredNode, currentNode);
    setConnectionMagnets(wbEdge, connectionContent, dmnEdge);
}
Also used : ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) Edge(org.kie.workbench.common.stunner.core.graph.Edge) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge)

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