@Test public void testActionsVisibilityWithPermissionToBuildProjectOnly() { doReturn(promises.resolve(true)).when(this.projectController).canBuildProject(any()); presenter.initialize(); verify(view).setAddAssetVisible(false); verify(view).setImportAssetVisible(false); verify(view).setDuplicateVisible(false); verify(view).setReimportVisible(false); verify(view).setDeleteProjectVisible(false); verify(view).setDeleteBranchVisible(false); verify(view).setActionsVisible(false); verify(projectMainActions).setBuildEnabled(eq(true)); verify(projectMainActions).setDeployEnabled(eq(false)); verify(projectMainActions).setRedeployEnabled(eq(false)); }
@PostConstruct public void initialize() { this.workspaceProject = this.libraryPlaces.getActiveWorkspace(); this.view.init(this); this.view.setTitle(libraryPlaces.getActiveWorkspace().getName()); this.view.addMainAction(projectMainActions.getElement()); this.resolveAssetsCount(); this.showAssets(); projectController.canUpdateProject(workspaceProject).then(userCanUpdateProject -> { this.view.setAddAssetVisible(userCanUpdateProject); this.view.setSubmitChangeRequestVisible(userCanUpdateProject); this.view.setImportAssetVisible(userCanUpdateProject); this.view.setReimportVisible(userCanUpdateProject); newFileUploader.acceptContext(new Callback<Boolean, Void>() { @Override public void onFailure(Void reason) { view.setImportAssetVisible(false); } @Override public void onSuccess(Boolean result) { view.setImportAssetVisible(result && userCanUpdateProject); } }); return promises.resolve(); }); final boolean userCanCreateProjects = this.userCanCreateProjects(); this.view.setDuplicateVisible(userCanCreateProjects); final boolean userCanDeleteProject = this.userCanDeleteProject(); this.view.setDeleteProjectVisible(userCanDeleteProject); projectController.canDeleteBranch(workspaceProject).then(userCanDeleteBranch -> { this.view.setDeleteBranchVisible(userCanDeleteBranch); return promises.resolve(); }); projectController.canSubmitChangeRequest(workspaceProject).then(userCanSubmitChangeRequest -> { this.view.setSubmitChangeRequestVisible(userCanSubmitChangeRequest); return promises.resolve(); }); setupMainActions(); final List<Promise<Boolean>> permissionPromises = Arrays.asList(projectController.canUpdateProject(workspaceProject), projectController.canDeleteBranch(workspaceProject), promises.resolve(userCanDeleteProject()), promises.resolve(userCanCreateProjects())); promises.reduce(promises.resolve(false), permissionPromises, (p1, p2) -> p1.then(resultP1 -> p2.then(resultP2 -> this.promises.resolve(resultP1 || resultP2)))).then(thereAreActionsToDisplay -> { this.view.setActionsVisible(thereAreActionsToDisplay); return promises.resolve(); }); this.setupChangeRequestList(); contributorsListScreen.setup(projectContributorsListService, contributorCount -> this.view.setContributorsCount(contributorCount)); }
ProjectScreen { @PostConstruct public void initialize() { this.workspaceProject = this.libraryPlaces.getActiveWorkspace(); this.view.init(this); this.view.setTitle(libraryPlaces.getActiveWorkspace().getName()); this.view.addMainAction(projectMainActions.getElement()); this.resolveAssetsCount(); this.showAssets(); projectController.canUpdateProject(workspaceProject).then(userCanUpdateProject -> { this.view.setAddAssetVisible(userCanUpdateProject); this.view.setSubmitChangeRequestVisible(userCanUpdateProject); this.view.setImportAssetVisible(userCanUpdateProject); this.view.setReimportVisible(userCanUpdateProject); newFileUploader.acceptContext(new Callback<Boolean, Void>() { @Override public void onFailure(Void reason) { view.setImportAssetVisible(false); } @Override public void onSuccess(Boolean result) { view.setImportAssetVisible(result && userCanUpdateProject); } }); return promises.resolve(); }); final boolean userCanCreateProjects = this.userCanCreateProjects(); this.view.setDuplicateVisible(userCanCreateProjects); final boolean userCanDeleteProject = this.userCanDeleteProject(); this.view.setDeleteProjectVisible(userCanDeleteProject); projectController.canDeleteBranch(workspaceProject).then(userCanDeleteBranch -> { this.view.setDeleteBranchVisible(userCanDeleteBranch); return promises.resolve(); }); projectController.canSubmitChangeRequest(workspaceProject).then(userCanSubmitChangeRequest -> { this.view.setSubmitChangeRequestVisible(userCanSubmitChangeRequest); return promises.resolve(); }); setupMainActions(); final List<Promise<Boolean>> permissionPromises = Arrays.asList(projectController.canUpdateProject(workspaceProject), projectController.canDeleteBranch(workspaceProject), promises.resolve(userCanDeleteProject()), promises.resolve(userCanCreateProjects())); promises.reduce(promises.resolve(false), permissionPromises, (p1, p2) -> p1.then(resultP1 -> p2.then(resultP2 -> this.promises.resolve(resultP1 || resultP2)))).then(thereAreActionsToDisplay -> { this.view.setActionsVisible(thereAreActionsToDisplay); return promises.resolve(); }); this.setupChangeRequestList(); contributorsListScreen.setup(projectContributorsListService, contributorCount -> this.view.setContributorsCount(contributorCount)); } }
ProjectScreen { @PostConstruct public void initialize() { this.workspaceProject = this.libraryPlaces.getActiveWorkspace(); this.view.init(this); this.view.setTitle(libraryPlaces.getActiveWorkspace().getName()); this.view.addMainAction(projectMainActions.getElement()); this.resolveAssetsCount(); this.showAssets(); projectController.canUpdateProject(workspaceProject).then(userCanUpdateProject -> { this.view.setAddAssetVisible(userCanUpdateProject); this.view.setSubmitChangeRequestVisible(userCanUpdateProject); this.view.setImportAssetVisible(userCanUpdateProject); this.view.setReimportVisible(userCanUpdateProject); newFileUploader.acceptContext(new Callback<Boolean, Void>() { @Override public void onFailure(Void reason) { view.setImportAssetVisible(false); } @Override public void onSuccess(Boolean result) { view.setImportAssetVisible(result && userCanUpdateProject); } }); return promises.resolve(); }); final boolean userCanCreateProjects = this.userCanCreateProjects(); this.view.setDuplicateVisible(userCanCreateProjects); final boolean userCanDeleteProject = this.userCanDeleteProject(); this.view.setDeleteProjectVisible(userCanDeleteProject); projectController.canDeleteBranch(workspaceProject).then(userCanDeleteBranch -> { this.view.setDeleteBranchVisible(userCanDeleteBranch); return promises.resolve(); }); projectController.canSubmitChangeRequest(workspaceProject).then(userCanSubmitChangeRequest -> { this.view.setSubmitChangeRequestVisible(userCanSubmitChangeRequest); return promises.resolve(); }); setupMainActions(); final List<Promise<Boolean>> permissionPromises = Arrays.asList(projectController.canUpdateProject(workspaceProject), projectController.canDeleteBranch(workspaceProject), promises.resolve(userCanDeleteProject()), promises.resolve(userCanCreateProjects())); promises.reduce(promises.resolve(false), permissionPromises, (p1, p2) -> p1.then(resultP1 -> p2.then(resultP2 -> this.promises.resolve(resultP1 || resultP2)))).then(thereAreActionsToDisplay -> { this.view.setActionsVisible(thereAreActionsToDisplay); return promises.resolve(); }); this.setupChangeRequestList(); contributorsListScreen.setup(projectContributorsListService, contributorCount -> this.view.setContributorsCount(contributorCount)); } @Inject  ProjectScreen(final View view,
                         final LibraryPlaces libraryPlaces,
                         final AssetsScreen assetsScreen,
                         final ChangeRequestListPresenter changeRequestsScreen,
                         final ContributorsListPresenter contributorsListScreen,
                         final ProjectMetricsScreen projectMetricsScreen,
                         final ProjectController projectController,
                         final SettingsPresenter settingsPresenter,
                         final NewFileUploader newFileUploader,
                         final NewResourcePresenter newResourcePresenter,
                         final ManagedInstance<DeleteProjectPopUpScreen> deleteProjectPopUpScreen,
                         final ManagedInstance<DeleteBranchPopUpScreen> deleteBranchPopUpScreen,
                         final ManagedInstance<RenameProjectPopUpScreen> renameProjectPopUpScreen,
                         final Caller<LibraryService> libraryService,
                         final Caller<ProjectScreenService> projectScreenService,
                         final CopyPopUpPresenter copyPopUpPresenter,
                         final ProjectNameValidator projectNameValidator,
                         final Promises promises,
                         final Event<NotificationEvent> notificationEvent,
                         final ProjectContributorsListServiceImpl projectContributorsListService,
                         final ProjectMainActions projectMainActions); }
