Search in sources :

Example 1 with MenuItemDividerView

use of org.uberfire.ext.widgets.common.client.menu.MenuItemDividerView in project drools-wb by kiegroup.

the class ViewMenuBuilderTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    menuItemFactory = new MenuItemFactory(menuItemViewProducer);
    menuItemFactoryViewMocks.clear();
    when(dtPresenter.getAccess()).thenReturn(access);
    when(ts.getTranslation(any(String.class))).thenReturn("i18n");
    when(menuItemViewProducer.select(any(Annotation.class))).thenAnswer((o) -> {
        final Annotation a = (Annotation) o.getArguments()[0];
        if (a.annotationType().equals(MenuItemHeader.class)) {
            return menuItemViewHeaderProducer;
        } else if (a.annotationType().equals(MenuItemWithIcon.class)) {
            return menuItemViewWithIconProducer;
        } else if (a.annotationType().equals(MenuItemDivider.class)) {
            return menuItemViewDividerProducer;
        }
        throw new IllegalArgumentException("Unexpected MenuItemView");
    });
    when(menuItemViewHeaderProducer.get()).then(invocation -> {
        final MenuItemHeaderView v = mock(MenuItemHeaderView.class);
        menuItemFactoryViewMocks.add(v);
        return v;
    });
    when(menuItemViewWithIconProducer.get()).then(invocation -> {
        final MenuItemWithIconView v = mock(MenuItemWithIconView.class);
        menuItemFactoryViewMocks.add(v);
        return v;
    });
    when(menuItemViewDividerProducer.get()).then(invocation -> {
        final MenuItemDividerView v = mock(MenuItemDividerView.class);
        menuItemFactoryViewMocks.add(v);
        return v;
    });
    builder = spy(new ViewMenuBuilder(ts, menuItemFactory));
    builder.setup();
    builder.setModeller(modeller);
}
Also used : MenuItemWithIconView(org.uberfire.ext.widgets.common.client.menu.MenuItemWithIconView) MenuItemDividerView(org.uberfire.ext.widgets.common.client.menu.MenuItemDividerView) MenuItemFactory(org.uberfire.ext.widgets.common.client.menu.MenuItemFactory) MenuItemWithIcon(org.uberfire.ext.widgets.common.client.menu.MenuItemWithIcon) MenuItemHeaderView(org.uberfire.ext.widgets.common.client.menu.MenuItemHeaderView) Annotation(java.lang.annotation.Annotation) Before(org.junit.Before)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Before (org.junit.Before)1 MenuItemDividerView (org.uberfire.ext.widgets.common.client.menu.MenuItemDividerView)1 MenuItemFactory (org.uberfire.ext.widgets.common.client.menu.MenuItemFactory)1 MenuItemHeaderView (org.uberfire.ext.widgets.common.client.menu.MenuItemHeaderView)1 MenuItemWithIcon (org.uberfire.ext.widgets.common.client.menu.MenuItemWithIcon)1 MenuItemWithIconView (org.uberfire.ext.widgets.common.client.menu.MenuItemWithIconView)1