Search in sources :

Example 1 with CanvasCommandExecutedEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandExecutedEvent in project kie-wb-common by kiegroup.

the class NotificationsObserverTest method testNotifyCommandSuccess.

@Test
@SuppressWarnings("unchecked")
public void testNotifyCommandSuccess() {
    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.INFO, notificationContext, command, "message1");
    tested.onGraphCommandExecuted(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 : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.kie.workbench.common.stunner.core.command.Command) CanvasCommandExecutedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandExecutedEvent) Test(org.junit.Test)

Example 2 with CanvasCommandExecutedEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandExecutedEvent in project kie-wb-common by kiegroup.

the class UndoSessionCommandTest method testOnCommandExecuted.

@Test
@SuppressWarnings("unchecked")
public void testOnCommandExecuted() {
    command.bind(session);
    command.listen(statusCallback);
    ((UndoSessionCommand) command).onCommandExecuted(new CanvasCommandExecutedEvent(null, null, null));
    assertFalse(command.isEnabled());
    commandHistory.add(mock(Command.class));
    ((UndoSessionCommand) command).onCommandExecuted(new CanvasCommandExecutedEvent(null, null, null));
    assertTrue(command.isEnabled());
    verify(statusCallback, times(2)).execute();
}
Also used : AbstractClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) Command(org.kie.workbench.common.stunner.core.command.Command) CanvasCommandExecutedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandExecutedEvent) Test(org.junit.Test)

Example 3 with CanvasCommandExecutedEvent

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

Aggregations

Test (org.junit.Test)3 CanvasCommandExecutedEvent (org.kie.workbench.common.stunner.core.client.canvas.event.command.CanvasCommandExecutedEvent)3 Command (org.kie.workbench.common.stunner.core.command.Command)3 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)2 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)2 AbstractClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.AbstractClientSessionCommand)1 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)1