ProjectScreen { @PostConstruct public void initialize() { this.workspaceProject = this.libraryPlaces.getActiveWorkspace(); this.view.init(this); this.view.setTitle(libraryPlaces.getActiveWorkspace().getName()); this.view.addMainAction(projectMainActions.getElement()); this.resolveAssetsCount(); this.showAssets(); projectController.canUpdateProject(workspaceProject).then(userCanUpdateProject -> { this.view.setAddAssetVisible(userCanUpdateProject); this.view.setSubmitChangeRequestVisible(userCanUpdateProject); this.view.setImportAssetVisible(userCanUpdateProject); this.view.setReimportVisible(userCanUpdateProject); newFileUploader.acceptContext(new Callback<Boolean, Void>() { @Override public void onFailure(Void reason) { view.setImportAssetVisible(false); } @Override public void onSuccess(Boolean result) { view.setImportAssetVisible(result && userCanUpdateProject); } }); return promises.resolve(); }); final boolean userCanCreateProjects = this.userCanCreateProjects(); this.view.setDuplicateVisible(userCanCreateProjects); final boolean userCanDeleteProject = this.userCanDeleteProject(); this.view.setDeleteProjectVisible(userCanDeleteProject); projectController.canDeleteBranch(workspaceProject).then(userCanDeleteBranch -> { this.view.setDeleteBranchVisible(userCanDeleteBranch); return promises.resolve(); }); projectController.canSubmitChangeRequest(workspaceProject).then(userCanSubmitChangeRequest -> { this.view.setSubmitChangeRequestVisible(userCanSubmitChangeRequest); return promises.resolve(); }); setupMainActions(); final List<Promise<Boolean>> permissionPromises = Arrays.asList(projectController.canUpdateProject(workspaceProject), projectController.canDeleteBranch(workspaceProject), promises.resolve(userCanDeleteProject()), promises.resolve(userCanCreateProjects())); promises.reduce(promises.resolve(false), permissionPromises, (p1, p2) -> p1.then(resultP1 -> p2.then(resultP2 -> this.promises.resolve(resultP1 || resultP2)))).then(thereAreActionsToDisplay -> { this.view.setActionsVisible(thereAreActionsToDisplay); return promises.resolve(); }); this.setupChangeRequestList(); contributorsListScreen.setup(projectContributorsListService, contributorCount -> this.view.setContributorsCount(contributorCount)); } @Inject  ProjectScreen(final View view,
                         final LibraryPlaces libraryPlaces,
                         final AssetsScreen assetsScreen,
                         final ChangeRequestListPresenter changeRequestsScreen,
                         final ContributorsListPresenter contributorsListScreen,
                         final ProjectMetricsScreen projectMetricsScreen,
                         final ProjectController projectController,
                         final SettingsPresenter settingsPresenter,
                         final NewFileUploader newFileUploader,
                         final NewResourcePresenter newResourcePresenter,
                         final ManagedInstance<DeleteProjectPopUpScreen> deleteProjectPopUpScreen,
                         final ManagedInstance<DeleteBranchPopUpScreen> deleteBranchPopUpScreen,
                         final ManagedInstance<RenameProjectPopUpScreen> renameProjectPopUpScreen,
                         final Caller<LibraryService> libraryService,
                         final Caller<ProjectScreenService> projectScreenService,
                         final CopyPopUpPresenter copyPopUpPresenter,
                         final ProjectNameValidator projectNameValidator,
                         final Promises promises,
                         final Event<NotificationEvent> notificationEvent,
                         final ProjectContributorsListServiceImpl projectContributorsListService,
                         final ProjectMainActions projectMainActions); @PostConstruct void initialize(); @OnMayClose boolean onMayClose(); void setAssetsCount(Integer assetsCount); void setChangeRequestsCount(final Integer openChangeRequestsCount); void onAddAsset(@Observes NewResourceSuccessEvent event); void onChangeRequestListUpdated(@Observes final ChangeRequestListUpdatedEvent event); void onChangeRequestStatusUpdated(@Observes final ChangeRequestStatusUpdatedEvent event); void onAssetsUpdated(@Observes UpdatedAssetsEvent event); void onRepositoryContributorsUpdated(@Observes final RepositoryContributorsUpdatedEvent repositoryUpdatedEvent); void changeProjectAndTitleWhenContextChange(@Observes final WorkspaceProjectContextChangeEvent current); void showAssets(); void showChangeRequests(); void showMetrics(); void showContributors(); @WorkbenchPartTitle String getTitle(); void deleteProject(); void deleteBranch(); void submitChangeRequest(); void addAsset(); void importAsset(); void showSettings(); void rename(); void duplicate(); void reimport(); boolean userCanDeleteProject(); boolean userCanCreateProjects(); @WorkbenchPartView ProjectScreen.View getView(); }
