GuidedDecisionTableGraphEditorPresenter extends BaseGuidedDecisionTableEditorPresenter implements HasSearchableElements<GuidedDecisionTableSearchableElement> { @Override public Promise<Void> makeMenuBar() { if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { fileMenuBuilder .addSave(getSaveMenuItem()) .addCopy(versionRecordManager::getCurrentPath, assetUpdateValidator) .addRename(getSaveAndRenameCommand()) .addDelete(versionRecordManager::getPathToLatest, assetUpdateValidator); } final FileMenuBuilder fileMenuBuilder = this.fileMenuBuilder .addValidate(() -> onValidate(getActiveDocument())) .addNewTopLevelMenu(getEditMenuItem()) .addNewTopLevelMenu(getViewMenuItem()) .addNewTopLevelMenu(getInsertMenuItem()) .addNewTopLevelMenu(getRadarMenuItem()) .addNewTopLevelMenu(getRegisteredDocumentsMenuItem()) .addNewTopLevelMenu(getVersionManagerMenuItem()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); addDownloadMenuItem(fileMenuBuilder); this.menus = fileMenuBuilder.build(); return promises.resolve(); }); } return promises.resolve(); } @Inject  GuidedDecisionTableGraphEditorPresenter(final View view,
                                                   final Caller<GuidedDecisionTableEditorService> service,
                                                   final AuthoringWorkbenchDocks docks,
                                                   final PerspectiveManager perspectiveManager,
                                                   final Caller<GuidedDecisionTableGraphEditorService> graphService,
                                                   final Caller<KieModuleService> moduleService,
                                                   final Caller<GuidedDecisionTableGraphSaveAndRenameService> graphSaveAndRenameService,
                                                   final Event<NotificationEvent> notification,
                                                   final Event<SaveInProgressEvent> saveInProgressEvent,
                                                   final Event<DecisionTableSelectedEvent> decisionTableSelectedEvent,
                                                   final GuidedDecisionTableDocksHandler guidedDecisionTableDocksHandler,
                                                   final AnalysisReportScreen analysisReportScreen,
                                                   final ValidationPopup validationPopup,
                                                   final GuidedDTableGraphResourceType dtGraphResourceType,
                                                   final EditMenuBuilder editMenuBuilder,
                                                   final ViewMenuBuilder viewMenuBuilder,
                                                   final InsertMenuBuilder insertMenuBuilder,
                                                   final RadarMenuBuilder radarMenuBuilder,
                                                   final GuidedDecisionTableModellerView.Presenter modeller,
                                                   final NewGuidedDecisionTableWizardHelper helper,
                                                   final SyncBeanManager beanManager,
                                                   final PlaceManager placeManager,
                                                   final LockManager lockManager,
                                                   final ColumnsPage columnsPage,
                                                   final SaveAndRenameCommandBuilder<List<GuidedDecisionTableEditorContent>, Metadata> saveAndRenameCommandBuilder,
                                                   final AlertsButtonMenuItemBuilder alertsButtonMenuItemBuilder,
                                                   final DownloadMenuItemBuilder downloadMenuItem,
                                                   final GuidedDecisionTableEditorSearchIndex editorSearchIndex,
                                                   final SearchBarComponent<GuidedDecisionTableSearchableElement> searchBarComponent,
                                                   final SearchableElementFactory searchableElementFactory,
                                                   final Event<SearchPerformedEvent> searchPerformedEvent); @PostConstruct void init(); @Override List<GuidedDecisionTableSearchableElement> getSearchableElements(); @Override @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest placeRequest); @Override @OnFocus void onFocus(); @Override void loadDocument(final ObservablePath path,
                             final PlaceRequest placeRequest); @Override @WorkbenchPartTitle String getTitleText(); @Override @WorkbenchPartView IsWidget getWidget(); @Override @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @Override @OnMayClose boolean mayClose(); @Override @OnClose void onClose(); @Override Promise<Void> makeMenuBar(); @Override void getAvailableDocumentPaths(final Callback<List<Path>> callback); @Override void onOpenDocumentsInEditor(final List<Path> selectedDocumentPaths); static final String IDENTIFIER; }
@Test public void testMakeMenuBarWithoutUpdateProjectPermission() { reset(fileMenuBuilder); doReturn(Optional.of(mock(WorkspaceProject.class))).when(workbenchContext).getActiveWorkspaceProject(); doReturn(promises.resolve(false)).when(projectController).canUpdateProject(any()); presenter.makeMenuBar(); verify(fileMenuBuilder, never()).addSave(any(MenuItem.class)); verify(fileMenuBuilder, never()).addCopy(any(BasicFileMenuBuilder.PathProvider.class), eq(assetUpdateValidator)); verify(fileMenuBuilder, never()).addRename(any(BasicFileMenuBuilder.PathProvider.class), eq(assetUpdateValidator)); verify(fileMenuBuilder, never()).addDelete(any(BasicFileMenuBuilder.PathProvider.class), eq(assetUpdateValidator)); verify(fileMenuBuilder, times(1)).addNewTopLevelMenu(alertsButtonMenuItem); }