use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.
the class DeleteNodeCommandTest method startNodeTestCanvasCommands.
@Test
public void startNodeTestCanvasCommands() {
this.tested = new DeleteNodeCommand(graphHolder.startNode);
final CommandResult<CanvasViolation> result = tested.allow(canvasHandler);
final AbstractCompositeCommand<AbstractCanvasHandler, CanvasViolation> compositeCommand = tested.getCommand();
assertNotNull(compositeCommand);
assertTrue(3 == compositeCommand.size());
final List<Command<AbstractCanvasHandler, CanvasViolation>> commands = compositeCommand.getCommands();
assertNotNull(commands);
final DeleteCanvasConnectorCommand delete1 = (DeleteCanvasConnectorCommand) commands.get(0);
assertNotNull(delete1);
assertEquals(graphHolder.edge1, delete1.getCandidate());
final RemoveCanvasChildrenCommand c2 = (RemoveCanvasChildrenCommand) commands.get(1);
assertNotNull(c2);
assertEquals(graphHolder.parentNode, c2.getParent());
assertEquals(graphHolder.startNode, c2.getChildren().iterator().next());
final DeleteCanvasNodeCommand c3 = (DeleteCanvasNodeCommand) commands.get(2);
assertNotNull(c3);
assertEquals(graphHolder.startNode, c3.getCandidate());
assertEquals(CommandResult.Type.INFO, result.getType());
}
use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.
the class CloneConnectorCommandTest method newCanvasCommand.
@Test
@SuppressWarnings("unchecked")
public void newCanvasCommand() {
Command<AbstractCanvasHandler, CanvasViolation> command = cloneConnectorCommand.newCanvasCommand(context);
assertTrue(command instanceof CompositeCommand);
Consumer<Edge> cloneCallback = cloneConnectorCommand.getCloneCallback();
cloneCallback.accept(clone);
CompositeCommand compositeCommand = (CompositeCommand) command;
assertTrue(compositeCommand.getCommands().stream().anyMatch(c -> c instanceof AddCanvasConnectorCommand));
assertEquals(((AddCanvasConnectorCommand) compositeCommand.getCommands().stream().filter(c -> c instanceof AddCanvasConnectorCommand).findFirst().get()).getCandidate(), clone);
assertTrue(compositeCommand.getCommands().stream().anyMatch(c -> c instanceof SetCanvasConnectionCommand));
assertEquals(((SetCanvasConnectionCommand) compositeCommand.getCommands().stream().filter(c -> c instanceof SetCanvasConnectionCommand).findFirst().get()).getEdge(), clone);
}
use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.
the class BPMNGraphFactoryImplTest method testBuild.
@Test
@SuppressWarnings("unchecked")
public void testBuild() {
final Node diagramNode = mock(Node.class);
final Node startEventNode = mock(Node.class);
when(factoryManager.newElement(anyString(), eq(getDefinitionId(BPMNDiagramImpl.class)))).thenReturn(diagramNode);
final Graph<DefinitionSet, Node> graph = tested.build("uuid1", "defSetId");
assertNotNull(graph);
assertEquals("uuid1", graph.getUUID());
assertEquals(1, graph.getLabels().size());
assertTrue(graph.getLabels().contains("defSetId"));
final ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class);
verify(graphCommandFactory, times(1)).addNode(eq(diagramNode));
verify(graphCommandManager, times(1)).execute(any(GraphCommandExecutionContext.class), commandCaptor.capture());
final Command command = commandCaptor.getValue();
assertTrue(command instanceof CompositeCommand);
final CompositeCommand compositeCommand = (CompositeCommand) command;
assertEquals(1, compositeCommand.size());
}
use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.
the class CaseGraphFactoryImplTest method buildInitialisationCommands.
@Test
@SuppressWarnings("all")
public void buildInitialisationCommands() {
final List<Command> commands = tested.buildInitialisationCommands();
assertEquals(1, commands.size());
final AddNodeCommand addNodeCommand = (AddNodeCommand) commands.get(0);
assertEquals(addNodeCommand.getCandidate(), diagramNode);
}
Aggregations