use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method getNextOutOfCanvas.
// TODO (AlessioP & Roger):
@Test
@Ignore
@SuppressWarnings("unchecked")
public void getNextOutOfCanvas() {
when(ruleManager.evaluate(eq(ruleSet), any(RuleEvaluationContext.class))).thenReturn(ruleViolations);
when(ruleViolations.violations(Violation.Type.ERROR)).thenReturn(ruleViolationIterable);
when(ruleViolations.violations(Violation.Type.ERROR).iterator()).thenReturn(ruleViolationIterator);
when(ruleViolations.violations(Violation.Type.ERROR).iterator().hasNext()).thenReturn(true);
this.graphTestHandler = new TestingGraphMockHandler();
graphInstance = TestingGraphInstanceBuilder.newGraph1(graphTestHandler);
Node node = mock(Node.class);
Bounds boundsNode = new BoundsImpl(new BoundImpl(100d, 0d), new BoundImpl(300d, 1400d));
View viewNode = mock(View.class);
when(node.getContent()).thenReturn(viewNode);
when(viewNode.getBounds()).thenReturn(boundsNode);
Node newNode = mock(Node.class);
Bounds boundsNewNode = new BoundsImpl(new BoundImpl(100d, 200d), new BoundImpl(300d, 300d));
View viewNewNode = mock(View.class);
when(newNode.getContent()).thenReturn(viewNewNode);
when(viewNewNode.getBounds()).thenReturn(boundsNewNode);
when(canvasHandler.getDiagram().getGraph()).thenReturn(graphInstance.graph);
when(graphBoundsIndexer.getAt(140.0, 0.0, 200.0, 100.0, null)).thenReturn(node);
graphInstance.startNode.getOutEdges().clear();
Point2D next = canvasLayoutUtils.getNext(canvasHandler, graphInstance.startNode, newNode);
Node<View<?>, Edge> intermNode = (Node<View<?>, Edge>) graphInstance.intermNode;
double[] size = GraphUtils.getNodeSize(intermNode.getContent());
assertTrue(next.getX() > size[0]);
assertTrue(next.getY() == CanvasLayoutUtils.getPaddingY());
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CreateNodeActionTest method testAction.
@Test
@SuppressWarnings("unchecked")
public void testAction() {
when(canvasLayoutUtils.getNext(eq(canvasHandler), eq(element), eq(targetNode))).thenReturn(new Point2D(100d, 500d));
final MouseClickEvent event = mock(MouseClickEvent.class);
when(event.getX()).thenReturn(100d);
when(event.getY()).thenReturn(500d);
ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, NODE_UUID, event);
assertEquals(tested, cascade);
ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class);
verify(sessionCommandManager, times(1)).execute(eq(canvasHandler), commandArgumentCaptor.capture());
DeferredCompositeCommand command = (DeferredCompositeCommand) commandArgumentCaptor.getValue();
DeferredCommand c0 = (DeferredCommand) command.getCommands().get(0);
DeferredCommand c1 = (DeferredCommand) command.getCommands().get(1);
DeferredCommand c2 = (DeferredCommand) command.getCommands().get(2);
DeferredCommand c3 = (DeferredCommand) command.getCommands().get(3);
AddNodeCommand addNodeCommand = (AddNodeCommand) c0.getCommand();
UpdateElementPositionCommand updateElementPositionCommand = (UpdateElementPositionCommand) c1.getCommand();
AddConnectorCommand addConnectorCommand = (AddConnectorCommand) c2.getCommand();
SetConnectionTargetNodeCommand setTargetNodeCommand = (SetConnectionTargetNodeCommand) c3.getCommand();
assertEquals(targetNode, addNodeCommand.getCandidate());
assertEquals("ss1", addNodeCommand.getShapeSetId());
assertEquals(edge, addConnectorCommand.getCandidate());
assertEquals(element, addConnectorCommand.getSource());
assertEquals("ss1", addConnectorCommand.getShapeSetId());
assertEquals(edge, setTargetNodeCommand.getEdge());
assertEquals(targetNode, setTargetNodeCommand.getNode());
assertEquals(targetNode, updateElementPositionCommand.getElement());
assertEquals(new Point2D(100d, 500d), updateElementPositionCommand.getLocation());
final ArgumentCaptor<CanvasSelectionEvent> eventArgumentCaptor = ArgumentCaptor.forClass(CanvasSelectionEvent.class);
verify(canvasElementSelectedEvent, times(1)).fire(eventArgumentCaptor.capture());
final CanvasSelectionEvent eCaptured = eventArgumentCaptor.getValue();
assertEquals(TARGET_NODE_UUID, eCaptured.getIdentifiers().iterator().next());
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CanvasDefinitionTooltipTest method testConfigure.
@Test
public void testConfigure() {
final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
final AbstractCanvas canvas = mock(AbstractCanvas.class);
final AbstractCanvas.View canvasView = mock(AbstractCanvas.View.class);
final Layer layer = mock(Layer.class);
final Transform transform = mock(Transform.class);
when(canvasHandler.getCanvas()).thenReturn(canvas);
when(canvasHandler.getAbstractCanvas()).thenReturn(canvas);
when(canvas.getLayer()).thenReturn(layer);
when(layer.getTransform()).thenReturn(transform);
when(canvas.getView()).thenReturn(canvasView);
when(canvasView.getAbsoluteX()).thenReturn(220d);
when(canvasView.getAbsoluteY()).thenReturn(50.5d);
final CanvasDefinitionTooltip t = tested.configure(canvasHandler);
assertEquals(tested, t);
verify(textTooltip, times(1)).setTransform(eq(transform));
final ArgumentCaptor<Point2D> pointCaptor = ArgumentCaptor.forClass(Point2D.class);
verify(textTooltip, times(1)).setCanvasLocation(pointCaptor.capture());
final Point2D point = pointCaptor.getValue();
assertEquals(220d, point.getX(), 0);
assertEquals(50.5d, point.getY(), 0);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CanvasDefinitionTooltipTest method testShowById.
@Test
public void testShowById() {
final Point2D point = new Point2D(55, 6);
tested.show("def1", point);
verify(textTooltip, times(1)).show(eq("def1theTestTitle"), eq(point));
verify(textTooltip, never()).hide();
verify(textTooltip, never()).destroy();
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class NodeShapeImplTest method testApplyPosition.
@Test
public void testApplyPosition() {
tested.applyPosition(element, MutationContext.STATIC);
verify(view, times(1)).setShapeLocation(new Point2D(10d, 20d));
}
Aggregations