Search in sources :

Example 1 with AbstractClientSessionCommand

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());
}
Also used : AbstractClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand) CanvasCommandUndoneEvent(org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent) EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) Test(org.junit.Test)

Example 2 with AbstractClientSessionCommand

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());
}
Also used : AbstractClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand) EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) CanvasCommandExecutedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandExecutedEvent) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) Test(org.junit.Test)

Example 3 with AbstractClientSessionCommand

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());
}
Also used : AbstractClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand) CanvasHandlerImpl(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandlerImpl) CanvasCommandUndoneEvent(org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent) EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) Test(org.junit.Test)

Example 4 with AbstractClientSessionCommand

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());
}
Also used : AbstractClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand) EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) CanvasCommandExecutedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandExecutedEvent) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)

Aggregations

AbstractClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand)4 EditorSession (org.kie.workbench.common.stunner.core.client.session.impl.EditorSession)4 CompositeCommand (org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)4 Test (org.junit.Test)3 CanvasCommandExecutedEvent (org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandExecutedEvent)2 CanvasCommandUndoneEvent (org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent)2 CanvasHandlerImpl (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandlerImpl)1