Search in sources :

Example 1 with CanvasCommandUndoneEvent

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

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));
}
Also used : CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.kie.workbench.common.stunner.core.command.Command) CanvasCommandUndoneEvent(org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent) Test(org.junit.Test)

Example 3 with CanvasCommandUndoneEvent

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));
}
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) CanvasCommandUndoneEvent(org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent) Test(org.junit.Test)

Example 4 with CanvasCommandUndoneEvent

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

Aggregations

Test (org.junit.Test)4 CanvasCommandUndoneEvent (org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandUndoneEvent)4 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)2 AbstractClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand)2 EditorSession (org.kie.workbench.common.stunner.core.client.session.impl.EditorSession)2 Command (org.kie.workbench.common.stunner.core.command.Command)2 CompositeCommand (org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)2 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)2 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)1 CanvasHandlerImpl (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandlerImpl)1