@Test public void singleAppSelection_public_onAppSelectionChanged() { AppSelectionChangedEvent eventMock = mock(AppSelectionChangedEvent.class); App appMock = mock(App.class); when(appMock.getPermission()).thenReturn(PermissionValue.read); when(appMock.getAppType()).thenReturn("DE"); when(appMock.getStepCount()).thenReturn(1); when(appMock.isPublic()).thenReturn(true); List<App> singleAppSelection = Lists.newArrayList(appMock); when(eventMock.getAppSelection()).thenReturn(singleAppSelection); when(currentSelectionMock.size()).thenReturn(singleAppSelection.size()); when(currentSelectionMock.get(eq(0))).thenReturn(singleAppSelection.get(0)); when(appMock.getIntegratorEmail()).thenReturn("user@email.com"); when(mockUserInfo.getEmail()).thenReturn("notCurrentUser@dongle.com"); uut.onAppSelectionChanged(eventMock); verify(currentSelectionMock).clear(); verify(currentSelectionMock).addAll(eq(singleAppSelection)); verify(mockAppMenu).setEnabled(eq(true)); verify(mockWfMenu).setEnabled(eq(true)); verify(mockDeleteApp).setEnabled(false); verify(mockEditApp).setEnabled(false); verify(mockCopyApp).setEnabled(true); verify(mockAppRun).setEnabled(true); verify(mockDeleteWf).setEnabled(false); verify(mockEditWf).setEnabled(false); verify(mockCopyWf).setEnabled(false); verify(mockWfRun).setEnabled(false); verify(mockshareMenuButton).setEnabled(false); verify(mockShareCollab).setEnabled(false); verify(mockSharePublic).setEnabled(false); verifyNoMoreInteractions(mockAppMenu, mockWfMenu, mockAppRun, mockCopyApp, mockCopyApp, mockCopyWf, mockCreateNewApp, mockCreateWorkflow, mockDeleteApp, mockDeleteWf, mockEditApp, mockEditWf, mockRequestTool, mockWfRun, mockShareCollab, mockSharePublic); verifyZeroInteractions(appSearchMock); }
@Override public void onAppSelectionChanged(final AppSelectionChangedEvent event) { app_menu.setEnabled(true); wf_menu.setEnabled(true); currentSelection.clear(); currentSelection.addAll(event.getAppSelection()); boolean deleteAppEnabled, editAppEnabled, submitAppEnabled, copyAppEnabled, appRunEnabled; boolean deleteWfEnabled, editWfEnabled, copyWfEnabled, wfRunEnabled, shareWithCollaboratorsMiEnabled; switch (currentSelection.size()) { case 0: deleteAppEnabled = false; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = false; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = false; break; case 1: final App selectedApp = currentSelection.get(0); final boolean isOwner = hasOwnerPermission(selectedApp); final boolean isEditable = isOwner || hasWritePermission(selectedApp) || isIntegrator(selectedApp); final boolean isCopyable = isEditable || hasReadPermission(selectedApp); final boolean isSingleStep = selectedApp.getStepCount() == 1; final boolean isMultiStep = selectedApp.getStepCount() > 1; final boolean isAppPublic = selectedApp.isPublic(); final boolean isAppDisabled = selectedApp.isDisabled(); final boolean isRunnable = selectedApp.isRunnable(); deleteAppEnabled = isSingleStep && !isAppPublic && isOwner; editAppEnabled = isSingleStep && isEditable; submitAppEnabled = isRunnable && !isAppPublic && isOwner; copyAppEnabled = isSingleStep && isCopyable; appRunEnabled = isSingleStep && !isAppDisabled; deleteWfEnabled = isMultiStep && !isAppPublic && isOwner; editWfEnabled = isMultiStep && !isAppPublic && isEditable; copyWfEnabled = isMultiStep && isCopyable; wfRunEnabled = isMultiStep && !isAppDisabled; GWT.log(selectedApp.getPermission() + "&&--&&"); shareWithCollaboratorsMiEnabled = containsSharableApps(Arrays.asList(selectedApp)); break; default: final boolean containsSingleStepApp = containsSingleStepApp(currentSelection); final boolean containsMultiStepApp = containsMultiStepApp(currentSelection); final boolean allSelectedAppsPrivate = allAppsPrivate(currentSelection); deleteAppEnabled = containsSingleStepApp && allSelectedAppsPrivate; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = containsMultiStepApp && allSelectedAppsPrivate; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = containsSharableApps(currentSelection); } shareMenuButton.setEnabled(submitAppEnabled || shareWithCollaboratorsMiEnabled); deleteApp.setEnabled(deleteAppEnabled); editApp.setEnabled(editAppEnabled); sharePublic.setEnabled(submitAppEnabled); GWT.log("menu enabled->" + shareWithCollaboratorsMiEnabled); shareCollab.setEnabled(shareWithCollaboratorsMiEnabled); copyApp.setEnabled(copyAppEnabled); appRun.setEnabled(appRunEnabled); deleteWf.setEnabled(deleteWfEnabled); editWf.setEnabled(editWfEnabled); copyWf.setEnabled(copyWfEnabled); wfRun.setEnabled(wfRunEnabled); }
AppsViewToolbarImpl extends Composite implements AppsToolbarView { @Override public void onAppSelectionChanged(final AppSelectionChangedEvent event) { app_menu.setEnabled(true); wf_menu.setEnabled(true); currentSelection.clear(); currentSelection.addAll(event.getAppSelection()); boolean deleteAppEnabled, editAppEnabled, submitAppEnabled, copyAppEnabled, appRunEnabled; boolean deleteWfEnabled, editWfEnabled, copyWfEnabled, wfRunEnabled, shareWithCollaboratorsMiEnabled; switch (currentSelection.size()) { case 0: deleteAppEnabled = false; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = false; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = false; break; case 1: final App selectedApp = currentSelection.get(0); final boolean isOwner = hasOwnerPermission(selectedApp); final boolean isEditable = isOwner || hasWritePermission(selectedApp) || isIntegrator(selectedApp); final boolean isCopyable = isEditable || hasReadPermission(selectedApp); final boolean isSingleStep = selectedApp.getStepCount() == 1; final boolean isMultiStep = selectedApp.getStepCount() > 1; final boolean isAppPublic = selectedApp.isPublic(); final boolean isAppDisabled = selectedApp.isDisabled(); final boolean isRunnable = selectedApp.isRunnable(); deleteAppEnabled = isSingleStep && !isAppPublic && isOwner; editAppEnabled = isSingleStep && isEditable; submitAppEnabled = isRunnable && !isAppPublic && isOwner; copyAppEnabled = isSingleStep && isCopyable; appRunEnabled = isSingleStep && !isAppDisabled; deleteWfEnabled = isMultiStep && !isAppPublic && isOwner; editWfEnabled = isMultiStep && !isAppPublic && isEditable; copyWfEnabled = isMultiStep && isCopyable; wfRunEnabled = isMultiStep && !isAppDisabled; GWT.log(selectedApp.getPermission() + "&&--&&"); shareWithCollaboratorsMiEnabled = containsSharableApps(Arrays.asList(selectedApp)); break; default: final boolean containsSingleStepApp = containsSingleStepApp(currentSelection); final boolean containsMultiStepApp = containsMultiStepApp(currentSelection); final boolean allSelectedAppsPrivate = allAppsPrivate(currentSelection); deleteAppEnabled = containsSingleStepApp && allSelectedAppsPrivate; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = containsMultiStepApp && allSelectedAppsPrivate; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = containsSharableApps(currentSelection); } shareMenuButton.setEnabled(submitAppEnabled || shareWithCollaboratorsMiEnabled); deleteApp.setEnabled(deleteAppEnabled); editApp.setEnabled(editAppEnabled); sharePublic.setEnabled(submitAppEnabled); GWT.log("menu enabled->" + shareWithCollaboratorsMiEnabled); shareCollab.setEnabled(shareWithCollaboratorsMiEnabled); copyApp.setEnabled(copyAppEnabled); appRun.setEnabled(appRunEnabled); deleteWf.setEnabled(deleteWfEnabled); editWf.setEnabled(editWfEnabled); copyWf.setEnabled(copyWfEnabled); wfRun.setEnabled(wfRunEnabled); } }
AppsViewToolbarImpl extends Composite implements AppsToolbarView { @Override public void onAppSelectionChanged(final AppSelectionChangedEvent event) { app_menu.setEnabled(true); wf_menu.setEnabled(true); currentSelection.clear(); currentSelection.addAll(event.getAppSelection()); boolean deleteAppEnabled, editAppEnabled, submitAppEnabled, copyAppEnabled, appRunEnabled; boolean deleteWfEnabled, editWfEnabled, copyWfEnabled, wfRunEnabled, shareWithCollaboratorsMiEnabled; switch (currentSelection.size()) { case 0: deleteAppEnabled = false; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = false; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = false; break; case 1: final App selectedApp = currentSelection.get(0); final boolean isOwner = hasOwnerPermission(selectedApp); final boolean isEditable = isOwner || hasWritePermission(selectedApp) || isIntegrator(selectedApp); final boolean isCopyable = isEditable || hasReadPermission(selectedApp); final boolean isSingleStep = selectedApp.getStepCount() == 1; final boolean isMultiStep = selectedApp.getStepCount() > 1; final boolean isAppPublic = selectedApp.isPublic(); final boolean isAppDisabled = selectedApp.isDisabled(); final boolean isRunnable = selectedApp.isRunnable(); deleteAppEnabled = isSingleStep && !isAppPublic && isOwner; editAppEnabled = isSingleStep && isEditable; submitAppEnabled = isRunnable && !isAppPublic && isOwner; copyAppEnabled = isSingleStep && isCopyable; appRunEnabled = isSingleStep && !isAppDisabled; deleteWfEnabled = isMultiStep && !isAppPublic && isOwner; editWfEnabled = isMultiStep && !isAppPublic && isEditable; copyWfEnabled = isMultiStep && isCopyable; wfRunEnabled = isMultiStep && !isAppDisabled; GWT.log(selectedApp.getPermission() + "&&--&&"); shareWithCollaboratorsMiEnabled = containsSharableApps(Arrays.asList(selectedApp)); break; default: final boolean containsSingleStepApp = containsSingleStepApp(currentSelection); final boolean containsMultiStepApp = containsMultiStepApp(currentSelection); final boolean allSelectedAppsPrivate = allAppsPrivate(currentSelection); deleteAppEnabled = containsSingleStepApp && allSelectedAppsPrivate; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = containsMultiStepApp && allSelectedAppsPrivate; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = containsSharableApps(currentSelection); } shareMenuButton.setEnabled(submitAppEnabled || shareWithCollaboratorsMiEnabled); deleteApp.setEnabled(deleteAppEnabled); editApp.setEnabled(editAppEnabled); sharePublic.setEnabled(submitAppEnabled); GWT.log("menu enabled->" + shareWithCollaboratorsMiEnabled); shareCollab.setEnabled(shareWithCollaboratorsMiEnabled); copyApp.setEnabled(copyAppEnabled); appRun.setEnabled(appRunEnabled); deleteWf.setEnabled(deleteWfEnabled); editWf.setEnabled(editWfEnabled); copyWf.setEnabled(copyWfEnabled); wfRun.setEnabled(wfRunEnabled); } @Inject  AppsViewToolbarImpl(final AppsToolbarAppearance appearance,
                        @Assisted
                        final PagingLoader<FilterPagingLoadConfig, PagingLoadResult<App>> loader); }
