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