Search in sources :

Example 1 with InsertMenuBuilder

use of org.drools.workbench.screens.guided.dtable.client.editor.menu.InsertMenuBuilder in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorMenusTest method setup.

@Before
public void setup() {
    when(alertsButtonMenuItemBuilder.build()).thenReturn(alertsButtonMenuItem);
    when(modeller.getView()).thenReturn(modellerView);
    when(versionRecordManager.newSaveMenuItem(any(Command.class))).thenReturn(saveMenuItem);
    when(versionRecordManager.buildMenu()).thenReturn(versionManagerMenuItem);
    when(ts.getTranslation(any(String.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
    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()).thenReturn(mock(MenuItemHeaderView.class));
    when(menuItemViewDividerProducer.get()).thenReturn(mock(MenuItemDividerView.class));
    when(menuItemViewWithIconProducer.get()).thenReturn(menuItemWithIconView);
    when(menuItemWithIconView.getElement()).thenReturn(mock(HTMLElement.class));
    this.dtServiceCaller = new CallerMock<>(dtService);
    this.versionServiceCaller = new CallerMock<>(versionService);
    this.menuItemFactory = new MenuItemFactory(menuItemViewProducer);
    this.editMenuBuilder = new EditMenuBuilder(clipboard, ts, menuItemFactory, popoverUtils);
    this.editMenuBuilder.setup();
    this.insertMenuBuilder = new InsertMenuBuilder(ts, menuItemFactory, wizardManagedInstance);
    this.insertMenuBuilder.setup();
    this.insertMenuBuilder.setModeller(modeller);
    this.viewMenuBuilder = new ViewMenuBuilder(ts, menuItemFactory);
    this.viewMenuBuilder.setup();
    this.viewMenuBuilder.setModeller(modeller);
    this.radarMenuBuilder = new RadarMenuBuilder(radarMenuView);
    this.radarMenuBuilder.setup();
    final GuidedDecisionTableEditorPresenter wrapped = new GuidedDecisionTableEditorPresenter(view, dtServiceCaller, notification, decisionTableSelectedEvent, validationPopup, resourceType, editMenuBuilder, viewMenuBuilder, insertMenuBuilder, radarMenuBuilder, modeller, beanManager, placeManager, columnsPage, saveAndRenameCommandBuilder, alertsButtonMenuItemBuilder) {

        @Override
        protected Command getSaveAndRenameCommand() {
            return mock(Command.class);
        }
    };
    wrapped.setKieEditorWrapperView(kieEditorWrapperView);
    wrapped.setOverviewWidget(overviewWidget);
    wrapped.setSavePopUpPresenter(savePopUpPresenter);
    wrapped.setImportsWidget(importsWidget);
    wrapped.setNotificationEvent(notificationEvent);
    wrapped.setChangeTitleEvent(changeTitleEvent);
    wrapped.setWorkbenchContext(workbenchContext);
    wrapped.setVersionRecordManager(versionRecordManager);
    wrapped.setRegisteredDocumentsMenuBuilder(registeredDocumentsMenuBuilder);
    wrapped.setFileMenuBuilder(fileMenuBuilder);
    wrapped.setFileNameValidator(fileNameValidator);
    this.presenter = spy(wrapped);
    when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
    when(workbenchContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    presenter.init();
    presenter.setupMenuBar();
}
Also used : HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) MenuItemFactory(org.uberfire.ext.widgets.common.client.menu.MenuItemFactory) EditMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.EditMenuBuilder) RadarMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.RadarMenuBuilder) Annotation(java.lang.annotation.Annotation) MenuItemDividerView(org.uberfire.ext.widgets.common.client.menu.MenuItemDividerView) InsertMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.InsertMenuBuilder) ViewMenuBuilder(org.drools.workbench.screens.guided.dtable.client.editor.menu.ViewMenuBuilder) Command(org.uberfire.mvp.Command) MenuItemCommand(org.uberfire.workbench.model.menu.MenuItemCommand) MenuItemWithIcon(org.uberfire.ext.widgets.common.client.menu.MenuItemWithIcon) MenuItemHeaderView(org.uberfire.ext.widgets.common.client.menu.MenuItemHeaderView) Before(org.junit.Before)

Aggregations

Annotation (java.lang.annotation.Annotation)1 EditMenuBuilder (org.drools.workbench.screens.guided.dtable.client.editor.menu.EditMenuBuilder)1 InsertMenuBuilder (org.drools.workbench.screens.guided.dtable.client.editor.menu.InsertMenuBuilder)1 RadarMenuBuilder (org.drools.workbench.screens.guided.dtable.client.editor.menu.RadarMenuBuilder)1 ViewMenuBuilder (org.drools.workbench.screens.guided.dtable.client.editor.menu.ViewMenuBuilder)1 HTMLElement (org.jboss.errai.common.client.dom.HTMLElement)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 Command (org.uberfire.mvp.Command)1 MenuItemCommand (org.uberfire.workbench.model.menu.MenuItemCommand)1