Search in sources :

Example 1 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class GroupItemTest method testHide.

@Test
public void testHide() {
    when(group.getAlpha()).thenReturn(1d);
    final Command before = mock(Command.class);
    final Command after = mock(Command.class);
    tested.hide(before, after);
    verify(before, times(1)).execute();
    verify(hideExecutor, times(1)).accept(eq(group), eq(after));
    verify(showExecutor, never()).accept(any(Group.class), any(Command.class));
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 2 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class ButtonGridItemImplTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    buttonGroup = spy(new Group().setAlpha(0d));
    toolboxGroup = spy(new Group());
    when(buttonGroup.getComputedBoundingPoints()).thenReturn(buttonBoundingPoints);
    when(buttonGroup.getBoundingBox()).thenReturn(buttonBoundingBox);
    when(buttonBoundingPoints.getBoundingBox()).thenReturn(buttonBoundingBox);
    when(toolboxGroup.getComputedBoundingPoints()).thenReturn(toolboxBoundingPoints);
    when(toolboxGroup.getBoundingBox()).thenReturn(toolboxBoundingBox);
    when(toolboxBoundingPoints.getBoundingBox()).thenReturn(toolboxBoundingBox);
    when(button.getBoundingBox()).thenReturn(() -> buttonBoundingBox);
    when(button.asPrimitive()).thenReturn(buttonGroup);
    when(button.getPrimitive()).thenReturn(mock(IPrimitive.class));
    when(button.getWrapped()).thenReturn(buttonWrap);
    when(buttonWrap.registrations()).thenReturn(registrations);
    when(buttonWrap.asPrimitive()).thenReturn(buttonGroup);
    when(buttonWrap.getBoundingBox()).thenReturn(() -> buttonBoundingBox);
    when(toolbox.getBoundingBox()).thenReturn(() -> toolboxBoundingBox);
    when(toolbox.asPrimitive()).thenReturn(toolboxGroup);
    when(toolbox.getPrimitive()).thenReturn(mock(IPrimitive.class));
    when(toolbox.getAt()).thenReturn(Direction.SOUTH_EAST);
    when(toolbox.getWrapped()).thenReturn(toolboxWrap);
    when(toolboxWrap.asPrimitive()).thenReturn(toolboxGroup);
    when(toolboxWrap.getBoundingBox()).thenReturn(() -> toolboxBoundingBox);
    when(button1.getPrimitive()).thenReturn(button1Prim);
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return button;
    }).when(button).show(any(Command.class), any(Command.class));
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return button;
    }).when(button).hide(any(Command.class), any(Command.class));
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return toolbox;
    }).when(toolbox).show(any(Command.class), any(Command.class));
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return toolbox;
    }).when(toolbox).hide(any(Command.class), any(Command.class));
    tested = new ButtonGridItemImpl(button, toolbox).useHideExecutor(hideExecutor).useShowExecutor(showExecutor);
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Command(org.uberfire.mvp.Command) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) Before(org.junit.Before)

Example 3 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class ButtonGridItemImplTest method testShow.

@Test
public void testShow() {
    final Command before = mock(Command.class);
    final Command after = mock(Command.class);
    tested.show(before, after);
    verify(button, times(1)).show(eq(before), eq(after));
    verify(button, never()).hide(any(Command.class), any(Command.class));
    verify(toolbox, never()).hide(any(Command.class), any(Command.class));
    verify(toolbox, never()).hide(any(Command.class), any(Command.class));
    verify(before, times(1)).execute();
    verify(after, times(1)).execute();
}
Also used : Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 4 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class ButtonItemImplTest method testShow.

@Test
public void testShow() {
    final Command before = mock(Command.class);
    final Command after = mock(Command.class);
    tested.show(before, after);
    verify(groupItem, times(1)).show(eq(before), eq(after));
    verify(groupItem, never()).hide(any(Command.class), any(Command.class));
    verify(before, times(1)).execute();
    verify(after, times(1)).execute();
}
Also used : Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 5 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class FocusableGroupTest method testShow.

@Test
public void testShow() {
    final Command before = mock(Command.class);
    final Command after = mock(Command.class);
    tested.show(before, after);
    verify(groupItem, times(1)).show(any(Command.class), eq(after));
    verify(groupItem, never()).hide(any(Command.class), any(Command.class));
    verify(before, times(1)).execute();
    verify(after, times(1)).execute();
}
Also used : Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Aggregations

Command (org.uberfire.mvp.Command)243 Test (org.junit.Test)168 Path (org.uberfire.backend.vfs.Path)34 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)27 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)16 PlaceRequest (org.uberfire.mvp.PlaceRequest)16 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)15 IOException (org.uberfire.java.nio.IOException)13 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)12 ArrayList (java.util.ArrayList)11 Before (org.junit.Before)11 YesNoCancelPopup (org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup)10 Group (com.ait.lienzo.client.core.shape.Group)9 HasListSelectorControl (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl)9 UpdateElementPropertyCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand)9 CompositeCommand (org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)9 DefaultPlaceRequest (org.uberfire.mvp.impl.DefaultPlaceRequest)9 IsWidget (com.google.gwt.user.client.ui.IsWidget)8 Collection (java.util.Collection)8 Inject (javax.inject.Inject)8