use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class AcyclicDirectedGraphRuleTest method checkCyclicalConnection.
@Test
@SuppressWarnings("unchecked")
public void checkCyclicalConnection() {
final Node node1 = new NodeImpl<>("node1");
final Node node2 = new NodeImpl<>("node2");
final Edge c1 = new EdgeImpl<>("edge1");
node1.getOutEdges().add(c1);
node2.getInEdges().add(c1);
c1.setSourceNode(node1);
c1.setTargetNode(node2);
graph.addNode(node1);
graph.addNode(node2);
when(context.getSource()).thenReturn(Optional.of(node2));
when(context.getTarget()).thenReturn(Optional.of(node1));
when(context.getConnector()).thenReturn(connector);
final RuleViolations result = check.evaluate(rule, context);
assertNotNull(result);
assertTrue(result.violations().iterator().hasNext());
final RuleViolation violation = result.violations().iterator().next();
assertNotNull(violation);
assertTrue(violation.getArguments().isPresent());
assertEquals(1, violation.getArguments().get().length);
assertEquals(AcyclicDirectedGraphRule.ERROR_MESSAGE, violation.getArguments().get()[0]);
}
use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class BaseGraphRuleTest method checkNoViolationsWhenNoExistingConnections.
@Test
@SuppressWarnings("unchecked")
public void checkNoViolationsWhenNoExistingConnections() {
final Node node1 = new NodeImpl<>("node1");
final Node node2 = new NodeImpl<>("node2");
graph.addNode(node1);
graph.addNode(node2);
when(context.getSource()).thenReturn(Optional.of(node1));
when(context.getTarget()).thenReturn(Optional.of(node2));
when(context.getConnector()).thenReturn(connector);
final RuleViolations result = check.evaluate(rule, context);
assertNotNull(result);
assertFalse(result.violations().iterator().hasNext());
}
use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class SingleConnectorPerTypeGraphRuleTest method checkHasExistingConnection.
@Test
@SuppressWarnings("unchecked")
public void checkHasExistingConnection() {
final Node node1 = new NodeImpl<>("node1");
final Node node2 = new NodeImpl<>("node2");
final Edge existingConnector = new EdgeImpl<>("edge1");
final ViewConnector existingConnectorView = mock(ViewConnector.class);
existingConnector.setContent(existingConnectorView);
when(existingConnectorView.getDefinition()).thenReturn(new Definition());
node1.getOutEdges().add(existingConnector);
node2.getInEdges().add(existingConnector);
existingConnector.setSourceNode(node1);
existingConnector.setTargetNode(node2);
graph.addNode(node1);
graph.addNode(node2);
when(context.getSource()).thenReturn(Optional.of(node1));
when(context.getTarget()).thenReturn(Optional.of(node2));
when(context.getConnector()).thenReturn(connector);
final RuleViolations result = check.evaluate(rule, context);
assertNotNull(result);
assertTrue(result.violations().iterator().hasNext());
final RuleViolation violation = result.violations().iterator().next();
assertNotNull(violation);
assertTrue(violation.getArguments().isPresent());
assertEquals(1, violation.getArguments().get().length);
assertEquals(SingleConnectorPerTypeGraphRule.ERROR_MESSAGE, violation.getArguments().get()[0]);
}
use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class FormsContainerTest method testDestroyOneDisplayer.
@Test
public void testDestroyOneDisplayer() {
NodeImpl firstNode = getNode(FIRST_ELEMENT_UID);
FormDisplayer firstDisplayer = testRender(firstNode, 1, 1);
NodeImpl secondNode = getNode(SECOND_ELEMENT_UID);
FormDisplayer secondDisplayer = testRender(secondNode, 2, 1);
formsContainer.clearFormDisplayer(GRAPH_UID, FIRST_ELEMENT_UID);
verify(firstDisplayer, times(3)).hide();
verify(view, times(1)).removeDisplayer(firstDisplayer);
verify(displayersInstance, times(1)).destroy(firstDisplayer);
verify(secondDisplayer, times(1)).hide();
verify(view, never()).removeDisplayer(secondDisplayer);
verify(displayersInstance, never()).destroy(secondDisplayer);
formsContainer.clearFormDisplayer(GRAPH_UID, SECOND_ELEMENT_UID);
verify(secondDisplayer, times(2)).hide();
verify(view, times(1)).removeDisplayer(secondDisplayer);
verify(displayersInstance, times(1)).destroy(secondDisplayer);
}
use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.
the class FormsContainerTest method getNode.
protected NodeImpl getNode(final String uuid) {
NodeImpl node = mock(NodeImpl.class);
when(node.getUUID()).thenReturn(uuid);
return node;
}
Aggregations