use of org.uberfire.ext.widgets.common.client.menu.MenuItemFactory in project drools-wb by kiegroup.
the class InsertMenuBuilderTest method setup.
@Before
public void setup() {
model = new GuidedDecisionTable52();
uiModel = new GuidedDecisionTableUiModel(mock(ModelSynchronizer.class));
final MenuItemFactory menuItemFactory = new MenuItemFactory(menuItemViewProducer);
when(dtPresenter.hasEditableColumns()).thenReturn(true);
when(dtPresenter.getView()).thenReturn(dtPresenterView);
when(dtPresenter.getModel()).thenReturn(model);
when(dtPresenter.getAccess()).thenReturn(access);
when(dtPresenterView.getModel()).thenReturn(uiModel);
when(translationService.getTranslation(any(String.class))).thenReturn("i18n");
when(menuItemViewProducer.select(any(Annotation.class))).thenReturn(menuItemViewProducer);
when(menuItemViewProducer.get()).thenReturn(mock(MenuItemWithIconView.class));
uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
builder = spy(new InsertMenuBuilder(translationService, menuItemFactory, wizardManagedInstance));
builder.setup();
builder.setModeller(modeller);
}
use of org.uberfire.ext.widgets.common.client.menu.MenuItemFactory in project drools-wb by kiegroup.
the class EditMenuBuilderTest method setup.
@Before
public void setup() {
model = new GuidedDecisionTable52();
uiModel = new GuidedDecisionTableUiModel(mock(ModelSynchronizer.class));
clipboard = new DefaultClipboard();
final MenuItemFactory menuItemFactory = new MenuItemFactory(menuItemViewProducer);
when(dtPresenter.hasEditableColumns()).thenReturn(true);
when(dtPresenter.getView()).thenReturn(dtPresenterView);
when(dtPresenter.getModel()).thenReturn(model);
when(dtPresenter.getAccess()).thenReturn(access);
when(dtPresenterView.getModel()).thenReturn(uiModel);
when(ts.getTranslation(any(String.class))).thenReturn("i18n");
when(menuItemViewProducer.select(any(Annotation.class))).thenReturn(menuItemViewProducer);
when(menuItemViewProducer.get()).thenReturn(menuItemWithIconView);
when(menuItemWithIconView.getElement()).thenReturn(menuItemHTMLElement);
uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
uiModel.appendColumn(new BaseGridColumn<>(headerMetaData, gridColumnRenderer, 100));
uiModel.appendRow(new BaseGridRow());
builder = spy(new EditMenuBuilder(clipboard, ts, menuItemFactory, popoverUtils));
builder.setup();
}
use of org.uberfire.ext.widgets.common.client.menu.MenuItemFactory 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();
}
use of org.uberfire.ext.widgets.common.client.menu.MenuItemFactory 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);
}
Aggregations