Search in sources :

Example 51 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method testRegisterColumnResizeCompleted.

@Test
@SuppressWarnings("unchecked")
public void testRegisterColumnResizeCompleted() {
    final DMNGridColumn uiColumn = mockColumn(200.0, grid);
    grid.registerColumnResizeCompleted(uiColumn, 100.0);
    verify(sessionCommandManager).execute(eq(canvasHandler), commandCaptor.capture());
    final Command command = commandCaptor.getValue();
    assertThat(command).isInstanceOf(SetComponentWidthCommand.class);
}
Also used : DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) SetTypeRefCommand(org.kie.workbench.common.dmn.client.commands.general.SetTypeRefCommand) SetHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) DeleteHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand) DeleteCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteCellValueCommand) DeleteHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHasValueCommand) SetHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHasValueCommand) SetComponentWidthCommand(org.kie.workbench.common.dmn.client.commands.factory.canvas.SetComponentWidthCommand) Command(org.kie.workbench.common.stunner.core.command.Command) Test(org.junit.Test)

Example 52 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class NotificationsObserverTest method testNotifyCommandExecutionSuccess.

@Test
@SuppressWarnings("unchecked")
public void testNotifyCommandExecutionSuccess() {
    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 53 with Command

use of org.kie.workbench.common.stunner.core.command.Command 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 54 with Command

use of org.kie.workbench.common.stunner.core.command.Command 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 55 with Command

use of org.kie.workbench.common.stunner.core.command.Command in project kie-wb-common by kiegroup.

the class NotificationsObserverTest method testNotifyCommandExecutionFailed.

@Test
@SuppressWarnings("unchecked")
public void testNotifyCommandExecutionFailed() {
    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

Command (org.kie.workbench.common.stunner.core.command.Command)74 Test (org.junit.Test)53 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)23 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)22 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)19 CompositeCommand (org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)16 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Node (org.kie.workbench.common.stunner.core.graph.Node)12 List (java.util.List)10 GraphCommandResultBuilder (org.kie.workbench.common.stunner.core.graph.command.GraphCommandResultBuilder)10 AbstractGraphCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand)10 View (org.kie.workbench.common.stunner.core.graph.content.view.View)9 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)7 Consumer (java.util.function.Consumer)6 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)6 ArrayList (java.util.ArrayList)5 AddNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddNodeCommand)5 Element (org.kie.workbench.common.stunner.core.graph.Element)5 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)5