### Question:
DataModelerScreenPresenter extends KieEditor<String> { @Override protected Promise<Void> makeMenuBar() { if (!workbenchContext.getActiveWorkspaceProject().isPresent()) { return promises.resolve(); } final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { final ParameterizedCommand<Boolean> onSave = withComments -> { saveWithComments = withComments; saveAction(); }; fileMenuBuilder.addSave(versionRecordManager.newSaveMenuItem(onSave)) .addCopy(() -> onCopy()) .addRename(() -> onSafeRename()) .addDelete(() -> onSafeDelete()); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder.addValidate(getValidateCommand()) .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } @Inject  DataModelerScreenPresenter(DataModelerScreenView baseView,
                                      SessionInfo sessionInfo); @WorkbenchPartTitle String getTitleText(); @WorkbenchPartTitleDecoration IsWidget getTitle(); @WorkbenchPartView IsWidget getView(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @OnFocus void onFocus(); @Override void showDocks(); @Override void hideDocks(); @OnMayClose boolean onMayClose(); @OnClose @Override void onClose(); void onSafeDelete(); void onSafeRename(); DataModel getDataModel(); String getSource(); void setSource(String source); @Override void onSourceTabSelected(); @Override void onOverviewSelected(); @Override void onEditTabSelected(); static final String EDITOR_ID; }### Answer:
@Test public void testMakeMenuBar() { final DataModelerScreenPresenter presenter = spy(this.presenter); doReturn(Optional.of(mock(WorkspaceProject.class))).when(workbenchContext).getActiveWorkspaceProject(); doReturn(promises.resolve(true)).when(projectController).canUpdateProject(any()); presenter.makeMenuBar(); verify(fileMenuBuilder).addSave(any(MenuItem.class)); verify(fileMenuBuilder).addCopy(any(Command.class)); verify(fileMenuBuilder).addRename(any(Command.class)); verify(fileMenuBuilder).addDelete(any(Command.class)); verify(fileMenuBuilder).addNewTopLevelMenu(alertsButtonMenuItem); verify(presenter).addDownloadMenuItem(fileMenuBuilder); }
@Test public void testMakeMenuBarWithoutUpdateProjectPermission() { 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(Command.class)); verify(fileMenuBuilder, never()).addRename(any(Command.class)); verify(fileMenuBuilder, never()).addDelete(any(Command.class)); verify(fileMenuBuilder).addNewTopLevelMenu(alertsButtonMenuItem); }