AppsViewToolbarImpl extends Composite implements AppsToolbarView { @Override public void onAppSelectionChanged(final AppSelectionChangedEvent event) { app_menu.setEnabled(true); wf_menu.setEnabled(true); currentSelection.clear(); currentSelection.addAll(event.getAppSelection()); boolean deleteAppEnabled, editAppEnabled, submitAppEnabled, copyAppEnabled, appRunEnabled; boolean deleteWfEnabled, editWfEnabled, copyWfEnabled, wfRunEnabled, shareWithCollaboratorsMiEnabled; switch (currentSelection.size()) { case 0: deleteAppEnabled = false; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = false; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = false; break; case 1: final App selectedApp = currentSelection.get(0); final boolean isOwner = hasOwnerPermission(selectedApp); final boolean isEditable = isOwner || hasWritePermission(selectedApp) || isIntegrator(selectedApp); final boolean isCopyable = isEditable || hasReadPermission(selectedApp); final boolean isSingleStep = selectedApp.getStepCount() == 1; final boolean isMultiStep = selectedApp.getStepCount() > 1; final boolean isAppPublic = selectedApp.isPublic(); final boolean isAppDisabled = selectedApp.isDisabled(); final boolean isRunnable = selectedApp.isRunnable(); deleteAppEnabled = isSingleStep && !isAppPublic && isOwner; editAppEnabled = isSingleStep && isEditable; submitAppEnabled = isRunnable && !isAppPublic && isOwner; copyAppEnabled = isSingleStep && isCopyable; appRunEnabled = isSingleStep && !isAppDisabled; deleteWfEnabled = isMultiStep && !isAppPublic && isOwner; editWfEnabled = isMultiStep && !isAppPublic && isEditable; copyWfEnabled = isMultiStep && isCopyable; wfRunEnabled = isMultiStep && !isAppDisabled; GWT.log(selectedApp.getPermission() + "&&--&&"); shareWithCollaboratorsMiEnabled = containsSharableApps(Arrays.asList(selectedApp)); break; default: final boolean containsSingleStepApp = containsSingleStepApp(currentSelection); final boolean containsMultiStepApp = containsMultiStepApp(currentSelection); final boolean allSelectedAppsPrivate = allAppsPrivate(currentSelection); deleteAppEnabled = containsSingleStepApp && allSelectedAppsPrivate; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = containsMultiStepApp && allSelectedAppsPrivate; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = containsSharableApps(currentSelection); } shareMenuButton.setEnabled(submitAppEnabled || shareWithCollaboratorsMiEnabled); deleteApp.setEnabled(deleteAppEnabled); editApp.setEnabled(editAppEnabled); sharePublic.setEnabled(submitAppEnabled); GWT.log("menu enabled->" + shareWithCollaboratorsMiEnabled); shareCollab.setEnabled(shareWithCollaboratorsMiEnabled); copyApp.setEnabled(copyAppEnabled); appRun.setEnabled(appRunEnabled); deleteWf.setEnabled(deleteWfEnabled); editWf.setEnabled(editWfEnabled); copyWf.setEnabled(copyWfEnabled); wfRun.setEnabled(wfRunEnabled); } @Inject  AppsViewToolbarImpl(final AppsToolbarAppearance appearance,
                        @Assisted
                        final PagingLoader<FilterPagingLoadConfig, PagingLoadResult<App>> loader); @Override HandlerRegistration addAppSearchResultLoadEventHandler(AppSearchResultLoadEventHandler handler); @Override HandlerRegistration addBeforeAppSearchEventHandler(BeforeAppSearchEvent.BeforeAppSearchEventHandler handler); @Override HandlerRegistration addCopyAppSelectedHandler(CopyAppSelected.CopyAppSelectedHandler handler); @Override HandlerRegistration addCopyWorkflowSelectedHandler(CopyWorkflowSelected.CopyWorkflowSelectedHandler handler); @Override HandlerRegistration addCreateNewAppSelectedHandler(CreateNewAppSelected.CreateNewAppSelectedHandler handler); @Override HandlerRegistration addCreateNewWorkflowSelectedHandler(CreateNewWorkflowSelected.CreateNewWorkflowSelectedHandler handler); @Override HandlerRegistration addDeleteAppsSelectedHandler(DeleteAppsSelected.DeleteAppsSelectedHandler handler); @Override HandlerRegistration addEditAppSelectedHandler(EditAppSelected.EditAppSelectedHandler handler); @Override HandlerRegistration addEditWorkflowSelectedHandler(EditWorkflowSelected.EditWorkflowSelectedHandler handler); @Override HandlerRegistration addRequestToolSelectedHandler(RequestToolSelected.RequestToolSelectedHandler handler); @Override HandlerRegistration addRunAppSelectedHandler(RunAppSelected.RunAppSelectedHandler handler); @Override HandlerRegistration addShareAppSelectedHandler(ShareAppsSelected.ShareAppsSelectedHandler handler); @Override void hideAppMenu(); @Override void hideWorkflowMenu(); @Override void onAppCategorySelectionChanged(AppCategorySelectionChangedEvent event); @Override void onOntologyHierarchySelectionChanged(OntologyHierarchySelectionChangedEvent event); @Override void onAppSelectionChanged(final AppSelectionChangedEvent event); }
