use of org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand 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.session.command.AbstractClientSessionCommand in project kie-wb-common by kiegroup.
the class RedoSessionCommandTest method testOnCommandExecutedSuccess.
@Test
public void testOnCommandExecutedSuccess() {
RedoSessionCommand command = spy(new RedoSessionCommand(sessionCommandManager, redoCommandHandler));
doCallRealMethod().when(command).onCommandExecuted(any(CanvasCommandExecutedEvent.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);
CanvasCommandExecutedEvent event = new CanvasCommandExecutedEvent(canvasHandler, new CompositeCommand(true), null);
command.onCommandExecuted(event);
verify(redoCommandHandler, times(1)).onCommandExecuted(event.getCommand());
}
use of org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand 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());
}
use of org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand in project kie-wb-common by kiegroup.
the class RedoSessionCommandTest method testOnCommandExecutedFails.
public void testOnCommandExecutedFails() {
RedoSessionCommand command = spy(new RedoSessionCommand(sessionCommandManager, redoCommandHandler));
doCallRealMethod().when(command).onCommandExecuted(any(CanvasCommandExecutedEvent.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);
CanvasCommandExecutedEvent event = new CanvasCommandExecutedEvent(canvasHandler, new CompositeCommand(true), null);
command.onCommandExecuted(event);
verify(redoCommandHandler, times(0)).onCommandExecuted(event.getCommand());
}
Aggregations