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();
}
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());
}
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());
}
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);
}
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));
}
Aggregations