ProjectController { public boolean canCreateProjects(final OrganizationalUnit organizationalUnit) { final boolean securityPermission = authorizationManager.authorize(Repository.RESOURCE_TYPE, RepositoryAction.CREATE, user); return securityPermission || userIsAtLeast(ContributorType.CONTRIBUTOR, organizationalUnit.getContributors()); } @Inject  ProjectController(final AuthorizationManager authorizationManager,
                             final User user,
                             final Caller<ProjectPermissionsService> projectPermissionsService,
                             final Promises promises); boolean canCreateProjects(final OrganizationalUnit organizationalUnit); boolean canReadProject(final WorkspaceProject workspaceProject); Promise<Boolean> canUpdateProject(final WorkspaceProject workspaceProject); Promise<Boolean> canUpdateBranch(final WorkspaceProject workspaceProject,
                                            final Branch branch); boolean canDeleteProject(final WorkspaceProject workspaceProject); Promise<Boolean> canBuildProject(final WorkspaceProject workspaceProject); Promise<Boolean> canDeployProject(final WorkspaceProject workspaceProject); Promise<Boolean> canReadBranch(final WorkspaceProject project); Promise<Boolean> canReadBranch(final WorkspaceProject project,
                                          final String branch); Promise<Boolean> canDeleteBranch(final WorkspaceProject project); Promise<Boolean> canSubmitChangeRequest(final WorkspaceProject project); Promise<Boolean> canDeleteBranch(final WorkspaceProject project,
                                            final String branch); Promise<Boolean> canViewDeploymentDetails(String id); Promise<Boolean> canSubmitChangeRequest(final WorkspaceProject project,
                                                   final String branch); Promise<Optional<RolePermissions>> getBranchPermissionsForUser(final WorkspaceProject project,
                                                                          final String branch); Optional<RolePermissions> getBranchPermissionsForUser(final WorkspaceProject project,
                                                                 final Map<String, RolePermissions> permissionsByRole); Promise<List<Branch>> getReadableBranches(final WorkspaceProject project); Promise<List<Branch>> getUpdatableBranches(final WorkspaceProject project);  }
@Test public void userCanCreateProjectTest() { final WorkspaceProject project = getProject(); when(authorizationManager.authorize(Repository.RESOURCE_TYPE, RepositoryAction.CREATE, user)).thenReturn(true); assertTrue(projectController.canCreateProjects(project.getOrganizationalUnit())); }