use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CanvasDefinitionTooltipTest method testShow.
@Test
public void testShow() {
final Point2D point = new Point2D(55, 6);
tested.show(new CanvasDefinitionTooltip.DefinitionIdContent("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 PasteSelectionSessionCommandTest method executeWithMultiSelection.
@Test
@SuppressWarnings("unchecked")
public void executeWithMultiSelection() {
pasteSelectionSessionCommand.bind(session);
// Mock the callback of CloneNodeCommand
ArgumentCaptor<Consumer> consumerNode = ArgumentCaptor.forClass(Consumer.class);
ArgumentCaptor<Consumer> consumerNode2 = ArgumentCaptor.forClass(Consumer.class);
when(cloneNodeCommand.getCandidate()).thenReturn(node);
when(cloneNodeCommand2.getCandidate()).thenReturn(node2);
when(canvasCommandFactory.cloneNode(eq(node), any(), any(), consumerNode.capture())).thenReturn(cloneNodeCommand);
when(canvasCommandFactory.cloneNode(eq(node2), any(), any(), consumerNode2.capture())).thenReturn(cloneNodeCommand2);
Map<Node, ArgumentCaptor<Consumer>> consumerMap = new HashMap() {
{
put(node, consumerNode);
put(node2, consumerNode2);
}
};
// Mock the callback of CloneConnectorCommand
ArgumentCaptor<Consumer> consumerEdge = ArgumentCaptor.forClass(Consumer.class);
when(canvasCommandFactory.cloneConnector(any(), anyString(), anyString(), anyString(), consumerEdge.capture())).thenReturn(cloneConnectorCommand);
// apply callbacks mocks
when(sessionCommandManager.execute(eq(canvasHandler), any())).thenAnswer(param -> {
CompositeCommand argument = param.getArgumentAt(1, CompositeCommand.class);
// callback to nodes
argument.getCommands().stream().filter(c -> c instanceof CloneNodeCommand).forEach(c -> {
CloneNodeCommand cloneNodeCommand = (CloneNodeCommand) c;
Node candidate = cloneNodeCommand.getCandidate();
consumerMap.get(candidate).getValue().accept(cloneMap.get(candidate));
});
// callback to connectors
argument.getCommands().stream().filter(c -> c instanceof CloneConnectorCommand).forEach(c -> consumerEdge.getValue().accept(cloneEdge));
return commandResult;
});
// Executing the command
clipboardControl.set(graphInstance.startNode, graphInstance.edge1, graphInstance.intermNode);
when(selectionControl.getSelectedItems()).thenReturn(Arrays.asList(graphInstance.startNode.getUUID(), graphInstance.edge1.getUUID(), graphInstance.intermNode.getUUID()));
pasteSelectionSessionCommand.execute(callback);
verify(canvasCommandFactory, times(1)).cloneNode(eq(graphInstance.startNode), eq(graphInstance.parentNode.getUUID()), eq(new Point2D(X, DEFAULT_PADDING + Y + NODE_SIZE)), any());
verify(canvasCommandFactory, times(1)).cloneConnector(eq(graphInstance.edge1), anyString(), anyString(), anyString(), any());
// check command registry update after execution to allow a single undo/redo
verify(commandRegistry, times(2)).pop();
ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class);
verify(commandRegistry, times(1)).register(commandArgumentCaptor.capture());
assertTrue(commandArgumentCaptor.getValue() instanceof CompositeCommand);
assertEquals(((CompositeCommand) commandArgumentCaptor.getValue()).size(), 2);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class AbstractControlPointCommandTest method setUp.
public void setUp() {
super.init(0, 0);
newLocation = new Point2D(0, 0);
controlPoint1 = new ControlPointImpl(new Point2D(1, 1), 1);
controlPoint2 = new ControlPointImpl(new Point2D(2, 2), 2);
controlPoint3 = new ControlPointImpl(new Point2D(3, 3), 3);
controlPointList = new ArrayList<ControlPoint>() {
{
add(controlPoint1);
add(controlPoint2);
add(controlPoint3);
}
};
when(edge.getContent()).thenReturn(viewConnector);
when(viewConnector.getControlPoints()).thenReturn(controlPointList);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CloneNodeCommandTest method setUp.
@Before
public void setUp() {
super.setUp();
candidate = graphInstance.containerNode;
parent = graphInstance.parentNode;
candidate.setContent(candidateContent);
this.position = new Point2D(1, 1);
this.cloneNodeCommand = new CloneNodeCommand(candidate, parent.getUUID(), position, null, childrenTraverseProcessorManagedInstance);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class GraphBoundsIndexerImplTest method testGetTrimmedBounds.
@Test
public void testGetTrimmedBounds() {
Point2D position = GraphUtils.getPosition((View) graphInstanceParent.startNode.getContent());
double[] size = GraphUtils.getNodeSize((View) graphInstanceParent.startNode.getContent());
double[] trimmedBounds = graphBoundsIndexerImpl.getTrimmedBounds();
assertEquals(trimmedBounds[0], position.getX(), 0.001);
assertEquals(trimmedBounds[1], position.getY(), 0.001);
assertEquals(trimmedBounds[2], size[0], 0.001);
assertEquals(trimmedBounds[3], size[1], 0.001);
}
Aggregations