Search in sources :

Example 41 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class CommandRegistryListenerTest method testExecuteFailed.

@Test
@SuppressWarnings("unchecked")
public void testExecuteFailed() {
    Object context = mock(Object.class);
    Command command = mock(Command.class);
    CommandResult result = mock(CommandResult.class);
    when(result.getType()).thenReturn(CommandResult.Type.ERROR);
    tested.onExecute(context, command, result);
    verify(commandRegistry, times(0)).register(eq(command));
    verify(commandRegistry, times(0)).pop();
    verify(commandRegistry, times(0)).peek();
}
Also used : Command(org.kie.workbench.common.stunner.core.command.Command) CommandResult(org.kie.workbench.common.stunner.core.command.CommandResult) Test(org.junit.Test)

Example 42 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class RedoCommandHandlerTest method testExecuteRemoveRedoCommands.

@Test
@SuppressWarnings("unchecked")
public void testExecuteRemoveRedoCommands() {
    createRealRegistry();
    Command command3 = mock(Command.class);
    assertTrue(tested.onUndoCommandExecuted(command1));
    assertTrue(tested.onUndoCommandExecuted(command2));
    assertFalse(tested.onCommandExecuted(command3));
    assertFalse(tested.isEnabled());
}
Also used : Command(org.kie.workbench.common.stunner.core.command.Command) Test(org.junit.Test)

Example 43 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class CommandRegistryImplTest method testPop.

@Test
public void testPop() {
    tested.register(command);
    Command result = tested.pop();
    assertNotNull(result);
    assertEquals(command, result);
    List<Command> result2 = tested.getCommandHistory();
    assertNotNull(result2);
    assertTrue(result2.isEmpty());
}
Also used : Command(org.kie.workbench.common.stunner.core.command.Command) Test(org.junit.Test)

Example 44 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class CommandRegistryImplTest method testGetCommandHistory.

@Test
public void testGetCommandHistory() {
    tested.register(command);
    tested.register(command1);
    List<Command> result = tested.getCommandHistory();
    assertNotNull(result);
    Command r1 = result.get(0);
    assertNotNull(r1);
    assertEquals(command1, r1);
    Command r2 = result.get(1);
    assertNotNull(r2);
    assertEquals(command, r2);
}
Also used : Command(org.kie.workbench.common.stunner.core.command.Command) Test(org.junit.Test)

Example 45 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class NotificationsObserverTest method testNotifyCommandFailed.

@Test
@SuppressWarnings("unchecked")
public void testNotifyCommandFailed() {
    final Command command = mock(Command.class);
    final CommandResult<CanvasViolation> result = mock(CommandResult.class);
    final CanvasCommandExecutedEvent<? extends CanvasHandler> commandExecutedEvent = new CanvasCommandExecutedEvent<>(canvasHandler, command, result);
    commandNotification = new CommandNotification(Notification.Type.ERROR, notificationContext, command, "message1");
    tested.onGraphCommandExecuted(commandExecutedEvent);
    verify(onNotification, times(1)).execute(eq(commandNotification));
    verify(commandFailed, times(1)).execute(eq(commandNotification));
    verify(commandSuccess, never()).execute(any(CommandNotification.class));
    verify(validationSuccess, never()).execute(any(ValidationSuccessNotification.class));
    verify(validationFailed, never()).execute(any(ValidationFailedNotification.class));
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.kie.workbench.common.stunner.core.command.Command) CanvasCommandExecutedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandExecutedEvent) Test(org.junit.Test)

Aggregations

Command (org.kie.workbench.common.stunner.core.command.Command)74 Test (org.junit.Test)53 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)23 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)22 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)19 CompositeCommand (org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)16 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Node (org.kie.workbench.common.stunner.core.graph.Node)12 List (java.util.List)10 GraphCommandResultBuilder (org.kie.workbench.common.stunner.core.graph.command.GraphCommandResultBuilder)10 AbstractGraphCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand)10 View (org.kie.workbench.common.stunner.core.graph.content.view.View)9 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)7 Consumer (java.util.function.Consumer)6 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)6 ArrayList (java.util.ArrayList)5 AddNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddNodeCommand)5 Element (org.kie.workbench.common.stunner.core.graph.Element)5 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)5