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));
}
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));
}
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));
}
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"));
}
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);
}
Aggregations