ProjectScreen { @PostConstruct public void initialize() { this.workspaceProject = this.libraryPlaces.getActiveWorkspace(); this.view.init(this); this.view.setTitle(libraryPlaces.getActiveWorkspace().getName()); this.view.addMainAction(projectMainActions.getElement()); this.resolveAssetsCount(); this.showAssets(); projectController.canUpdateProject(workspaceProject).then(userCanUpdateProject -> { this.view.setAddAssetVisible(userCanUpdateProject); this.view.setSubmitChangeRequestVisible(userCanUpdateProject); this.view.setImportAssetVisible(userCanUpdateProject); this.view.setReimportVisible(userCanUpdateProject); newFileUploader.acceptContext(new Callback<Boolean, Void>() { @Override public void onFailure(Void reason) { view.setImportAssetVisible(false); } @Override public void onSuccess(Boolean result) { view.setImportAssetVisible(result && userCanUpdateProject); } }); return promises.resolve(); }); final boolean userCanCreateProjects = this.userCanCreateProjects(); this.view.setDuplicateVisible(userCanCreateProjects); final boolean userCanDeleteProject = this.userCanDeleteProject(); this.view.setDeleteProjectVisible(userCanDeleteProject); projectController.canDeleteBranch(workspaceProject).then(userCanDeleteBranch -> { this.view.setDeleteBranchVisible(userCanDeleteBranch); return promises.resolve(); }); projectController.canSubmitChangeRequest(workspaceProject).then(userCanSubmitChangeRequest -> { this.view.setSubmitChangeRequestVisible(userCanSubmitChangeRequest); return promises.resolve(); }); setupMainActions(); final List<Promise<Boolean>> permissionPromises = Arrays.asList(projectController.canUpdateProject(workspaceProject), projectController.canDeleteBranch(workspaceProject), promises.resolve(userCanDeleteProject()), promises.resolve(userCanCreateProjects())); promises.reduce(promises.resolve(false), permissionPromises, (p1, p2) -> p1.then(resultP1 -> p2.then(resultP2 -> this.promises.resolve(resultP1 || resultP2)))).then(thereAreActionsToDisplay -> { this.view.setActionsVisible(thereAreActionsToDisplay); return promises.resolve(); }); this.setupChangeRequestList(); contributorsListScreen.setup(projectContributorsListService, contributorCount -> this.view.setContributorsCount(contributorCount)); } @Inject  ProjectScreen(final View view,
                         final LibraryPlaces libraryPlaces,
                         final AssetsScreen assetsScreen,
                         final ChangeRequestListPresenter changeRequestsScreen,
                         final ContributorsListPresenter contributorsListScreen,
                         final ProjectMetricsScreen projectMetricsScreen,
                         final ProjectController projectController,
                         final SettingsPresenter settingsPresenter,
                         final NewFileUploader newFileUploader,
                         final NewResourcePresenter newResourcePresenter,
                         final ManagedInstance<DeleteProjectPopUpScreen> deleteProjectPopUpScreen,
                         final ManagedInstance<DeleteBranchPopUpScreen> deleteBranchPopUpScreen,
                         final ManagedInstance<RenameProjectPopUpScreen> renameProjectPopUpScreen,
                         final Caller<LibraryService> libraryService,
                         final Caller<ProjectScreenService> projectScreenService,
                         final CopyPopUpPresenter copyPopUpPresenter,
                         final ProjectNameValidator projectNameValidator,
                         final Promises promises,
                         final Event<NotificationEvent> notificationEvent,
                         final ProjectContributorsListServiceImpl projectContributorsListService,
                         final ProjectMainActions projectMainActions); @PostConstruct void initialize(); @OnMayClose boolean onMayClose(); void setAssetsCount(Integer assetsCount); void setChangeRequestsCount(final Integer openChangeRequestsCount); void onAddAsset(@Observes NewResourceSuccessEvent event); void onChangeRequestListUpdated(@Observes final ChangeRequestListUpdatedEvent event); void onChangeRequestStatusUpdated(@Observes final ChangeRequestStatusUpdatedEvent event); void onAssetsUpdated(@Observes UpdatedAssetsEvent event); void onRepositoryContributorsUpdated(@Observes final RepositoryContributorsUpdatedEvent repositoryUpdatedEvent); void changeProjectAndTitleWhenContextChange(@Observes final WorkspaceProjectContextChangeEvent current); void showAssets(); void showChangeRequests(); void showMetrics(); void showContributors(); @WorkbenchPartTitle String getTitle(); void deleteProject(); void deleteBranch(); void submitChangeRequest(); void addAsset(); void importAsset(); void showSettings(); void rename(); void duplicate(); void reimport(); boolean userCanDeleteProject(); boolean userCanCreateProjects(); @WorkbenchPartView ProjectScreen.View getView();  }