use of org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent in project kie-wb-common by kiegroup.
the class RedoSessionCommandTest method testNotifyRedoSuccess.
@Test
@SuppressWarnings("unchecked")
public void testNotifyRedoSuccess() {
RedoSessionCommand command = spy(new RedoSessionCommand(sessionCommandManager, redoCommandHandler));
doCallRealMethod().when(command).onCommandUndoExecuted(any(CanvasCommandUndoneEvent.class));
doCallRealMethod().when(command).bind(any(EditorSession.class));
when(session.getCanvasHandler()).thenReturn(canvasHandler);
when(session.getKeyboardControl()).thenReturn(keyboardControl);
when(keyboardControl.addKeyShortcutCallback(any(KeyboardControl.KeyShortcutCallback.class))).thenReturn(keyboardControl);
((AbstractClientSessionCommand) command).bind(session);
CanvasCommandUndoneEvent event = new CanvasCommandUndoneEvent(canvasHandler, new CompositeCommand(true), null);
command.onCommandUndoExecuted(event);
verify(redoCommandHandler, times(1)).onUndoCommandExecuted(event.getCommand());
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent in project kie-wb-common by kiegroup.
the class NotificationsObserverTest method testNotifyCommandUndoSuccess.
@Test
@SuppressWarnings("unchecked")
public void testNotifyCommandUndoSuccess() {
final Command command = mock(Command.class);
final CommandResult<CanvasViolation> result = mock(CommandResult.class);
final CanvasCommandUndoneEvent<CanvasHandler> commandExecutedEvent = new CanvasCommandUndoneEvent<>(canvasHandler, command, result);
commandNotification = new CommandNotification(Notification.Type.INFO, notificationContext, command, "message1");
tested.onCanvasCommandUndoneEvent(commandExecutedEvent);
verify(onNotification, times(1)).execute(eq(commandNotification));
verify(commandSuccess, times(1)).execute(eq(commandNotification));
verify(commandFailed, never()).execute(any(CommandNotification.class));
verify(validationSuccess, never()).execute(any(ValidationSuccessNotification.class));
verify(validationFailed, never()).execute(any(ValidationFailedNotification.class));
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent in project kie-wb-common by kiegroup.
the class NotificationsObserverTest method testNotifyCommandUndoFailed.
@Test
@SuppressWarnings("unchecked")
public void testNotifyCommandUndoFailed() {
final Command command = mock(Command.class);
final CommandResult<CanvasViolation> result = mock(CommandResult.class);
final CanvasCommandUndoneEvent<? extends CanvasHandler> commandExecutedEvent = new CanvasCommandUndoneEvent<>(canvasHandler, command, result);
commandNotification = new CommandNotification(Notification.Type.ERROR, notificationContext, command, "message1");
tested.onCanvasCommandUndoneEvent(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));
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent in project kie-wb-common by kiegroup.
the class RedoSessionCommandTest method testNotifyRedoFails.
@Test
@SuppressWarnings("unchecked")
public void testNotifyRedoFails() {
RedoSessionCommand command = spy(new RedoSessionCommand(sessionCommandManager, redoCommandHandler));
doCallRealMethod().when(command).onCommandUndoExecuted(any(CanvasCommandUndoneEvent.class));
doCallRealMethod().when(command).bind(any(EditorSession.class));
when(session.getCanvasHandler()).thenReturn(new CanvasHandlerImpl(null, null, null, null, null, null, null, null, null, null, null));
when(session.getKeyboardControl()).thenReturn(keyboardControl);
when(keyboardControl.addKeyShortcutCallback(any(KeyboardControl.KeyShortcutCallback.class))).thenReturn(keyboardControl);
((AbstractClientSessionCommand) command).bind(session);
CanvasCommandUndoneEvent event = new CanvasCommandUndoneEvent(canvasHandler, new CompositeCommand(true), null);
command.onCommandUndoExecuted(event);
verify(redoCommandHandler, times(0)).onUndoCommandExecuted(event.getCommand());
}
Aggregations