AppsViewToolbarImpl extends Composite implements AppsToolbarView { @Override public void onAppSelectionChanged(final AppSelectionChangedEvent event) { app_menu.setEnabled(true); wf_menu.setEnabled(true); currentSelection.clear(); currentSelection.addAll(event.getAppSelection()); boolean deleteAppEnabled, editAppEnabled, submitAppEnabled, copyAppEnabled, appRunEnabled; boolean deleteWfEnabled, editWfEnabled, copyWfEnabled, wfRunEnabled, shareWithCollaboratorsMiEnabled; switch (currentSelection.size()) { case 0: deleteAppEnabled = false; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = false; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = false; break; case 1: final App selectedApp = currentSelection.get(0); final boolean isOwner = hasOwnerPermission(selectedApp); final boolean isEditable = isOwner || hasWritePermission(selectedApp) || isIntegrator(selectedApp); final boolean isCopyable = isEditable || hasReadPermission(selectedApp); final boolean isSingleStep = selectedApp.getStepCount() == 1; final boolean isMultiStep = selectedApp.getStepCount() > 1; final boolean isAppPublic = selectedApp.isPublic(); final boolean isAppDisabled = selectedApp.isDisabled(); final boolean isRunnable = selectedApp.isRunnable(); deleteAppEnabled = isSingleStep && !isAppPublic && isOwner; editAppEnabled = isSingleStep && isEditable; submitAppEnabled = isRunnable && !isAppPublic && isOwner; copyAppEnabled = isSingleStep && isCopyable; appRunEnabled = isSingleStep && !isAppDisabled; deleteWfEnabled = isMultiStep && !isAppPublic && isOwner; editWfEnabled = isMultiStep && !isAppPublic && isEditable; copyWfEnabled = isMultiStep && isCopyable; wfRunEnabled = isMultiStep && !isAppDisabled; GWT.log(selectedApp.getPermission() + "&&--&&"); shareWithCollaboratorsMiEnabled = containsSharableApps(Arrays.asList(selectedApp)); break; default: final boolean containsSingleStepApp = containsSingleStepApp(currentSelection); final boolean containsMultiStepApp = containsMultiStepApp(currentSelection); final boolean allSelectedAppsPrivate = allAppsPrivate(currentSelection); deleteAppEnabled = containsSingleStepApp && allSelectedAppsPrivate; editAppEnabled = false; submitAppEnabled = false; copyAppEnabled = false; appRunEnabled = false; deleteWfEnabled = containsMultiStepApp && allSelectedAppsPrivate; editWfEnabled = false; copyWfEnabled = false; wfRunEnabled = false; shareWithCollaboratorsMiEnabled = containsSharableApps(currentSelection); } shareMenuButton.setEnabled(submitAppEnabled || shareWithCollaboratorsMiEnabled); deleteApp.setEnabled(deleteAppEnabled); editApp.setEnabled(editAppEnabled); sharePublic.setEnabled(submitAppEnabled); GWT.log("menu enabled->" + shareWithCollaboratorsMiEnabled); shareCollab.setEnabled(shareWithCollaboratorsMiEnabled); copyApp.setEnabled(copyAppEnabled); appRun.setEnabled(appRunEnabled); deleteWf.setEnabled(deleteWfEnabled); editWf.setEnabled(editWfEnabled); copyWf.setEnabled(copyWfEnabled); wfRun.setEnabled(wfRunEnabled); } @Inject  AppsViewToolbarImpl(final AppsToolbarAppearance appearance,
                        @Assisted
                        final PagingLoader<FilterPagingLoadConfig, PagingLoadResult<App>> loader); @Override HandlerRegistration addAppSearchResultLoadEventHandler(AppSearchResultLoadEventHandler handler); @Override HandlerRegistration addBeforeAppSearchEventHandler(BeforeAppSearchEvent.BeforeAppSearchEventHandler handler); @Override HandlerRegistration addCopyAppSelectedHandler(CopyAppSelected.CopyAppSelectedHandler handler); @Override HandlerRegistration addCopyWorkflowSelectedHandler(CopyWorkflowSelected.CopyWorkflowSelectedHandler handler); @Override HandlerRegistration addCreateNewAppSelectedHandler(CreateNewAppSelected.CreateNewAppSelectedHandler handler); @Override HandlerRegistration addCreateNewWorkflowSelectedHandler(CreateNewWorkflowSelected.CreateNewWorkflowSelectedHandler handler); @Override HandlerRegistration addDeleteAppsSelectedHandler(DeleteAppsSelected.DeleteAppsSelectedHandler handler); @Override HandlerRegistration addEditAppSelectedHandler(EditAppSelected.EditAppSelectedHandler handler); @Override HandlerRegistration addEditWorkflowSelectedHandler(EditWorkflowSelected.EditWorkflowSelectedHandler handler); @Override HandlerRegistration addRequestToolSelectedHandler(RequestToolSelected.RequestToolSelectedHandler handler); @Override HandlerRegistration addRunAppSelectedHandler(RunAppSelected.RunAppSelectedHandler handler); @Override HandlerRegistration addShareAppSelectedHandler(ShareAppsSelected.ShareAppsSelectedHandler handler); @Override void hideAppMenu(); @Override void hideWorkflowMenu(); @Override void onAppCategorySelectionChanged(AppCategorySelectionChangedEvent event); @Override void onOntologyHierarchySelectionChanged(OntologyHierarchySelectionChangedEvent event); @Override void onAppSelectionChanged(final AppSelectionChangedEvent event);  }