Search in sources :

Example 96 with Command

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

the class FocusableGroupTest method testHide.

@Test
public void testHide() {
    final Command before = mock(Command.class);
    final Command after = mock(Command.class);
    tested.hide(before, after);
    verify(groupItem, times(1)).hide(any(Command.class), eq(after));
    verify(groupItem, never()).show(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 97 with Command

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

the class GroupImplTest 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();
    verify(decorator, times(1)).show();
    verify(tooltip, times(1)).show();
}
Also used : Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 98 with Command

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

the class ItemGridImplTest method testHide.

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

Example 99 with Command

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

the class ItemGridImplTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    when(groupItem.getPrimitive()).thenReturn((IPrimitive) group);
    when(groupItem.asPrimitive()).thenReturn(group);
    when(groupItem.setBoundingBox(any(Supplier.class))).thenReturn(groupItem);
    when(groupItem.getGroupItem()).thenReturn(groupItemWrap);
    when(button1Prim.getLocation()).thenReturn(new Point2D(1, 1));
    when(button2Prim.getLocation()).thenReturn(new Point2D(3, 3));
    when(button1BB.getWidth()).thenReturn(10d);
    when(button1BB.getHeight()).thenReturn(10d);
    when(button2BB.getWidth()).thenReturn(2.2d);
    when(button2BB.getHeight()).thenReturn(2.2d);
    when(button1.getBoundingBox()).thenReturn(() -> button1BB);
    when(button1.asPrimitive()).thenReturn(button1Prim);
    when(button2.asPrimitive()).thenReturn(button2Prim);
    when(button2.getBoundingBox()).thenReturn(() -> button2BB);
    when(group.getAlpha()).thenReturn(0d);
    when(group.getComputedBoundingPoints()).thenReturn(boundingPoints);
    when(group.getBoundingBox()).thenReturn(boundingBox);
    when(group.getChildNodes()).thenReturn(groupChildren);
    when(groupChildren.size()).thenReturn(1);
    when(boundingPoints.getBoundingBox()).thenReturn(boundingBox);
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        when(group.getAlpha()).thenReturn(1d);
        when(groupItem.isVisible()).thenReturn(true);
        return groupItem;
    }).when(groupItem).show(any(Command.class), any(Command.class));
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[0]).execute();
        ((Command) invocationOnMock.getArguments()[1]).execute();
        when(group.getAlpha()).thenReturn(0d);
        when(groupItem.isVisible()).thenReturn(false);
        return groupItem;
    }).when(groupItem).hide(any(Command.class), any(Command.class));
    tested = new ItemGridImpl(groupItem).useHideExecutor(hideExecutor).useShowExecutor(showExecutor).grid(grid).add(button1).add(button2).onRefresh(refreshCallback);
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) Command(org.uberfire.mvp.Command) Supplier(java.util.function.Supplier) Before(org.junit.Before)

Example 100 with Command

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

the class ItemImplTest method testFocusExecutorDoingFocus.

@Test
public void testFocusExecutorDoingFocus() {
    final AbstractDecoratorItem decorator = mock(AbstractDecoratorItem.class);
    final Group decPrimitive = mock(Group.class);
    when(decorator.asPrimitive()).thenReturn(decPrimitive);
    final TooltipItem<?> tooltip = mock(TooltipItem.class);
    tested = new ItemImpl(groupItem, shape).setFocusDelay(0).setUnFocusDelay(0).decorate(decorator).tooltip(tooltip);
    final AbstractFocusableGroupItem<ItemImpl>.FocusGroupExecutor focusExecutor = spy(tested.getFocusGroupExecutor());
    doAnswer(invocationOnMock -> {
        ((Command) invocationOnMock.getArguments()[1]).execute();
        return null;
    }).when(focusExecutor).accept(any(Group.class), any(Command.class));
    focusExecutor.focus();
    verify(focusExecutor, times(1)).setAlpha(AbstractFocusableGroupItem.ALPHA_FOCUSED);
    verify(decorator, times(1)).show();
    verify(decPrimitive, times(1)).moveToBottom();
    verify(tooltip, times(1)).show();
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Command(org.uberfire.mvp.Command) AbstractDecoratorItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.AbstractDecoratorItem) Test(org.junit.Test)

Aggregations

Command (org.uberfire.mvp.Command)117 Test (org.junit.Test)66 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)15 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)11 Group (com.ait.lienzo.client.core.shape.Group)9 YesNoCancelPopup (org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup)9 Before (org.junit.Before)8 HasListSelectorControl (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl)7 Path (org.uberfire.backend.vfs.Path)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 PlaceRequest (org.uberfire.mvp.PlaceRequest)5 MenuItem (org.uberfire.workbench.model.menu.MenuItem)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)4 Inject (javax.inject.Inject)4 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)4 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)4 DeleteHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand)4 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)4 SetHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand)4