src_fm_fc_ms_ff
stringlengths 43
86.8k
| target
stringlengths 20
276k
|
---|---|
ProjectTeamController { @GetMapping public String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form, BindingResult bindingResult, @PathVariable long projectId, Model model, UserResource loggedInUser) { model.addAttribute("model", projectTeamPopulator.populate(projectId, loggedInUser)); return "projectteam/project-team"; } @GetMapping String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
Model model,
UserResource loggedInUser); @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("add-team-member") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String closeAddTeamMemberForm(@PathVariable long projectId,
@PathVariable long competitionId); @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("invite-to-project") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String resendInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") String removeOrganisation(@PathVariable("projectId") long projectId,
@PathVariable("competitionId") long competitionId,
@RequestParam("remove-organisation") final long orgId); @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String removeInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-invite") long inviteId); @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String resendPartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-partner-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String removePartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-partner-invite") long inviteId); } | @Test public void viewProjectTeam() throws Exception { UserResource loggedInUser = newUserResource().build(); setLoggedInUser(loggedInUser); long projectId = 999L; long competitionId = 888L; ProjectTeamViewModel expected = mock(ProjectTeamViewModel.class); when(populator.populate(projectId, loggedInUser)).thenReturn(expected); MvcResult result = mockMvc.perform(get("/competition/{compId}/project/{projectId}/team", competitionId, projectId)) .andExpect(status().isOk()) .andExpect(view().name("projectteam/project-team")) .andReturn(); ProjectTeamViewModel actual = (ProjectTeamViewModel) result.getModelAndView().getModel().get("model"); assertEquals(expected, actual); } |
ProjectTeamController { @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") public String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form, BindingResult bindingResult, @PathVariable long projectId, @PathVariable long competitionId, @RequestParam("add-team-member") long organisationId, Model model, UserResource loggedInUser) { model.addAttribute("model", projectTeamPopulator.populate(projectId, loggedInUser) .openAddTeamMemberForm(organisationId)); return "projectteam/project-team"; } @GetMapping String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
Model model,
UserResource loggedInUser); @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("add-team-member") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String closeAddTeamMemberForm(@PathVariable long projectId,
@PathVariable long competitionId); @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("invite-to-project") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String resendInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") String removeOrganisation(@PathVariable("projectId") long projectId,
@PathVariable("competitionId") long competitionId,
@RequestParam("remove-organisation") final long orgId); @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String removeInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-invite") long inviteId); @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String resendPartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-partner-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String removePartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-partner-invite") long inviteId); } | @Test public void openAddTeamMemberForm() throws Exception { UserResource loggedInUser = newUserResource().withRoleGlobal(IFS_ADMINISTRATOR).build(); setLoggedInUser(loggedInUser); long projectId = 999L; long competitionId = 888L; long organisationId = 3L; ProjectTeamViewModel expected = mock(ProjectTeamViewModel.class); when(populator.populate(projectId, loggedInUser)).thenReturn(expected); when(expected.openAddTeamMemberForm(organisationId)).thenReturn(expected); MvcResult result = mockMvc.perform(post("/competition/{competitionId}/project/{projectId}/team", competitionId, projectId) .param("add-team-member", String.valueOf(organisationId))) .andExpect(status().isOk()) .andExpect(view().name("projectteam/project-team")) .andReturn(); ProjectTeamViewModel actual = (ProjectTeamViewModel) result.getModelAndView().getModel().get("model"); assertEquals(expected, actual); verify(expected).openAddTeamMemberForm(organisationId); } |
ProjectTeamController { @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") public String closeAddTeamMemberForm(@PathVariable long projectId, @PathVariable long competitionId) { return format("redirect:/competition/%d/project/%d/team", competitionId, projectId); } @GetMapping String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
Model model,
UserResource loggedInUser); @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("add-team-member") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String closeAddTeamMemberForm(@PathVariable long projectId,
@PathVariable long competitionId); @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("invite-to-project") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String resendInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") String removeOrganisation(@PathVariable("projectId") long projectId,
@PathVariable("competitionId") long competitionId,
@RequestParam("remove-organisation") final long orgId); @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String removeInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-invite") long inviteId); @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String resendPartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-partner-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String removePartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-partner-invite") long inviteId); } | @Test public void closeAddTeamMemberForm() throws Exception { long projectId = 999L; long competitionId = 888L; mockMvc.perform(post("/competition/{competitionId}/project/{projectId}/team", competitionId, projectId) .param("close-add-team-member-form", "")) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl(format("/competition/%d/project/%d/team", competitionId, projectId))) .andReturn(); } |
ProjectTeamController { @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") public String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form, BindingResult bindingResult, ValidationHandler validationHandler, @PathVariable long projectId, @PathVariable long competitionId, @RequestParam("invite-to-project") long organisationId, Model model, UserResource loggedInUser) { Supplier<String> failureView = () -> { model.addAttribute("model", projectTeamPopulator.populate(projectId, loggedInUser) .openAddTeamMemberForm(organisationId)); return "projectteam/project-team"; }; Supplier<String> successView = () -> format("redirect:/competition/%d/project/%d/team", competitionId, projectId); return projectInviteHelper.sendInvite(form.getName(), form.getEmail(), loggedInUser, validationHandler, failureView, successView, projectId, organisationId); } @GetMapping String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
Model model,
UserResource loggedInUser); @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("add-team-member") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String closeAddTeamMemberForm(@PathVariable long projectId,
@PathVariable long competitionId); @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("invite-to-project") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String resendInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") String removeOrganisation(@PathVariable("projectId") long projectId,
@PathVariable("competitionId") long competitionId,
@RequestParam("remove-organisation") final long orgId); @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String removeInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-invite") long inviteId); @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String resendPartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-partner-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String removePartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-partner-invite") long inviteId); } | @Test public void inviteToProject() throws Exception { UserResource loggedInUser = newUserResource().withRoleGlobal(IFS_ADMINISTRATOR).build(); setLoggedInUser(loggedInUser); long projectId = 999L; long competitionId = 888L; ProjectTeamViewModel expected = mock(ProjectTeamViewModel.class); String email = "[email protected]"; String userName = "Some One"; ProjectResource projectResource = newProjectResource() .withId(projectId) .withApplication(5L) .build(); OrganisationResource leadOrganisation = newOrganisationResource().build(); OrganisationResource organisationResource = newOrganisationResource().build(); ProjectUserInviteResource projectUserInviteResource = new ProjectUserInviteResource(userName, email, projectId); projectUserInviteResource.setOrganisation(organisationResource.getId()); projectUserInviteResource.setApplicationId(projectResource.getApplication()); projectUserInviteResource.setLeadOrganisationId(leadOrganisation.getId()); projectUserInviteResource.setOrganisationName(organisationResource.getName()); when(expected.openAddTeamMemberForm(organisationResource.getId())).thenReturn(expected); when(populator.populate(projectId, loggedInUser)).thenReturn(expected); when(projectService.getById(projectId)).thenReturn(projectResource); when(projectService.getLeadOrganisation(projectId)).thenReturn(leadOrganisation); when(organisationRestService.getOrganisationById(organisationResource.getId())).thenReturn(restSuccess(organisationResource)); when(projectInviteRestService.getInvitesByProject(projectId)).thenReturn(restSuccess(singletonList(projectUserInviteResource))); when(projectTeamRestService.inviteProjectMember(projectId, projectUserInviteResource)).thenReturn(restSuccess()); MvcResult result = mockMvc.perform(post("/competition/{competitionId}/project/{projectId}/team", competitionId, projectId) .param("invite-to-project", String.valueOf(organisationResource.getId())) .param("name", userName) .param("email", email)) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl(format("/competition/%d/project/%d/team", competitionId, projectId))) .andReturn(); verify(projectTeamRestService).inviteProjectMember(projectId, projectUserInviteResource); } |
ProjectTeamController { @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") public String resendInvite(@PathVariable long projectId, @PathVariable long competitionId, @RequestParam("resend-invite") long inviteId, HttpServletResponse response) { projectInviteHelper.resendInvite(inviteId, projectId, (project, projectInviteResource) -> projectTeamRestService.inviteProjectMember(project, projectInviteResource).toServiceResult()); cookieFlashMessageFilter.setFlashMessage(response, "emailSent"); return format("redirect:/competition/%d/project/%d/team", competitionId, projectId); } @GetMapping String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
Model model,
UserResource loggedInUser); @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("add-team-member") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String closeAddTeamMemberForm(@PathVariable long projectId,
@PathVariable long competitionId); @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("invite-to-project") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String resendInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") String removeOrganisation(@PathVariable("projectId") long projectId,
@PathVariable("competitionId") long competitionId,
@RequestParam("remove-organisation") final long orgId); @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String removeInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-invite") long inviteId); @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String resendPartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-partner-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String removePartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-partner-invite") long inviteId); } | @Test public void resendInvite() throws Exception { long projectId = 4L; long competitionId = 5L; long organisationId = 21L; long inviteId = 3L; String invitedUserName = "test"; String invitedUserEmail = "[email protected]"; OrganisationResource leadOrganisation = newOrganisationResource().withName("Lead Organisation").build(); List<ProjectUserInviteResource> existingInvites = newProjectUserInviteResource().withId(inviteId) .withProject(projectId).withName("exist test", invitedUserName) .withEmail("[email protected]", invitedUserEmail) .withOrganisation(organisationId) .withStatus(SENT) .withLeadOrganisation(leadOrganisation.getId()).build(1); when(projectInviteRestService.getInvitesByProject(projectId)).thenReturn(restSuccess(existingInvites)); when(projectTeamRestService.inviteProjectMember(projectId, existingInvites.get(0))).thenReturn(restSuccess()); mockMvc.perform(post("/competition/{competitionId}/project/{projectId}/team", competitionId, projectId) .param("resend-invite", "3")) .andExpect(status().is3xxRedirection()); verify(projectTeamRestService).inviteProjectMember(projectId, existingInvites.get(0)); verify(cookieFlashMessageFilter).setFlashMessage(any(), eq("emailSent")); } |
GoogleAnalyticsDataLayerController { @GetMapping("/application/{applicationId}/user-roles") public RestResult<List<Role>> getRolesByApplicationIdForCurrentUser(@PathVariable("applicationId") long applicationId) { return googleAnalyticsDataLayerService.getRolesByApplicationIdForCurrentUser(applicationId).toGetResponse(); } @GetMapping("/application/{applicationId}/competition-name") RestResult<String> getCompetitionNameForApplication(@PathVariable("applicationId") long applicationId); @GetMapping("/invite/{inviteHash}/competition-name") RestResult<String> getCompetitionNameForInvite(@PathVariable("inviteHash") String inviteHash); @GetMapping("/application/{applicationId}/user-roles") RestResult<List<Role>> getRolesByApplicationIdForCurrentUser(@PathVariable("applicationId") long applicationId); @GetMapping("/competition/{competitionId}/competition-name") RestResult<String> getCompetitionName(@PathVariable("competitionId") long competitionId); @GetMapping("/project/{projectId}/competition-name") RestResult<String> getCompetitionNameForProject(@PathVariable("projectId") long projectId); @GetMapping("/project/{projectId}/user-roles") RestResult<List<Role>> getRolesByProjectIdForCurrentUser(@PathVariable("projectId") long projectId); @GetMapping("/assessment/{assessmentId}/competition-name") RestResult<String> getCompetitionNameForAssessment(@PathVariable("assessmentId") long assessmentId); @GetMapping("/project/{projectId}/application-id") RestResult<Long> getApplicationIdForProject(@PathVariable("projectId") long projectId); @GetMapping("/assessment/{assessmentId}/application-id") RestResult<Long> getApplicationIdForAssessment(@PathVariable("assessmentId") long assessmentId); } | @Test public void getApplicationRolesById() throws Exception { final long applicationId = 12L; final Role role = Role.LEADAPPLICANT; when(googleAnalyticsDataLayerServiceMock.getRolesByApplicationIdForCurrentUser(applicationId)) .thenReturn(serviceSuccess(singletonList(role))); mockMvc.perform(get("/analytics/application/{applicationId}/user-roles", applicationId)) .andExpect(status().isOk()) .andExpect(content().string(toJson(singletonList(role)))); } |
ProjectTeamController { @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") public String removeInvite(@PathVariable long projectId, @PathVariable long competitionId, @RequestParam("remove-invite") long inviteId) { projectTeamRestService.removeInvite(projectId, inviteId).getSuccess(); return format("redirect:/competition/%d/project/%d/team", competitionId, projectId); } @GetMapping String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
Model model,
UserResource loggedInUser); @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("add-team-member") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String closeAddTeamMemberForm(@PathVariable long projectId,
@PathVariable long competitionId); @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("invite-to-project") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String resendInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") String removeOrganisation(@PathVariable("projectId") long projectId,
@PathVariable("competitionId") long competitionId,
@RequestParam("remove-organisation") final long orgId); @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String removeInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-invite") long inviteId); @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String resendPartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-partner-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String removePartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-partner-invite") long inviteId); } | @Test public void removeInvite() throws Exception { long inviteId = 777L; long projectId = 888L; long competitionId = 999L; when(projectTeamRestService.removeInvite(projectId, inviteId)).thenReturn(restSuccess()); mockMvc.perform(post("/competition/" + competitionId + "/project/" + projectId + "/team") .param("remove-invite", String.valueOf(inviteId))) .andExpect(status().is3xxRedirection()); verify(projectTeamRestService).removeInvite(projectId, inviteId); } |
ProjectTeamController { @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") public String removeOrganisation(@PathVariable("projectId") long projectId, @PathVariable("competitionId") long competitionId, @RequestParam("remove-organisation") final long orgId) { partnerOrganisationRestService.removePartnerOrganisation(projectId, orgId).getSuccess(); return format("redirect:/competition/%d/project/%d/team", competitionId, projectId); } @GetMapping String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
Model model,
UserResource loggedInUser); @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("add-team-member") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String closeAddTeamMemberForm(@PathVariable long projectId,
@PathVariable long competitionId); @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("invite-to-project") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String resendInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") String removeOrganisation(@PathVariable("projectId") long projectId,
@PathVariable("competitionId") long competitionId,
@RequestParam("remove-organisation") final long orgId); @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String removeInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-invite") long inviteId); @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String resendPartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-partner-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String removePartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-partner-invite") long inviteId); } | @Test public void removeOrganisation() throws Exception { long organisationId = 777L; long projectId = 888L; long competitionId = 999L; when(partnerOrganisationRestService.removePartnerOrganisation(projectId, organisationId)).thenReturn(restSuccess()); mockMvc.perform(post("/competition/" + competitionId + "/project/" + projectId + "/team") .param("remove-organisation", String.valueOf(organisationId))) .andExpect(status().is3xxRedirection()); verify(partnerOrganisationRestService).removePartnerOrganisation(projectId, organisationId); } |
ProjectTeamController { @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") public String resendPartnerInvite(@PathVariable long projectId, @PathVariable long competitionId, @RequestParam("resend-partner-invite") long inviteId, HttpServletResponse response) { projectPartnerInviteRestService.resendInvite(projectId, inviteId).getSuccess(); cookieFlashMessageFilter.setFlashMessage(response, "emailSent"); return format("redirect:/competition/%d/project/%d/team", competitionId, projectId); } @GetMapping String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
Model model,
UserResource loggedInUser); @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("add-team-member") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String closeAddTeamMemberForm(@PathVariable long projectId,
@PathVariable long competitionId); @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("invite-to-project") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String resendInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") String removeOrganisation(@PathVariable("projectId") long projectId,
@PathVariable("competitionId") long competitionId,
@RequestParam("remove-organisation") final long orgId); @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String removeInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-invite") long inviteId); @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String resendPartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-partner-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String removePartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-partner-invite") long inviteId); } | @Test public void resendPartnerInvite() throws Exception { long inviteId = 777L; long projectId = 888L; long competitionId = 999L; when(projectPartnerInviteRestService.resendInvite(projectId, inviteId)).thenReturn(restSuccess()); mockMvc.perform(post("/competition/" + competitionId + "/project/" + projectId + "/team") .param("resend-partner-invite", String.valueOf(inviteId))) .andExpect(status().is3xxRedirection()); verify(projectPartnerInviteRestService).resendInvite(projectId, inviteId); } |
ProjectTeamController { @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") public String removePartnerInvite(@PathVariable long projectId, @PathVariable long competitionId, @RequestParam("remove-partner-invite") long inviteId) { projectPartnerInviteRestService.deleteInvite(projectId, inviteId).getSuccess(); return format("redirect:/competition/%d/project/%d/team", competitionId, projectId); } @GetMapping String viewProjectTeam(@ModelAttribute(value = "form", binding = false) ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
Model model,
UserResource loggedInUser); @PostMapping(params = "add-team-member") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String openAddTeamMemberForm(@ModelAttribute(value = "form") ProjectTeamForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("add-team-member") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "close-add-team-member-form") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String closeAddTeamMemberForm(@PathVariable long projectId,
@PathVariable long competitionId); @PostMapping(params = "invite-to-project") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("invite-to-project") long organisationId,
Model model,
UserResource loggedInUser); @PostMapping(params = "resend-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String resendInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-organisation") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'project_finance')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and project finance can edit project team.") String removeOrganisation(@PathVariable("projectId") long projectId,
@PathVariable("competitionId") long competitionId,
@RequestParam("remove-organisation") final long orgId); @PostMapping(params = "remove-invite") @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')") @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.") String removeInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-invite") long inviteId); @PostMapping(params = "resend-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String resendPartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("resend-partner-invite") long inviteId,
HttpServletResponse response); @PostMapping(params = "remove-partner-invite") @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "PROJECT_PARTNER_CHANGES", description = "Project finance can change the partner organisations.") String removePartnerInvite(@PathVariable long projectId,
@PathVariable long competitionId,
@RequestParam("remove-partner-invite") long inviteId); } | @Test public void removePartnerInvite() throws Exception { long inviteId = 777L; long projectId = 888L; long competitionId = 999L; when(projectPartnerInviteRestService.deleteInvite(projectId, inviteId)).thenReturn(restSuccess()); mockMvc.perform(post("/competition/" + competitionId + "/project/" + projectId + "/team") .param("remove-partner-invite", String.valueOf(inviteId))) .andExpect(status().is3xxRedirection()); verify(projectPartnerInviteRestService).deleteInvite(projectId, inviteId); } |
FinanceChecksNotesAddNoteController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping public String viewNewNote(@P("projectId")@PathVariable final Long projectId, @PathVariable final Long organisationId, Model model, UserResource loggedInUser, HttpServletRequest request, HttpServletResponse response) { partnerOrganisationRestService.getPartnerOrganisation(projectId, organisationId); saveOriginCookie(response, projectId, organisationId, loggedInUser.getId()); List<Long> attachments = loadAttachmentsFromCookie(request, projectId, organisationId); model.addAttribute("model", populateNoteViewModel(projectId, organisationId, attachments)); model.addAttribute(FORM_ATTR, loadForm(request, projectId, organisationId).orElse(new FinanceChecksNotesAddNoteForm())); return NEW_NOTE_VIEW; } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping String viewNewNote(@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
Model model,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping String saveNote(@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
@Valid @ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "uploadAttachment") String saveNewNoteAttachment(Model model,
@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
@ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping("/attachment/{attachmentId}") @ResponseBody ResponseEntity<ByteArrayResource> downloadAttachment(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
@PathVariable Long attachmentId,
UserResource loggedInUser,
HttpServletRequest request); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "removeAttachment") String removeAttachment(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
@RequestParam(value = "removeAttachment") final Long attachmentId,
@ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response,
Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping("/cancel") String cancelNewForm(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); } | @Test public void testViewNewNote() throws Exception { Cookie formCookie; FinanceChecksNotesAddNoteForm form = new FinanceChecksNotesAddNoteForm(); form.setNote("Note"); formCookie = createFormCookie(form); MvcResult result = mockMvc.perform(get("/project/" + projectId + "/finance-check/organisation/" + applicantOrganisationId + "/note/new-note") .cookie(formCookie)) .andExpect(view().name("project/financecheck/new-note")) .andReturn(); FinanceChecksNotesAddNoteViewModel noteViewModel = (FinanceChecksNotesAddNoteViewModel) result.getModelAndView().getModel().get("model"); FinanceChecksNotesAddNoteForm modelForm = (FinanceChecksNotesAddNoteForm) result.getModelAndView().getModel().get("form"); assertEquals(URLEncoder.encode(JsonUtil.getSerializedObject(Arrays.asList(projectId, applicantOrganisationId, loggedInUser.getId())), CharEncoding.UTF_8), getDecryptedCookieValue(result.getResponse().getCookies(), "finance_checks_notes_new_note_origin")); assertEquals("Org1", noteViewModel.getOrganisationName()); assertEquals("Project1", noteViewModel.getProjectName()); assertEquals(applicantOrganisationId, noteViewModel.getOrganisationId()); assertEquals(projectId, noteViewModel.getProjectId()); assertEquals("/project/{projectId}/finance-check/organisation/{organisationId}/note/new-note", noteViewModel.getBaseUrl()); assertEquals(4000, noteViewModel.getMaxNoteCharacters()); assertEquals(400, noteViewModel.getMaxNoteWords()); assertEquals(255, noteViewModel.getMaxTitleCharacters()); assertTrue(noteViewModel.isLeadPartnerOrganisation()); assertEquals(0, noteViewModel.getNewAttachmentLinks().size()); assertEquals("Note", modelForm.getNote()); } |
FinanceChecksNotesAddNoteController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping public String saveNote(@P("projectId")@PathVariable final Long projectId, @PathVariable final Long organisationId, @Valid @ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, Model model, UserResource loggedInUser, HttpServletRequest request, HttpServletResponse response) { if (postParametersMatchOrigin(request, projectId, organisationId, loggedInUser.getId())) { Supplier<String> failureView = () -> { List<Long> attachments = loadAttachmentsFromCookie(request, projectId, organisationId); FinanceChecksNotesAddNoteViewModel viewModel = populateNoteViewModel(projectId, organisationId, attachments); model.addAttribute("model", viewModel); model.addAttribute(FORM_ATTR, form); return NEW_NOTE_VIEW; }; return validationHandler.failNowOrSucceedWith(failureView, () -> { ValidationMessages validationMessages = new ValidationMessages(bindingResult); ProjectFinanceResource projectFinance = projectFinanceService.getProjectFinance(projectId, organisationId); List<AttachmentResource> attachmentResources = new ArrayList<>(); List<Long> attachments = loadAttachmentsFromCookie(request, projectId, organisationId); attachments.forEach(attachment -> financeCheckService.getAttachment(attachment).ifSuccessful(fileEntry -> attachmentResources.add(fileEntry))); PostResource post = new PostResource(null, loggedInUser, form.getNote(), attachmentResources, ZonedDateTime.now()); List<PostResource> posts = new ArrayList<>(); posts.add(post); NoteResource note = new NoteResource(null, projectFinance.getId(), posts, form.getNoteTitle(), ZonedDateTime.now()); ServiceResult<Long> result = financeCheckService.saveNote(note); validationHandler.addAnyErrors(result); return validationHandler.addAnyErrors(validationMessages, fieldErrorsToFieldErrors(), asGlobalErrors()). failNowOrSucceedWith(failureView, () -> { deleteCookies(response, projectId, organisationId); return redirectToNotePage(projectId, organisationId); }); }); } else { throw new ObjectNotFoundException(); } } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping String viewNewNote(@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
Model model,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping String saveNote(@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
@Valid @ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "uploadAttachment") String saveNewNoteAttachment(Model model,
@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
@ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping("/attachment/{attachmentId}") @ResponseBody ResponseEntity<ByteArrayResource> downloadAttachment(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
@PathVariable Long attachmentId,
UserResource loggedInUser,
HttpServletRequest request); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "removeAttachment") String removeAttachment(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
@RequestParam(value = "removeAttachment") final Long attachmentId,
@ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response,
Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping("/cancel") String cancelNewForm(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); } | @Test public void testSaveNewNote() throws Exception { ProjectFinanceResource projectFinanceResource = newProjectFinanceResource().withProject(projectId).withOrganisation(applicantOrganisationId).withId(projectFinanceId).build(); when(projectFinanceService.getProjectFinance(projectId, applicantOrganisationId)).thenReturn(projectFinanceResource); when(financeCheckServiceMock.saveNote(any(NoteResource.class))).thenReturn(ServiceResult.serviceSuccess(1L)); FinanceChecksNotesAddNoteForm formIn = new FinanceChecksNotesAddNoteForm(); Cookie formCookie = createFormCookie(formIn); Cookie originCookie = createOriginCookie(); MvcResult result = mockMvc.perform(post("/project/" + projectId + "/finance-check/organisation/" + applicantOrganisationId + "/note/new-note") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param("noteTitle", "Title") .param("note", "Query text") .cookie(formCookie) .cookie(originCookie)) .andExpect(redirectedUrlPattern("/project/" + projectId + "/finance-check/organisation/" + applicantOrganisationId + "/note**")) .andReturn(); verify(financeCheckServiceMock).saveNote(saveNoteArgumentCaptor.capture()); assertEquals(1, saveNoteArgumentCaptor.getAllValues().get(0).posts.size()); assertEquals("Title", saveNoteArgumentCaptor.getAllValues().get(0).title); assertTrue(ZonedDateTime.now().compareTo(saveNoteArgumentCaptor.getAllValues().get(0).createdOn) >= 0); assertEquals("Query text", saveNoteArgumentCaptor.getAllValues().get(0).posts.get(0).body); assertEquals(loggedInUser, saveNoteArgumentCaptor.getAllValues().get(0).posts.get(0).author); assertEquals(0, saveNoteArgumentCaptor.getAllValues().get(0).posts.get(0).attachments.size()); assertTrue(ZonedDateTime.now().compareTo(saveNoteArgumentCaptor.getAllValues().get(0).createdOn) >= 0); FinanceChecksNotesAddNoteForm form = (FinanceChecksNotesAddNoteForm) result.getModelAndView().getModel().get("form"); assertEquals("Title", form.getNoteTitle()); assertEquals("Query text", form.getNote()); assertEquals(null, form.getAttachment()); Optional<Cookie> cookieFound = Arrays.stream(result.getResponse().getCookies()) .filter(cookie -> cookie.getName().equals("finance_checks_notes_new_note_attachments_" + projectId + "_" + applicantOrganisationId)) .findAny(); assertEquals(true, cookieFound.get().getValue().isEmpty()); Optional<Cookie> formCookieFound = Arrays.stream(result.getResponse().getCookies()) .filter(cookie -> cookie.getName().equals("finance_checks_notes_new_note_form_" + projectId + "_" + applicantOrganisationId)) .findAny(); assertEquals(true, formCookieFound.get().getValue().isEmpty()); }
@Test public void testSaveNewNoteNoOriginCookie() throws Exception { ProjectFinanceResource projectFinanceResource = newProjectFinanceResource().withProject(projectId).withOrganisation(applicantOrganisationId).withId(projectFinanceId).build(); when(projectFinanceService.getProjectFinance(projectId, applicantOrganisationId)).thenReturn(projectFinanceResource); when(financeCheckServiceMock.saveNote(any(NoteResource.class))).thenReturn(ServiceResult.serviceSuccess(1L)); FinanceChecksNotesAddNoteForm formIn = new FinanceChecksNotesAddNoteForm(); Cookie formCookie = createFormCookie(formIn); mockMvc.perform(post("/project/" + projectId + "/finance-check/organisation/" + applicantOrganisationId + "/note/new-note") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param("noteTitle", "Title") .param("note", "Query text") .cookie(formCookie)) .andExpect(status().isNotFound()); } |
FinanceChecksNotesAddNoteController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "uploadAttachment") public String saveNewNoteAttachment(Model model, @P("projectId")@PathVariable final Long projectId, @PathVariable final Long organisationId, @ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, UserResource loggedInUser, HttpServletRequest request, HttpServletResponse response) { if (postParametersMatchOrigin(request, projectId, organisationId, loggedInUser.getId())) { List<Long> attachments = loadAttachmentsFromCookie(request, projectId, organisationId); Supplier<String> onSuccess = () -> redirectTo(rootView(projectId, organisationId)); Supplier<String> onError = () -> { model.addAttribute("model", populateNoteViewModel(projectId, organisationId, attachments)); model.addAttribute("form", form); return NEW_NOTE_VIEW; }; return validationHandler.performActionOrBindErrorsToField("attachment", onError, onSuccess, () -> { MultipartFile file = form.getAttachment(); ServiceResult<AttachmentResource> result = financeCheckService.uploadFile(projectId, file.getContentType(), file.getSize(), file.getOriginalFilename(), getMultipartFileBytes(file)); result.ifSuccessful(uploadedAttachment -> { attachments.add(uploadedAttachment.id); saveAttachmentsToCookie(response, attachments, projectId, organisationId); saveFormToCookie(response, projectId, organisationId, form); }); model.addAttribute("model", populateNoteViewModel(projectId, organisationId, attachments)); return result; }); } else { throw new ObjectNotFoundException(); } } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping String viewNewNote(@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
Model model,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping String saveNote(@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
@Valid @ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "uploadAttachment") String saveNewNoteAttachment(Model model,
@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
@ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping("/attachment/{attachmentId}") @ResponseBody ResponseEntity<ByteArrayResource> downloadAttachment(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
@PathVariable Long attachmentId,
UserResource loggedInUser,
HttpServletRequest request); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "removeAttachment") String removeAttachment(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
@RequestParam(value = "removeAttachment") final Long attachmentId,
@ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response,
Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping("/cancel") String cancelNewForm(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); } | @Test public void testSaveNewNoteAttachment() throws Exception { MockMultipartFile uploadedFile = new MockMultipartFile("attachment", "testFile.pdf", "application/pdf", "My content!".getBytes()); AttachmentResource attachment = new AttachmentResource(1L, "name", "mediaType", 2L, null); Cookie originCookie = createOriginCookie(); when(financeCheckServiceMock.uploadFile(projectId, "application/pdf", 11, "testFile.pdf", "My content!".getBytes())).thenReturn(ServiceResult.serviceSuccess(attachment)); when(financeCheckServiceMock.getAttachment(1L)).thenReturn(ServiceResult.serviceSuccess(attachment)); MvcResult result = mockMvc.perform( fileUpload("/project/" + projectId + "/finance-check/organisation/" + applicantOrganisationId + "/note/new-note"). file(uploadedFile).param("uploadAttachment", "").cookie(originCookie)) .andExpect(cookie().exists("finance_checks_notes_new_note_attachments_" + projectId + "_" + applicantOrganisationId)) .andExpect(cookie().exists("finance_checks_notes_new_note_form_" + projectId + "_" + applicantOrganisationId)) .andExpect(redirectedUrlPattern("/project/" + projectId + "/finance-check/organisation/" + applicantOrganisationId + "/note/new-note**")) .andReturn(); List<Long> expectedAttachmentIds = new ArrayList<>(); expectedAttachmentIds.add(1L); assertEquals(URLEncoder.encode(JsonUtil.getSerializedObject(expectedAttachmentIds), CharEncoding.UTF_8), getDecryptedCookieValue(result.getResponse().getCookies(), "finance_checks_notes_new_note_attachments_" + projectId + "_" + applicantOrganisationId)); FinanceChecksNotesAddNoteForm expectedForm = new FinanceChecksNotesAddNoteForm(); expectedForm.setAttachment(uploadedFile); assertEquals(URLEncoder.encode(JsonUtil.getSerializedObject(expectedForm), CharEncoding.UTF_8), getDecryptedCookieValue(result.getResponse().getCookies(), "finance_checks_notes_new_note_form_" + projectId + "_" + applicantOrganisationId)); verify(financeCheckServiceMock).uploadFile(projectId, "application/pdf", 11, "testFile.pdf", "My content!".getBytes()); } |
FinanceChecksNotesAddNoteController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "removeAttachment") public String removeAttachment(@P("projectId")@PathVariable Long projectId, @PathVariable Long organisationId, @RequestParam(value = "removeAttachment") final Long attachmentId, @ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, UserResource loggedInUser, HttpServletRequest request, HttpServletResponse response, Model model) { if (postParametersMatchOrigin(request, projectId, organisationId, loggedInUser.getId())) { List<Long> attachments = loadAttachmentsFromCookie(request, projectId, organisationId); if (attachments.contains(attachmentId)) { financeCheckService.deleteFile(attachmentId) .andOnSuccess(() -> attachments.remove(attachments.indexOf(attachmentId))); } saveAttachmentsToCookie(response, attachments, projectId, organisationId); saveFormToCookie(response, projectId, organisationId, form); return redirectTo(rootView(projectId, organisationId)); } else { throw new ObjectNotFoundException(); } } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping String viewNewNote(@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
Model model,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping String saveNote(@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
@Valid @ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "uploadAttachment") String saveNewNoteAttachment(Model model,
@P("projectId")@PathVariable final Long projectId,
@PathVariable final Long organisationId,
@ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping("/attachment/{attachmentId}") @ResponseBody ResponseEntity<ByteArrayResource> downloadAttachment(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
@PathVariable Long attachmentId,
UserResource loggedInUser,
HttpServletRequest request); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @PostMapping(params = "removeAttachment") String removeAttachment(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
@RequestParam(value = "removeAttachment") final Long attachmentId,
@ModelAttribute(FORM_ATTR) FinanceChecksNotesAddNoteForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response,
Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_NOTES_SECTION')") @GetMapping("/cancel") String cancelNewForm(@P("projectId")@PathVariable Long projectId,
@PathVariable Long organisationId,
UserResource loggedInUser,
HttpServletRequest request,
HttpServletResponse response); } | @Test public void testRemoveAttachment() throws Exception { List<Long> attachmentIds = new ArrayList<>(); attachmentIds.add(1L); Cookie ck = createAttachmentsCookie(attachmentIds); Cookie originCookie = createOriginCookie(); when(financeCheckServiceMock.deleteFile(1L)).thenReturn(ServiceResult.serviceSuccess()); MvcResult result = mockMvc.perform(post("/project/" + projectId + "/finance-check/organisation/" + applicantOrganisationId + "/note/new-note") .param("removeAttachment", "1") .cookie(ck) .cookie(originCookie) .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param("noteTitle", "Title") .param("note", "Query")) .andExpect(redirectedUrlPattern("/project/" + projectId + "/finance-check/organisation/" + applicantOrganisationId + "/note/new-note**")) .andExpect(cookie().exists("finance_checks_notes_new_note_attachments_" + projectId + "_" + applicantOrganisationId)) .andExpect(cookie().exists("finance_checks_notes_new_note_form_" + projectId + "_" + applicantOrganisationId)) .andReturn(); List<Long> expectedAttachmentIds = new ArrayList<>(); assertEquals(URLEncoder.encode(JsonUtil.getSerializedObject(expectedAttachmentIds), CharEncoding.UTF_8), getDecryptedCookieValue(result.getResponse().getCookies(), "finance_checks_notes_new_note_attachments_" + projectId + "_" + applicantOrganisationId)); FinanceChecksNotesAddNoteForm expectedForm = new FinanceChecksNotesAddNoteForm(); expectedForm.setNote("Query"); expectedForm.setNoteTitle("Title"); assertEquals(URLEncoder.encode(JsonUtil.getSerializedObject(expectedForm), CharEncoding.UTF_8), getDecryptedCookieValue(result.getResponse().getCookies(), "finance_checks_notes_new_note_form_" + projectId + "_" + applicantOrganisationId)); verify(financeCheckServiceMock).deleteFile(1L); FinanceChecksNotesAddNoteForm form = (FinanceChecksNotesAddNoteForm) result.getModelAndView().getModel().get("form"); assertEquals("Title", form.getNoteTitle()); assertEquals("Query", form.getNote()); assertEquals(null, form.getAttachment()); } |
ProjectDetailsStartDateViewModel implements BasicProjectDetailsViewModel { public boolean isKtpCompetition() { return ktpCompetition; } ProjectDetailsStartDateViewModel(ProjectResource project, CompetitionResource competition); String getProjectName(); long getProjectDurationInMonths(); Long getProjectId(); Long getApplicationId(); Long getCompetitionId(); boolean isKtpCompetition(); boolean isProcurementCompetition(); } | @Test public void testKtpCompetition() { ProjectResource projectResource = ProjectResourceBuilder.newProjectResource() .withDuration(15L).build(); CompetitionResource competitionResource = CompetitionResourceBuilder.newCompetitionResource() .withFundingType(FundingType.KTP).build(); ProjectDetailsStartDateViewModel viewModel = new ProjectDetailsStartDateViewModel(projectResource, competitionResource); assertTrue(viewModel.isKtpCompetition()); }
@Test public void testNonKtpCompetition() { ProjectResource projectResource = ProjectResourceBuilder.newProjectResource() .withDuration(15L).build(); CompetitionResource competitionResource = CompetitionResourceBuilder.newCompetitionResource() .withFundingType(FundingType.GRANT).build(); ProjectDetailsStartDateViewModel viewModel = new ProjectDetailsStartDateViewModel(projectResource, competitionResource); assertFalse(viewModel.isKtpCompetition()); } |
GoogleAnalyticsDataLayerController { @GetMapping("/project/{projectId}/user-roles") public RestResult<List<Role>> getRolesByProjectIdForCurrentUser(@PathVariable("projectId") long projectId) { return googleAnalyticsDataLayerService.getRolesByProjectIdForCurrentUser(projectId).toGetResponse(); } @GetMapping("/application/{applicationId}/competition-name") RestResult<String> getCompetitionNameForApplication(@PathVariable("applicationId") long applicationId); @GetMapping("/invite/{inviteHash}/competition-name") RestResult<String> getCompetitionNameForInvite(@PathVariable("inviteHash") String inviteHash); @GetMapping("/application/{applicationId}/user-roles") RestResult<List<Role>> getRolesByApplicationIdForCurrentUser(@PathVariable("applicationId") long applicationId); @GetMapping("/competition/{competitionId}/competition-name") RestResult<String> getCompetitionName(@PathVariable("competitionId") long competitionId); @GetMapping("/project/{projectId}/competition-name") RestResult<String> getCompetitionNameForProject(@PathVariable("projectId") long projectId); @GetMapping("/project/{projectId}/user-roles") RestResult<List<Role>> getRolesByProjectIdForCurrentUser(@PathVariable("projectId") long projectId); @GetMapping("/assessment/{assessmentId}/competition-name") RestResult<String> getCompetitionNameForAssessment(@PathVariable("assessmentId") long assessmentId); @GetMapping("/project/{projectId}/application-id") RestResult<Long> getApplicationIdForProject(@PathVariable("projectId") long projectId); @GetMapping("/assessment/{assessmentId}/application-id") RestResult<Long> getApplicationIdForAssessment(@PathVariable("assessmentId") long assessmentId); } | @Test public void getProjectRolesById() throws Exception { final long projectId = 112L; final List<Role> roles = asList(Role.PARTNER, Role.PROJECT_MANAGER); when(googleAnalyticsDataLayerServiceMock.getRolesByProjectIdForCurrentUser(projectId)) .thenReturn(serviceSuccess(roles)); mockMvc.perform(get("/analytics/project/{projectId}/user-roles", projectId)) .andExpect(status().isOk()) .andExpect(content().string(toJson(roles))); } |
ProjectDetailsViewModel { public boolean isKtpCompetition() { return ktpCompetition; } ProjectDetailsViewModel(ProjectResource project,
Long competitionId,
String competitionName,
UserResource userResource,
OrganisationResource leadOrganisation,
boolean locationPerPartnerRequired,
List<PartnerOrganisationResource> partnerOrganisations,
List<OrganisationResource> organisations,
String financeReviewerName,
String financeReviewerEmail,
boolean spendProfileGenerated,
boolean ktpCompetition); static ProjectDetailsViewModel editDurationViewModel(ProjectResource project, boolean ktpCompetition); ProjectResource getProject(); boolean isHandleOffline(); boolean isCompleteOffline(); Long getCompetitionId(); String getCompetitionName(); OrganisationResource getLeadOrganisation(); String getFinanceReviewerName(); String getFinanceReviewerEmail(); boolean isLocationPerPartnerRequired(); String getPostcodeForPartnerOrganisation(Long organisationId); List<PartnerOrganisationResource> getPartnerOrganisations(); boolean isFinanceReviewerAssigned(); boolean isSpendProfileGenerated(); boolean isAbleToManageProjectState(); boolean isProjectFinance(); String getLocationForPartnerOrganisation(Long organisationId); boolean isLeadOrganisationInternational(); boolean modifyTheFinanceReviewer(); boolean modifyStartDate(); boolean isKtpCompetition(); @Override boolean equals(Object o); @Override int hashCode(); } | @Test public void testKtpCompetition() { ProjectDetailsViewModel viewModel = new ProjectDetailsViewModel(null, null, null, null, null, false, null, null, null, null, false, true); assertTrue(viewModel.isKtpCompetition()); }
@Test public void testNonKtpCompetition() { ProjectDetailsViewModel viewModel = new ProjectDetailsViewModel(null, null, null, null, null, false, null, null, null, null, false, false); assertFalse(viewModel.isKtpCompetition()); } |
ProjectDetailsController { @PreAuthorize("hasAnyAuthority('project_finance', 'comp_admin', 'support', 'innovation_lead', 'stakeholder', 'external_finance')") @SecuredBySpring(value = "VIEW_PROJECT_DETAILS", description = "Project finance, comp admin, support, innovation lead and stakeholders can view the project details") @GetMapping("/{projectId}/details") public String viewProjectDetails(@PathVariable("competitionId") final Long competitionId, @PathVariable("projectId") final Long projectId, Model model, UserResource loggedInUser, boolean isSpendProfileGenerated) { ProjectResource projectResource = projectService.getById(projectId); OrganisationResource leadOrganisationResource = projectService.getLeadOrganisation(projectId); CompetitionResource competitionResource = competitionRestService.getCompetitionById(competitionId).getSuccess(); boolean locationPerPartnerRequired = competitionResource.isLocationPerPartner(); Optional<SimpleUserResource> financeReviewer = Optional.ofNullable(projectResource.getFinanceReviewer()) .map(id -> financeReviewerRestService.findFinanceReviewerForProject(projectId).getSuccess()); List<PartnerOrganisationResource> partnerOrganisations = locationPerPartnerRequired? partnerOrganisationRestService.getProjectPartnerOrganisations(projectId).getSuccess() : Collections.emptyList(); List<OrganisationResource> organisations = partnerOrganisations.stream() .map(p -> organisationRestService.getOrganisationById(p.getOrganisation()).getSuccess()) .collect(Collectors.toList()); model.addAttribute("model", new ProjectDetailsViewModel(projectResource, competitionId, competitionResource.getName(), loggedInUser, leadOrganisationResource, locationPerPartnerRequired, partnerOrganisations, organisations, financeReviewer.map(SimpleUserResource::getName).orElse(null), financeReviewer.map(SimpleUserResource::getEmail).orElse(null), isSpendProfileGenerated, competitionResource.isKtp())); return "project/detail"; } ProjectDetailsController(); @Autowired ProjectDetailsController(ProjectService projectService, CompetitionRestService competitionRestService,
ProjectDetailsService projectDetailsService,
PartnerOrganisationRestService partnerOrganisationRestService,
OrganisationRestService organisationRestService,
FinanceReviewerRestService financeReviewerRestService); @PreAuthorize("hasAnyAuthority('project_finance', 'comp_admin', 'support', 'innovation_lead', 'stakeholder', 'external_finance')") @SecuredBySpring(value = "VIEW_PROJECT_DETAILS", description = "Project finance, comp admin, support, innovation lead and stakeholders can view the project details") @GetMapping("/{projectId}/details") String viewProjectDetails(@PathVariable("competitionId") final Long competitionId,
@PathVariable("projectId") final Long projectId, Model model,
UserResource loggedInUser,
boolean isSpendProfileGenerated); @PreAuthorize("hasAuthority('ifs_administrator')") @SecuredBySpring(value = "VIEW_START_DATE", description = "Only the IFS Administrator can view the page to edit the project start date") @GetMapping("/{projectId}/details/start-date") String viewStartDate(@PathVariable("projectId") final long projectId, Model model,
@ModelAttribute(name = FORM_ATTR_NAME, binding = false) ProjectDetailsStartDateForm form,
UserResource loggedInUser); @PreAuthorize("hasAuthority('ifs_administrator')") @SecuredBySpring(value = "UPDATE_START_DATE", description = "Only the IFS Administrator can update the project start date") @PostMapping("/{projectId}/details/start-date") String updateStartDate(@PathVariable("competitionId") final long competitionId,
@PathVariable("projectId") final long projectId,
@ModelAttribute(FORM_ATTR_NAME) ProjectDetailsStartDateForm form,
@SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "VIEW_EDIT_PROJECT_DURATION", description = "Only the project finance can view the page to edit the project duration") @GetMapping("/{projectId}/duration") String viewEditProjectDuration(@PathVariable("projectId") final long projectId, Model model,
UserResource loggedInUser); @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "UPDATE_PROJECT_DURATION", description = "Only the project finance can update the project duration") @PostMapping("/{projectId}/duration") String updateProjectDuration(@PathVariable("projectId") final long projectId,
@Valid @ModelAttribute(FORM_ATTR_NAME) ProjectDurationForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); } | @Test public void viewProjectDetails() throws Exception { Long competitionId = 1L; Long projectId = 1L; setLoggedInUser(newUserResource().withRolesGlobal(singletonList(PROJECT_FINANCE)).build()); CompetitionResource competition = newCompetitionResource() .withId(competitionId) .withName("Comp 1") .withFundingType(FundingType.GRANT) .withLocationPerPartner(true) .build(); ProjectResource project = newProjectResource() .withId(projectId) .withName("Project 1") .build(); OrganisationResource leadOrganisation = newOrganisationResource() .withId(1L) .withName("Lead Org 1") .build(); OrganisationResource partnerOrganisation = newOrganisationResource() .withId(2L) .withName("Partner Org 1") .build(); List<ProjectUserResource> projectUsers = buildProjectUsers(leadOrganisation, partnerOrganisation); ProjectUserResource projectManagerProjectUser = newProjectUserResource(). withUser(loggedInUser.getId()). withOrganisation(leadOrganisation.getId()). withRole(PROJECT_MANAGER). build(); ProjectUserResource leadFinanceContactProjectUser = newProjectUserResource(). withUser(loggedInUser.getId()). withOrganisation(leadOrganisation.getId()). withRole(FINANCE_CONTACT). build(); ProjectUserResource partnerFinanceContactProjectUser = newProjectUserResource(). withUser(2L). withOrganisation(partnerOrganisation.getId()). withRole(FINANCE_CONTACT). build(); projectUsers.add(projectManagerProjectUser); projectUsers.add(leadFinanceContactProjectUser); projectUsers.add(partnerFinanceContactProjectUser); List<PartnerOrganisationResource> partnerOrganisations = PartnerOrganisationResourceBuilder.newPartnerOrganisationResource() .withOrganisation(1L, 2L) .withPostcode("TW14 9QG", "UB7 8QF") .build(2); when(projectService.getById(project.getId())).thenReturn(project); when(projectService.getProjectUsersForProject(project.getId())).thenReturn(projectUsers); when(projectService.getLeadOrganisation(project.getId())).thenReturn(leadOrganisation); when(competitionRestService.getCompetitionById(competitionId)).thenReturn(restSuccess(competition)); when(partnerOrganisationRestService.getProjectPartnerOrganisations(projectId)).thenReturn(restSuccess(partnerOrganisations)); when(organisationRestService.getOrganisationById(1L)).thenReturn(restSuccess(leadOrganisation)); when(organisationRestService.getOrganisationById(2L)).thenReturn(restSuccess(partnerOrganisation)); MvcResult result = mockMvc.perform(get("/competition/" + competitionId + "/project/" + projectId + "/details")) .andExpect(view().name("project/detail")) .andReturn(); ProjectDetailsViewModel model = (ProjectDetailsViewModel) result.getModelAndView().getModel().get("model"); assertEquals(project, model.getProject()); assertEquals(competitionId, model.getCompetitionId()); assertEquals("Comp 1", model.getCompetitionName()); assertTrue(model.isAbleToManageProjectState()); assertEquals("Lead Org 1", model.getLeadOrganisation().getName()); assertTrue(model.isLocationPerPartnerRequired()); assertEquals("TW14 9QG", model.getPostcodeForPartnerOrganisation(1L)); assertEquals("UB7 8QF", model.getPostcodeForPartnerOrganisation(2L)); assertFalse(model.isKtpCompetition()); } |
ProjectDetailsController { @PreAuthorize("hasAuthority('ifs_administrator')") @SecuredBySpring(value = "VIEW_START_DATE", description = "Only the IFS Administrator can view the page to edit the project start date") @GetMapping("/{projectId}/details/start-date") public String viewStartDate(@PathVariable("projectId") final long projectId, Model model, @ModelAttribute(name = FORM_ATTR_NAME, binding = false) ProjectDetailsStartDateForm form, UserResource loggedInUser) { ProjectResource projectResource = projectService.getById(projectId); CompetitionResource competitionResource = competitionRestService.getCompetitionById(projectResource.getCompetition()).getSuccess(); LocalDate defaultStartDate = projectResource.getTargetStartDate().withDayOfMonth(1); form.setProjectStartDate(defaultStartDate); return doViewProjectStartDate(model, projectResource, form, competitionResource); } ProjectDetailsController(); @Autowired ProjectDetailsController(ProjectService projectService, CompetitionRestService competitionRestService,
ProjectDetailsService projectDetailsService,
PartnerOrganisationRestService partnerOrganisationRestService,
OrganisationRestService organisationRestService,
FinanceReviewerRestService financeReviewerRestService); @PreAuthorize("hasAnyAuthority('project_finance', 'comp_admin', 'support', 'innovation_lead', 'stakeholder', 'external_finance')") @SecuredBySpring(value = "VIEW_PROJECT_DETAILS", description = "Project finance, comp admin, support, innovation lead and stakeholders can view the project details") @GetMapping("/{projectId}/details") String viewProjectDetails(@PathVariable("competitionId") final Long competitionId,
@PathVariable("projectId") final Long projectId, Model model,
UserResource loggedInUser,
boolean isSpendProfileGenerated); @PreAuthorize("hasAuthority('ifs_administrator')") @SecuredBySpring(value = "VIEW_START_DATE", description = "Only the IFS Administrator can view the page to edit the project start date") @GetMapping("/{projectId}/details/start-date") String viewStartDate(@PathVariable("projectId") final long projectId, Model model,
@ModelAttribute(name = FORM_ATTR_NAME, binding = false) ProjectDetailsStartDateForm form,
UserResource loggedInUser); @PreAuthorize("hasAuthority('ifs_administrator')") @SecuredBySpring(value = "UPDATE_START_DATE", description = "Only the IFS Administrator can update the project start date") @PostMapping("/{projectId}/details/start-date") String updateStartDate(@PathVariable("competitionId") final long competitionId,
@PathVariable("projectId") final long projectId,
@ModelAttribute(FORM_ATTR_NAME) ProjectDetailsStartDateForm form,
@SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "VIEW_EDIT_PROJECT_DURATION", description = "Only the project finance can view the page to edit the project duration") @GetMapping("/{projectId}/duration") String viewEditProjectDuration(@PathVariable("projectId") final long projectId, Model model,
UserResource loggedInUser); @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "UPDATE_PROJECT_DURATION", description = "Only the project finance can update the project duration") @PostMapping("/{projectId}/duration") String updateProjectDuration(@PathVariable("projectId") final long projectId,
@Valid @ModelAttribute(FORM_ATTR_NAME) ProjectDurationForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); } | @Test public void viewStartDate() throws Exception { Long competitionId = 1L; ApplicationResource applicationResource = newApplicationResource().build(); CompetitionResource competition = newCompetitionResource() .withId(competitionId) .withName("Comp 1") .withFundingType(FundingType.GRANT) .withLocationPerPartner(true) .build(); ProjectResource project = newProjectResource(). withCompetition(competition.getId()). withApplication(applicationResource). with(name("My Project")). withDuration(4L). withTargetStartDate(LocalDate.now().withDayOfMonth(5)). withDuration(4L). build(); OrganisationResource leadOrganisation = newOrganisationResource().build(); List<ProjectUserResource> projectUsers = newProjectUserResource(). withUser(loggedInUser.getId()). withOrganisation(leadOrganisation.getId()). withRole(PARTNER). build(1); when(projectService.getById(project.getId())).thenReturn(project); when(projectService.getProjectUsersForProject(project.getId())).thenReturn(projectUsers); when(projectService.getLeadOrganisation(project.getId())).thenReturn(leadOrganisation); when(competitionRestService.getCompetitionById(competitionId)).thenReturn(restSuccess(competition)); MvcResult result = mockMvc.perform(get("/competition/{competitionId}/project/{projectId}/details/start-date", project.getCompetition(), project.getId())) .andExpect(status().isOk()) .andExpect(view().name("project/details-start-date")) .andReturn(); Map<String, Object> model = result.getModelAndView().getModel(); ProjectDetailsStartDateViewModel viewModel = (ProjectDetailsStartDateViewModel) model.get("model"); assertEquals(project.getId(), viewModel.getProjectId()); assertEquals(project.getApplication(), (long) viewModel.getApplicationId()); assertEquals(project.getName(), viewModel.getProjectName()); assertEquals(project.getDurationInMonths(), Long.valueOf(viewModel.getProjectDurationInMonths())); assertFalse(viewModel.isKtpCompetition()); ProjectDetailsStartDateForm form = (ProjectDetailsStartDateForm) model.get(FORM_ATTR_NAME); assertEquals(project.getTargetStartDate().withDayOfMonth(1), form.getProjectStartDate()); } |
ProjectDetailsController { @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "VIEW_EDIT_PROJECT_DURATION", description = "Only the project finance can view the page to edit the project duration") @GetMapping("/{projectId}/duration") public String viewEditProjectDuration(@PathVariable("projectId") final long projectId, Model model, UserResource loggedInUser) { ProjectDurationForm form = new ProjectDurationForm(); return doViewEditProjectDuration(projectId, model, form); } ProjectDetailsController(); @Autowired ProjectDetailsController(ProjectService projectService, CompetitionRestService competitionRestService,
ProjectDetailsService projectDetailsService,
PartnerOrganisationRestService partnerOrganisationRestService,
OrganisationRestService organisationRestService,
FinanceReviewerRestService financeReviewerRestService); @PreAuthorize("hasAnyAuthority('project_finance', 'comp_admin', 'support', 'innovation_lead', 'stakeholder', 'external_finance')") @SecuredBySpring(value = "VIEW_PROJECT_DETAILS", description = "Project finance, comp admin, support, innovation lead and stakeholders can view the project details") @GetMapping("/{projectId}/details") String viewProjectDetails(@PathVariable("competitionId") final Long competitionId,
@PathVariable("projectId") final Long projectId, Model model,
UserResource loggedInUser,
boolean isSpendProfileGenerated); @PreAuthorize("hasAuthority('ifs_administrator')") @SecuredBySpring(value = "VIEW_START_DATE", description = "Only the IFS Administrator can view the page to edit the project start date") @GetMapping("/{projectId}/details/start-date") String viewStartDate(@PathVariable("projectId") final long projectId, Model model,
@ModelAttribute(name = FORM_ATTR_NAME, binding = false) ProjectDetailsStartDateForm form,
UserResource loggedInUser); @PreAuthorize("hasAuthority('ifs_administrator')") @SecuredBySpring(value = "UPDATE_START_DATE", description = "Only the IFS Administrator can update the project start date") @PostMapping("/{projectId}/details/start-date") String updateStartDate(@PathVariable("competitionId") final long competitionId,
@PathVariable("projectId") final long projectId,
@ModelAttribute(FORM_ATTR_NAME) ProjectDetailsStartDateForm form,
@SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "VIEW_EDIT_PROJECT_DURATION", description = "Only the project finance can view the page to edit the project duration") @GetMapping("/{projectId}/duration") String viewEditProjectDuration(@PathVariable("projectId") final long projectId, Model model,
UserResource loggedInUser); @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "UPDATE_PROJECT_DURATION", description = "Only the project finance can update the project duration") @PostMapping("/{projectId}/duration") String updateProjectDuration(@PathVariable("projectId") final long projectId,
@Valid @ModelAttribute(FORM_ATTR_NAME) ProjectDurationForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); } | @Test public void viewEditProjectDuration() throws Exception { long competitionId = 1L; String competitionName = "Comp 1"; long projectId = 11L; CompetitionResource competition = newCompetitionResource() .withId(competitionId) .withFundingType(FundingType.GRANT) .withName(competitionName) .build(); ProjectResource project = newProjectResource() .withId(projectId) .withName("Project 1") .withTargetStartDate(LocalDate.of(2018, 3, 1)) .withDuration(36L) .withCompetition(competition.getId()) .build(); when(projectService.getById(projectId)).thenReturn(project); when(competitionRestService.getCompetitionById(competitionId)).thenReturn(restSuccess(competition)); MvcResult result = mockMvc.perform(get("/competition/" + competitionId + "/project/" + projectId + "/duration")) .andExpect(status().isOk()) .andExpect(view().name("project/edit-duration")) .andReturn(); ProjectDetailsViewModel viewModel = (ProjectDetailsViewModel) result.getModelAndView().getModel().get("model"); assertEquals(project, viewModel.getProject()); assertEquals(project.getCompetition(), (long) viewModel.getCompetitionId()); assertEquals(project.getCompetitionName(), viewModel.getCompetitionName()); assertNull(viewModel.getLeadOrganisation()); assertFalse(viewModel.isLocationPerPartnerRequired()); assertFalse(viewModel.isKtpCompetition()); ProjectDurationForm form = (ProjectDurationForm) result.getModelAndView().getModel().get("form"); assertEquals(new ProjectDurationForm(), form); verify(projectService).getById(projectId); verify(competitionRestService).getCompetitionById(competitionId); } |
ProjectDetailsController { @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "UPDATE_PROJECT_DURATION", description = "Only the project finance can update the project duration") @PostMapping("/{projectId}/duration") public String updateProjectDuration(@PathVariable("projectId") final long projectId, @Valid @ModelAttribute(FORM_ATTR_NAME) ProjectDurationForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, Model model, UserResource loggedInUser) { Supplier<String> failureView = () -> doViewEditProjectDuration(projectId, model, form); Supplier<String> successView = () -> "redirect:/project/" + projectId + "/finance-check"; validateDuration(form.getDurationInMonths(), validationHandler); return validationHandler.failNowOrSucceedWith(failureView, () -> { ServiceResult<Void> updateResult = projectDetailsService.updateProjectDuration(projectId, Long.parseLong(form.getDurationInMonths())); return validationHandler.addAnyErrors(updateResult, toField("durationInMonths")).failNowOrSucceedWith(failureView, successView); }); } ProjectDetailsController(); @Autowired ProjectDetailsController(ProjectService projectService, CompetitionRestService competitionRestService,
ProjectDetailsService projectDetailsService,
PartnerOrganisationRestService partnerOrganisationRestService,
OrganisationRestService organisationRestService,
FinanceReviewerRestService financeReviewerRestService); @PreAuthorize("hasAnyAuthority('project_finance', 'comp_admin', 'support', 'innovation_lead', 'stakeholder', 'external_finance')") @SecuredBySpring(value = "VIEW_PROJECT_DETAILS", description = "Project finance, comp admin, support, innovation lead and stakeholders can view the project details") @GetMapping("/{projectId}/details") String viewProjectDetails(@PathVariable("competitionId") final Long competitionId,
@PathVariable("projectId") final Long projectId, Model model,
UserResource loggedInUser,
boolean isSpendProfileGenerated); @PreAuthorize("hasAuthority('ifs_administrator')") @SecuredBySpring(value = "VIEW_START_DATE", description = "Only the IFS Administrator can view the page to edit the project start date") @GetMapping("/{projectId}/details/start-date") String viewStartDate(@PathVariable("projectId") final long projectId, Model model,
@ModelAttribute(name = FORM_ATTR_NAME, binding = false) ProjectDetailsStartDateForm form,
UserResource loggedInUser); @PreAuthorize("hasAuthority('ifs_administrator')") @SecuredBySpring(value = "UPDATE_START_DATE", description = "Only the IFS Administrator can update the project start date") @PostMapping("/{projectId}/details/start-date") String updateStartDate(@PathVariable("competitionId") final long competitionId,
@PathVariable("projectId") final long projectId,
@ModelAttribute(FORM_ATTR_NAME) ProjectDetailsStartDateForm form,
@SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "VIEW_EDIT_PROJECT_DURATION", description = "Only the project finance can view the page to edit the project duration") @GetMapping("/{projectId}/duration") String viewEditProjectDuration(@PathVariable("projectId") final long projectId, Model model,
UserResource loggedInUser); @PreAuthorize("hasAuthority('project_finance')") @SecuredBySpring(value = "UPDATE_PROJECT_DURATION", description = "Only the project finance can update the project duration") @PostMapping("/{projectId}/duration") String updateProjectDuration(@PathVariable("projectId") final long projectId,
@Valid @ModelAttribute(FORM_ATTR_NAME) ProjectDurationForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); } | @Test public void updateProjectDurationFailure() throws Exception { long competitionId = 1L; long projectId = 11L; String durationInMonths = "18"; when(projectDetailsService.updateProjectDuration(projectId, 18L)) .thenReturn(serviceFailure(PROJECT_SETUP_PROJECT_DURATION_CANNOT_BE_CHANGED_ONCE_SPEND_PROFILE_HAS_BEEN_GENERATED)); CompetitionResource competition = newCompetitionResource() .withId(competitionId) .withFundingType(FundingType.GRANT).build(); ProjectResource project = newProjectResource() .withCompetition(competition.getId()).build(); when(projectService.getById(projectId)).thenReturn(project); when(competitionRestService.getCompetitionById(competitionId)).thenReturn(restSuccess(competition)); mockMvc.perform(post("/competition/" + competitionId + "/project/" + projectId + "/duration") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param("durationInMonths", durationInMonths)) .andExpect(status().isOk()) .andExpect(view().name("project/edit-duration")) .andReturn(); verify(projectDetailsService).updateProjectDuration(projectId, 18L); verify(projectService).getById(projectId); verify(competitionRestService).getCompetitionById(competitionId); }
@Test public void updateProjectDurationSuccess() throws Exception { long competitionId = 1L; long projectId = 11L; String durationInMonths = "18"; when(projectDetailsService.updateProjectDuration(projectId, 18L)).thenReturn(serviceSuccess()); mockMvc.perform(post("/competition/" + competitionId + "/project/" + projectId + "/duration") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param("durationInMonths", durationInMonths)) .andExpect(status().is3xxRedirection()) .andExpect(view().name("redirect:/project/" + projectId + "/finance-check")) .andReturn(); verify(projectDetailsService).updateProjectDuration(projectId, 18L); } |
DocumentsController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/all") public String viewAllDocuments(@PathVariable("projectId") long projectId, Model model, UserResource loggedInUser) { model.addAttribute("model", populator.populateAllDocuments(projectId, loggedInUser.getId())); return "project/documents-all"; } DocumentsController(); @Autowired DocumentsController(DocumentsPopulator populator, DocumentsRestService documentsRestService); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/all") String viewAllDocuments(@PathVariable("projectId") long projectId, Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}") String viewDocument(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId,
Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}/download") @ResponseBody ResponseEntity<ByteArrayResource> downloadDocument(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'APPROVE_DOCUMENTS')") @PostMapping("/config/{documentConfigId}") String documentDecision(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId,
@ModelAttribute(FORM_ATTR) DocumentForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); } | @Test public void viewAllDocuments() throws Exception { long projectId = 1L; ProjectResource project = newProjectResource() .withId(projectId) .withApplication(2L) .withCompetition(3L) .withName("Project 12") .build(); AllDocumentsViewModel viewModel = new AllDocumentsViewModel(project, emptyList(), true, false); when(populator.populateAllDocuments(projectId, loggedInUser.getId())).thenReturn(viewModel); MvcResult result = mockMvc.perform(get("/project/" + projectId + "/document/all")) .andExpect(view().name("project/documents-all")) .andReturn(); AllDocumentsViewModel returnedViewModel = (AllDocumentsViewModel) result.getModelAndView().getModel().get("model"); assertEquals(viewModel, returnedViewModel); } |
DocumentsController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}") public String viewDocument(@PathVariable("projectId") long projectId, @PathVariable("documentConfigId") long documentConfigId, Model model, UserResource loggedInUser) { return doViewDocument(projectId, loggedInUser.getId(), documentConfigId, model, new DocumentForm()); } DocumentsController(); @Autowired DocumentsController(DocumentsPopulator populator, DocumentsRestService documentsRestService); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/all") String viewAllDocuments(@PathVariable("projectId") long projectId, Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}") String viewDocument(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId,
Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}/download") @ResponseBody ResponseEntity<ByteArrayResource> downloadDocument(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'APPROVE_DOCUMENTS')") @PostMapping("/config/{documentConfigId}") String documentDecision(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId,
@ModelAttribute(FORM_ATTR) DocumentForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); } | @Test public void viewDocument() throws Exception { long projectId = 1L; long documentConfigId = 2L; long applicationId = 3L; DocumentViewModel viewModel = new DocumentViewModel(projectId, "Project 12", applicationId, documentConfigId, "Risk Register", "Guidance for Risk Register", null, DocumentStatus.UNSET, "",true, true); when(populator.populateViewDocument(projectId, loggedInUser.getId(), documentConfigId)).thenReturn(viewModel); MvcResult result = mockMvc.perform(get("/project/" + projectId + "/document/config/" + documentConfigId)) .andExpect(view().name("project/document")) .andReturn(); Map<String, Object> model = result.getModelAndView().getModel(); DocumentViewModel returnedViewModel = (DocumentViewModel) model.get("model"); assertEquals(viewModel, returnedViewModel); assertEquals(new DocumentForm(), model.get("form")); } |
GoogleAnalyticsDataLayerController { @GetMapping("/project/{projectId}/application-id") public RestResult<Long> getApplicationIdForProject(@PathVariable("projectId") long projectId) { return googleAnalyticsDataLayerService.getApplicationIdForProject(projectId).toGetResponse(); } @GetMapping("/application/{applicationId}/competition-name") RestResult<String> getCompetitionNameForApplication(@PathVariable("applicationId") long applicationId); @GetMapping("/invite/{inviteHash}/competition-name") RestResult<String> getCompetitionNameForInvite(@PathVariable("inviteHash") String inviteHash); @GetMapping("/application/{applicationId}/user-roles") RestResult<List<Role>> getRolesByApplicationIdForCurrentUser(@PathVariable("applicationId") long applicationId); @GetMapping("/competition/{competitionId}/competition-name") RestResult<String> getCompetitionName(@PathVariable("competitionId") long competitionId); @GetMapping("/project/{projectId}/competition-name") RestResult<String> getCompetitionNameForProject(@PathVariable("projectId") long projectId); @GetMapping("/project/{projectId}/user-roles") RestResult<List<Role>> getRolesByProjectIdForCurrentUser(@PathVariable("projectId") long projectId); @GetMapping("/assessment/{assessmentId}/competition-name") RestResult<String> getCompetitionNameForAssessment(@PathVariable("assessmentId") long assessmentId); @GetMapping("/project/{projectId}/application-id") RestResult<Long> getApplicationIdForProject(@PathVariable("projectId") long projectId); @GetMapping("/assessment/{assessmentId}/application-id") RestResult<Long> getApplicationIdForAssessment(@PathVariable("assessmentId") long assessmentId); } | @Test public void getApplicationIdForProject() throws Exception { final long projectId = 345L; final long applicationId = 678L; when(googleAnalyticsDataLayerServiceMock.getApplicationIdForProject(projectId)) .thenReturn(serviceSuccess(applicationId)); mockMvc.perform(get("/analytics/project/{projectId}/application-id", projectId)) .andExpect(status().isOk()) .andExpect(content().string(toJson(applicationId))); } |
DocumentsController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}/download") @ResponseBody public ResponseEntity<ByteArrayResource> downloadDocument(@PathVariable("projectId") long projectId, @PathVariable("documentConfigId") long documentConfigId) { final Optional<ByteArrayResource> fileContents = documentsRestService.getFileContents(projectId, documentConfigId).getSuccess(); final Optional<FileEntryResource> fileEntryDetails = documentsRestService.getFileEntryDetails(projectId, documentConfigId).getSuccess(); return returnFileIfFoundOrThrowNotFoundException(projectId, documentConfigId, fileContents, fileEntryDetails); } DocumentsController(); @Autowired DocumentsController(DocumentsPopulator populator, DocumentsRestService documentsRestService); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/all") String viewAllDocuments(@PathVariable("projectId") long projectId, Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}") String viewDocument(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId,
Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}/download") @ResponseBody ResponseEntity<ByteArrayResource> downloadDocument(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'APPROVE_DOCUMENTS')") @PostMapping("/config/{documentConfigId}") String documentDecision(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId,
@ModelAttribute(FORM_ATTR) DocumentForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); } | @Test public void downloadDocument() throws Exception { long projectId = 1L; long documentConfigId = 2L; ByteArrayResource fileContents = new ByteArrayResource("My content!".getBytes()); FileEntryResource fileEntryDetails = newFileEntryResource().withName("Risk Register").build(); when(documentsRestService.getFileContents(projectId, documentConfigId)). thenReturn(restSuccess(Optional.of(fileContents))); when(documentsRestService.getFileEntryDetails(projectId, documentConfigId)). thenReturn(restSuccess(Optional.of(fileEntryDetails))); MvcResult result = mockMvc.perform(get("/project/" + projectId + "/document/config/" + documentConfigId + "/download")). andExpect(status().isOk()). andReturn(); assertEquals("My content!", result.getResponse().getContentAsString()); assertEquals("inline; filename=\"" + fileEntryDetails.getName() + "\"", result.getResponse().getHeader("Content-Disposition")); } |
DocumentsController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'APPROVE_DOCUMENTS')") @PostMapping("/config/{documentConfigId}") public String documentDecision(@PathVariable("projectId") long projectId, @PathVariable("documentConfigId") long documentConfigId, @ModelAttribute(FORM_ATTR) DocumentForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, Model model, UserResource loggedInUser) { Supplier<String> successView = () -> redirectToViewDocumentPage(projectId, documentConfigId); Supplier<String> failureView = () -> doViewDocument(projectId, loggedInUser.getId(), documentConfigId, model, form); RestResult<Void> result = documentsRestService.documentDecision(projectId, documentConfigId, new ProjectDocumentDecision(form.getApproved(), form.getRejectionReason())); return validationHandler.addAnyErrors(result, asGlobalErrors()). failNowOrSucceedWith(failureView, successView); } DocumentsController(); @Autowired DocumentsController(DocumentsPopulator populator, DocumentsRestService documentsRestService); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/all") String viewAllDocuments(@PathVariable("projectId") long projectId, Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}") String viewDocument(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId,
Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_DOCUMENTS_SECTION')") @GetMapping("/config/{documentConfigId}/download") @ResponseBody ResponseEntity<ByteArrayResource> downloadDocument(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'APPROVE_DOCUMENTS')") @PostMapping("/config/{documentConfigId}") String documentDecision(@PathVariable("projectId") long projectId,
@PathVariable("documentConfigId") long documentConfigId,
@ModelAttribute(FORM_ATTR) DocumentForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); } | @Test public void documentDecision() throws Exception { long projectId = 1L; long documentConfigId = 2L; when(documentsRestService.documentDecision(projectId, documentConfigId, new ProjectDocumentDecision(true, null))).thenReturn(restSuccess()); mockMvc.perform( post("/project/" + projectId + "/document/config/" + documentConfigId) .param("approved", "true")) .andExpect(status().is3xxRedirection()) .andExpect(view().name("redirect:/project/" + projectId + "/document/config/" + documentConfigId)); verify(documentsRestService).documentDecision(projectId, documentConfigId, new ProjectDocumentDecision(true, null)); }
@Test public void submitDocumentFailure() throws Exception { long projectId = 1L; long documentConfigId = 2L; long applicationId = 3L; when(documentsRestService.documentDecision(projectId, documentConfigId, new ProjectDocumentDecision(true, null))). thenReturn(restFailure(PROJECT_SETUP_PROJECT_DOCUMENT_CANNOT_BE_ACCEPTED_OR_REJECTED)); FileEntryResource fileEntryDetails = newFileEntryResource().withName("Risk Register").build(); FileDetailsViewModel fileDetailsViewModel = new FileDetailsViewModel(fileEntryDetails); DocumentViewModel viewModel = new DocumentViewModel(projectId, "Project 12", applicationId, documentConfigId, "Risk Register", "Guidance for Risk Register", fileDetailsViewModel, DocumentStatus.UNSET, "",true, true); when(populator.populateViewDocument(projectId, loggedInUser.getId(), documentConfigId)).thenReturn(viewModel); MvcResult result = mockMvc.perform( post("/project/" + projectId + "/document/config/" + documentConfigId) .param("approved", "true")) .andExpect(status().isOk()) .andExpect(view().name("project/document")) .andReturn(); Map<String, Object> model = result.getModelAndView().getModel(); DocumentViewModel returnedViewModel = (DocumentViewModel) model.get("model"); DocumentForm form = new DocumentForm(); form.setApproved(true); assertEquals(viewModel, returnedViewModel); assertEquals(form, model.get("form")); } |
ProjectSetupCompleteController { @GetMapping public String viewSetupCompletePage(@ModelAttribute(name = "form", binding = false) ProjectSetupCompleteForm form, @PathVariable long projectId, @PathVariable long competitionId, Model model, UserResource user) { ProjectResource project = projectRestService.getProjectById(projectId).getSuccess(); model.addAttribute("model", new ProjectSetupCompleteViewModel(project)); return "project/setup-complete"; } @GetMapping String viewSetupCompletePage(@ModelAttribute(name = "form", binding = false) ProjectSetupCompleteForm form,
@PathVariable long projectId,
@PathVariable long competitionId,
Model model,
UserResource user); @PostMapping String saveProjectState(@ModelAttribute(name = "form") ProjectSetupCompleteForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
Model model,
UserResource user); } | @Test public void viewSetupCompletePage() throws Exception { when(projectRestService.getProjectById(projectId)).thenReturn(restSuccess(project)); MvcResult result = mockMvc.perform(get("/competition/{competitionId}/project/{projectId}/setup-complete", competitionId, projectId)) .andExpect(view().name("project/setup-complete")) .andReturn(); ProjectSetupCompleteViewModel viewModel = (ProjectSetupCompleteViewModel) result.getModelAndView().getModel().get("model"); assertEquals(viewModel.getProjectId(), projectId); assertEquals(viewModel.getApplicationId(), 3L); assertEquals(viewModel.getCompetitionId(), competitionId); assertEquals(viewModel.getProjectName(), "Project name"); assertEquals(viewModel.getState(), ProjectState.LIVE); assertTrue(viewModel.isReadonly()); } |
CompetitionsBankDetailsController { @SecuredBySpring(value = "PENDING_BANK_DETAILS_APPROVALS", description = "Project finance users can view and action pending bank details approvals for all competitions") @GetMapping("/status/pending-bank-details-approvals") @PreAuthorize("hasAnyAuthority('project_finance')") public String viewPendingBankDetailsApprovals(Model model, UserResource loggedInUser) { List<BankDetailsReviewResource> pendingBankDetails = bankDetailsRestService.getPendingBankDetailsApprovals().getSuccess(); model.addAttribute("model", new CompetitionPendingBankDetailsApprovalsViewModel(pendingBankDetails)); return "project/competition-pending-bank-details"; } @SecuredBySpring(value = "PENDING_BANK_DETAILS_APPROVALS", description = "Project finance users can view and action pending bank details approvals for all competitions") @GetMapping("/status/pending-bank-details-approvals") @PreAuthorize("hasAnyAuthority('project_finance')") String viewPendingBankDetailsApprovals(Model model, UserResource loggedInUser); } | @Test public void viewPendingBankDetailsApprovals() throws Exception { List<BankDetailsReviewResource> pendingBankDetails = singletonList(new BankDetailsReviewResource(1L, 11L, "Comp1", 12L, "project1", 22L, "Org1")); when(bankDetailsRestService.getPendingBankDetailsApprovals()).thenReturn(restSuccess(pendingBankDetails)); MvcResult result = mockMvc.perform(get("/competitions/status/pending-bank-details-approvals")). andExpect(view().name("project/competition-pending-bank-details")). andExpect(status().isOk()). andReturn(); CompetitionPendingBankDetailsApprovalsViewModel model = (CompetitionPendingBankDetailsApprovalsViewModel) result.getModelAndView().getModel().get("model"); assertEquals(model, new CompetitionPendingBankDetailsApprovalsViewModel(pendingBankDetails)); } |
BankDetailsManagementController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_BANK_DETAILS_SECTION')") @GetMapping("/review-all-bank-details") public String viewPartnerBankDetails( Model model, @P("projectId")@PathVariable("projectId") Long projectId, UserResource loggedInUser) { model.addAttribute("isCompAdminUser", loggedInUser.hasRole(COMP_ADMIN)); final ProjectBankDetailsStatusSummary bankDetailsStatusSummary = bankDetailsRestService.getBankDetailsStatusSummaryByProject(projectId) .getSuccess(); if (onlyOneOrganisationAndTheirBankDetailsAreRequired(bankDetailsStatusSummary)) { return format("redirect:/project/%d/organisation/%d/review-bank-details", projectId, bankDetailsStatusSummary.getBankDetailsStatusResources().get(0).getOrganisationId()); } return doViewBankDetailsSummaryPage(bankDetailsStatusSummary, model); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_BANK_DETAILS_SECTION')") @GetMapping("/review-all-bank-details") String viewPartnerBankDetails(
Model model,
@P("projectId")@PathVariable("projectId") Long projectId,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_BANK_DETAILS_SECTION')") @GetMapping("/organisation/{organisationId}/review-bank-details") String viewBankDetails(
Model model,
@P("projectId")@PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_BANK_DETAILS_SECTION')") @PostMapping("/organisation/{organisationId}/review-bank-details") String approveBankDetails(
Model model,
@ModelAttribute(FORM_ATTR_NAME) ApproveBankDetailsForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@P("projectId")@PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_BANK_DETAILS_SECTION')") @GetMapping("/organisation/{organisationId}/review-bank-details/change") String changeBankDetailsView(
Model model,
@P("projectId")@PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId,
UserResource loggedInUser,
@ModelAttribute(name = FORM_ATTR_NAME, binding = false) ChangeBankDetailsForm form); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_BANK_DETAILS_SECTION')") @PostMapping("/organisation/{organisationId}/review-bank-details/change") String changeBankDetails(
Model model,
@P("projectId") @PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId,
UserResource loggedInUser,
@Valid @ModelAttribute(FORM_ATTR_NAME) ChangeBankDetailsForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler); } | @Test public void testViewPartnerBankDetails() throws Exception { Long projectId = 123L; final ProjectBankDetailsStatusSummary bankDetailsStatusSummary = newProjectBankDetailsStatusSummary().withBankDetailsStatusResources(newBankDetailsStatusResource().withBankDetailsStatus(ProjectActivityStates.NOT_REQUIRED).build(1)).build(); when(bankDetailsRestService.getBankDetailsStatusSummaryByProject(projectId)).thenReturn(restSuccess(bankDetailsStatusSummary)); MvcResult result = mockMvc.perform(get("/project/" + projectId + "/review-all-bank-details")).andExpect(status().isOk()).andExpect(view().name("project/bank-details-status")).andReturn(); assertEquals(bankDetailsStatusSummary, result.getModelAndView().getModel().get("model")); } |
FinanceChecksEligibilityController extends AsyncAdaptor { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping("remove-row/{rowId}") public @ResponseBody String ajaxRemoveRow(@PathVariable long projectId, @PathVariable long organisationId, @PathVariable String rowId) throws JsonProcessingException { yourProjectCostsSaver.removeFinanceRow(rowId); AjaxResult ajaxResult = new AjaxResult(HttpStatus.OK, "true"); ObjectMapper mapper = new ObjectMapper(); return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(ajaxResult); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @GetMapping @AsyncMethod String viewEligibility(@PathVariable long projectId,
@PathVariable long organisationId,
@RequestParam(value = "financeType", required = false) FinanceRowType rowType,
@RequestParam(value = "editAcademicFinances", required = false) boolean editAcademicFinances,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-academic-costs") @AsyncMethod String saveAcademicCosts(@PathVariable long projectId,
@PathVariable long organisationId,
@Valid @ModelAttribute("academicCostForm") AcademicCostForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-eligibility") @AsyncMethod String projectFinanceFormSubmit(@PathVariable long projectId,
@PathVariable long organisationId,
@RequestParam("save-eligibility") FinanceRowType type,
@ModelAttribute("form") YourProjectCostsForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping("remove-row/{rowId}") @ResponseBody String ajaxRemoveRow(@PathVariable long projectId,
@PathVariable long organisationId,
@PathVariable String rowId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping("add-row/{rowType}") String ajaxAddRow(Model model,
@PathVariable long projectId,
@PathVariable FinanceRowType rowType); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "confirm-eligibility") @AsyncMethod String confirmEligibility(@PathVariable long projectId,
@PathVariable long organisationId,
@ModelAttribute(FORM_ATTR_NAME) YourProjectCostsForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
@ModelAttribute("eligibilityForm") FinanceChecksEligibilityForm eligibilityForm,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-and-continue") @AsyncMethod String saveAndContinue(@PathVariable long projectId,
@PathVariable long organisationId,
@ModelAttribute(FORM_ATTR_NAME) YourProjectCostsForm form,
@ModelAttribute("eligibilityForm") FinanceChecksEligibilityForm eligibilityForm,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @GetMapping("/changes") String viewExternalEligibilityChanges(@PathVariable long projectId, @PathVariable final Long organisationId, Model model, UserResource loggedInUser); } | @Test public void ajaxRemoveRow() throws Exception { Long projectId = 1L; Long organisationId = 2L; Long costId = 3L; mockMvc.perform(post("/project/{projectId}/finance-check/organisation/{organisationId}/eligibility/remove-row/{rowId}", projectId, organisationId, costId)) .andExpect(status().isOk()); verify(yourProjectCostsSaver).removeFinanceRow(String.valueOf(costId)); } |
FinanceChecksEligibilityController extends AsyncAdaptor { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping("add-row/{rowType}") public String ajaxAddRow(Model model, @PathVariable long projectId, @PathVariable FinanceRowType rowType) throws InstantiationException, IllegalAccessException { YourProjectCostsForm form = new YourProjectCostsForm(); Map.Entry<String, AbstractCostRowForm> entry = yourProjectCostsSaver.addRowForm(form, rowType); model.addAttribute("form", form); model.addAttribute("id", entry.getKey()); model.addAttribute("row", entry.getValue()); return String.format("application/your-project-costs-fragments :: ajax_%s_row", rowType.name().toLowerCase()); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @GetMapping @AsyncMethod String viewEligibility(@PathVariable long projectId,
@PathVariable long organisationId,
@RequestParam(value = "financeType", required = false) FinanceRowType rowType,
@RequestParam(value = "editAcademicFinances", required = false) boolean editAcademicFinances,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-academic-costs") @AsyncMethod String saveAcademicCosts(@PathVariable long projectId,
@PathVariable long organisationId,
@Valid @ModelAttribute("academicCostForm") AcademicCostForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-eligibility") @AsyncMethod String projectFinanceFormSubmit(@PathVariable long projectId,
@PathVariable long organisationId,
@RequestParam("save-eligibility") FinanceRowType type,
@ModelAttribute("form") YourProjectCostsForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping("remove-row/{rowId}") @ResponseBody String ajaxRemoveRow(@PathVariable long projectId,
@PathVariable long organisationId,
@PathVariable String rowId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping("add-row/{rowType}") String ajaxAddRow(Model model,
@PathVariable long projectId,
@PathVariable FinanceRowType rowType); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "confirm-eligibility") @AsyncMethod String confirmEligibility(@PathVariable long projectId,
@PathVariable long organisationId,
@ModelAttribute(FORM_ATTR_NAME) YourProjectCostsForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
@ModelAttribute("eligibilityForm") FinanceChecksEligibilityForm eligibilityForm,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-and-continue") @AsyncMethod String saveAndContinue(@PathVariable long projectId,
@PathVariable long organisationId,
@ModelAttribute(FORM_ATTR_NAME) YourProjectCostsForm form,
@ModelAttribute("eligibilityForm") FinanceChecksEligibilityForm eligibilityForm,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @GetMapping("/changes") String viewExternalEligibilityChanges(@PathVariable long projectId, @PathVariable final Long organisationId, Model model, UserResource loggedInUser); } | @Test public void ajaxAddRow() throws Exception { Long projectId = 1L; Long organisationId = 2L; String rowId = "123"; LabourRowForm row = new LabourRowForm(); row.setCostId(Long.valueOf(rowId)); FinanceRowType type = FinanceRowType.LABOUR; doAnswer((invocation) -> { YourProjectCostsForm form = (YourProjectCostsForm) invocation.getArguments()[0]; form.getLabour().getRows().put(rowId, row); return form.getLabour().getRows().entrySet().iterator().next(); }).when(yourProjectCostsSaver).addRowForm(any(YourProjectCostsForm.class), eq(type)); mockMvc.perform(post("/project/{projectId}/finance-check/organisation/{organisationId}/eligibility/add-row/{type}", projectId, organisationId, type)) .andExpect(view().name("application/your-project-costs-fragments :: ajax_labour_row")) .andExpect(model().attribute("row", row)) .andExpect(model().attribute("id", rowId)) .andExpect(status().isOk()); verify(yourProjectCostsSaver).addRowForm(any(YourProjectCostsForm.class), eq(type)); } |
FinanceChecksEligibilityController extends AsyncAdaptor { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-eligibility") @AsyncMethod public String projectFinanceFormSubmit(@PathVariable long projectId, @PathVariable long organisationId, @RequestParam("save-eligibility") FinanceRowType type, @ModelAttribute("form") YourProjectCostsForm form, BindingResult bindingResult, ValidationHandler validationHandler, Model model, UserResource user) { Supplier<String> successView = () -> getRedirectUrlToEligibility(projectId, organisationId); Supplier<String> failureView = () -> doViewEligibility(projectId, organisationId, model, null, form, null, null, false); yourProjectCostsFormValidator.validateType(form, type, validationHandler); return validationHandler.failNowOrSucceedWith(failureView, () -> { validationHandler.addAnyErrors(yourProjectCostsSaver.saveType(form, type, projectId, organisationId)); return validationHandler.failNowOrSucceedWith(failureView, successView); }); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @GetMapping @AsyncMethod String viewEligibility(@PathVariable long projectId,
@PathVariable long organisationId,
@RequestParam(value = "financeType", required = false) FinanceRowType rowType,
@RequestParam(value = "editAcademicFinances", required = false) boolean editAcademicFinances,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-academic-costs") @AsyncMethod String saveAcademicCosts(@PathVariable long projectId,
@PathVariable long organisationId,
@Valid @ModelAttribute("academicCostForm") AcademicCostForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-eligibility") @AsyncMethod String projectFinanceFormSubmit(@PathVariable long projectId,
@PathVariable long organisationId,
@RequestParam("save-eligibility") FinanceRowType type,
@ModelAttribute("form") YourProjectCostsForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping("remove-row/{rowId}") @ResponseBody String ajaxRemoveRow(@PathVariable long projectId,
@PathVariable long organisationId,
@PathVariable String rowId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping("add-row/{rowType}") String ajaxAddRow(Model model,
@PathVariable long projectId,
@PathVariable FinanceRowType rowType); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "confirm-eligibility") @AsyncMethod String confirmEligibility(@PathVariable long projectId,
@PathVariable long organisationId,
@ModelAttribute(FORM_ATTR_NAME) YourProjectCostsForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
@ModelAttribute("eligibilityForm") FinanceChecksEligibilityForm eligibilityForm,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @PostMapping(params = "save-and-continue") @AsyncMethod String saveAndContinue(@PathVariable long projectId,
@PathVariable long organisationId,
@ModelAttribute(FORM_ATTR_NAME) YourProjectCostsForm form,
@ModelAttribute("eligibilityForm") FinanceChecksEligibilityForm eligibilityForm,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_FINANCE_CHECKS_SECTION')") @GetMapping("/changes") String viewExternalEligibilityChanges(@PathVariable long projectId, @PathVariable final Long organisationId, Model model, UserResource loggedInUser); } | @Test public void testProjectFinanceFormSubmit() throws Exception { Long projectId = 1L; Long organisationId = 2L; FinanceRowType rowType = FinanceRowType.LABOUR; when(yourProjectCostsSaver.saveType(isA(YourProjectCostsForm.class), eq(rowType), eq(projectId), eq(organisationId))).thenReturn(serviceSuccess()); mockMvc.perform(post("/project/{projectId}/finance-check/organisation/{organisationId}/eligibility", projectId, organisationId). param("save-eligibility", rowType.name())). andExpect(status().is3xxRedirection()). andExpect(view().name("redirect:/project/" + projectId + "/finance-check/organisation/" + 2 +"/eligibility")); } |
GrantOfferLetterController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/send") public String sendGrantOfferLetter(@P("projectId") @PathVariable Long projectId, Model model, @ModelAttribute(FORM_ATTR) @Valid GrantOfferLetterLetterForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler) { Supplier<String> failureView = () -> doViewGrantOfferLetterSend(projectId, model, form); return validationHandler.failNowOrSucceedWith(failureView, () -> { ServiceResult<Void> generateResult = grantOfferLetterService.sendGrantOfferLetter(projectId); return validationHandler.addAnyErrors(generateResult).failNowOrSucceedWith(failureView, () -> redirectToGrantOfferLetterPage(projectId)); }); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/send") String viewGrantOfferLetterSend(@P("projectId") @PathVariable Long projectId, Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/send") String sendGrantOfferLetter(@P("projectId") @PathVariable Long projectId,
Model model,
@ModelAttribute(FORM_ATTR) @Valid GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "uploadGrantOfferLetterClicked") String uploadGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "removeGrantOfferLetterClicked") String removeGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/upload-annex", params = "removeAdditionalContractFileClicked") String removeAdditionalContractFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/signed") String signedGrantOfferLetterApproval(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(APPROVAL_FORM_ATTR) GrantOfferLetterApprovalForm approvalForm); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/additional-contract") @ResponseBody ResponseEntity<ByteArrayResource> downloadAdditionalContractFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadGeneratedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/signed-grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadSignedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(params = "uploadAnnexClicked", value = "/upload-annex") String uploadAnnexFile(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/template") String viewGrantOfferLetterTemplatePage(@PathVariable("projectId") long projectId,
Model model); } | @Test public void testSendGOLSuccess() throws Exception { Long projectId = 123L; when(grantOfferLetterService.sendGrantOfferLetter(projectId)).thenReturn(serviceSuccess()); mockMvc.perform(post("/project/" + projectId + "/grant-offer-letter/send"). param("confirmation", "true")). andExpect(status().is3xxRedirection()). andExpect(view().name("redirect:/project/" + projectId + "/grant-offer-letter/send")); verify(grantOfferLetterService).sendGrantOfferLetter(projectId); }
@Test public void testSendGOLValidation() throws Exception { Long competitionId = 1L; Long projectId = 123L; Long applicationId = 789L; ApplicationResource applicationResource = newApplicationResource().withId(applicationId).build(); ProjectResource projectResource = newProjectResource() .withId(projectId) .withApplication(applicationResource) .withProjectState(SETUP) .build(); when(projectService.getById(projectId)).thenReturn(projectResource); when(applicationService.getById(applicationId)).thenReturn(newApplicationResource().withId(applicationId).withCompetition(competitionId).build()); CompetitionResource competition = newCompetitionResource().withId(competitionId).build(); when(competitionRestService.getCompetitionById(competitionId)).thenReturn(restSuccess(competition)); when(projectService.getById(projectId)).thenReturn(projectResource); when(applicationService.getById(applicationId)).thenReturn(newApplicationResource().withId(applicationId).withCompetition(competitionId).build()); when(grantOfferLetterService.getGrantOfferFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.getAdditionalContractFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.getGrantOfferLetterState(projectId)).thenReturn(golState(PENDING)); when(grantOfferLetterService.getSignedGrantOfferLetterFileDetails(projectId)).thenReturn(Optional.empty()); mockMvc.perform(post("/project/" + projectId + "/grant-offer-letter/send")). andExpect(view().name("project/grant-offer-letter-send")). andExpect(model().errorCount(1)). andExpect(model().attributeHasFieldErrorCode("form", "confirmation", "NotNull")). andReturn(); verify(grantOfferLetterService, never()).sendGrantOfferLetter(projectId); }
@Test public void testSendGOLFailure() throws Exception { Long competitionId = 1L; Long projectId = 123L; Long applicationId = 789L; ApplicationResource applicationResource = newApplicationResource().withId(applicationId).build(); ProjectResource projectResource = newProjectResource() .withId(projectId) .withApplication(applicationResource) .withProjectState(SETUP) .build(); when(projectService.getById(projectId)).thenReturn(projectResource); when(applicationService.getById(applicationId)).thenReturn(newApplicationResource().withId(applicationId).withCompetition(competitionId).build()); CompetitionResource competition = newCompetitionResource().withId(competitionId).build(); when(competitionRestService.getCompetitionById(competitionId)).thenReturn(restSuccess(competition)); when(grantOfferLetterService.getGrantOfferFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.getAdditionalContractFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.getGrantOfferLetterState(projectId)).thenReturn(golState(PENDING)); when(grantOfferLetterService.getSignedGrantOfferLetterFileDetails(projectId)).thenReturn(Optional.empty()); List<Error> errors = asList(notFoundError(String.class), notFoundError(Long.class)); when(grantOfferLetterService.sendGrantOfferLetter(projectId)).thenReturn(serviceFailure(errors)); when(projectService.getById(projectId)).thenReturn(projectResource); when(applicationService.getById(applicationId)).thenReturn(newApplicationResource().withId(applicationId).withCompetition(competitionId).build()); when(grantOfferLetterService.getGrantOfferFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.getAdditionalContractFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.getGrantOfferLetterState(projectId)).thenReturn(golState(PENDING)); when(grantOfferLetterService.getSignedGrantOfferLetterFileDetails(projectId)).thenReturn(Optional.empty()); mockMvc.perform(post("/project/" + projectId + "/grant-offer-letter/send"). param("confirmation", "true")). andExpect(view().name("project/grant-offer-letter-send")). andExpect(model().errorCount(errors.size())). andReturn(); verify(grantOfferLetterService).sendGrantOfferLetter(projectId); }
@Test public void uploadAnnexFileFails() throws Exception { Long competitionId = 1L; Long projectId = 123L; Long applicationId = 789L; ApplicationResource applicationResource = newApplicationResource().withId(applicationId).build(); ProjectResource projectResource = newProjectResource() .withId(projectId) .withApplication(applicationResource) .withProjectState(SETUP) .build(); when(projectService.getById(projectId)).thenReturn(projectResource); when(applicationService.getById(applicationId)).thenReturn(newApplicationResource().withId(applicationId).withCompetition(competitionId).build()); CompetitionResource competition = newCompetitionResource().withId(competitionId).build(); when(competitionRestService.getCompetitionById(competitionId)).thenReturn(restSuccess(competition)); when(grantOfferLetterService.getGrantOfferFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.getAdditionalContractFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.getGrantOfferLetterState(projectId)).thenReturn(golState(PENDING)); when(grantOfferLetterService.getSignedGrantOfferLetterFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.sendGrantOfferLetter(projectId)).thenReturn(serviceSuccess()); MockMultipartFile uploadedFile = new MockMultipartFile("annex", "annex.pdf", "application/pdf", "My content!".getBytes()); when(grantOfferLetterService.addAdditionalContractFile(123L, "application/pdf", 11, "annex.pdf", "My content!".getBytes())). thenReturn(ServiceResult.serviceFailure(new Error(FILES_UNABLE_TO_CREATE_FILE, INTERNAL_SERVER_ERROR))); MvcResult result = mockMvc.perform( fileUpload("/project/"+ projectId + "/grant-offer-letter/upload-annex"). file(uploadedFile).param("uploadAnnexClicked", "")). andExpect(status().isOk()). andExpect(view().name("project/grant-offer-letter-send")). andReturn(); GrantOfferLetterLetterForm form = (GrantOfferLetterLetterForm) result.getModelAndView().getModel().get("form"); assertEquals(uploadedFile, form.getAnnex()); assertEquals(Boolean.FALSE, ((GrantOfferLetterModel)result.getModelAndView().getModel().get("model")).getAdditionalContractFileContentAvailable()); } |
GoogleAnalyticsDataLayerController { @GetMapping("/assessment/{assessmentId}/application-id") public RestResult<Long> getApplicationIdForAssessment(@PathVariable("assessmentId") long assessmentId) { return googleAnalyticsDataLayerService.getApplicationIdForAssessment(assessmentId).toGetResponse(); } @GetMapping("/application/{applicationId}/competition-name") RestResult<String> getCompetitionNameForApplication(@PathVariable("applicationId") long applicationId); @GetMapping("/invite/{inviteHash}/competition-name") RestResult<String> getCompetitionNameForInvite(@PathVariable("inviteHash") String inviteHash); @GetMapping("/application/{applicationId}/user-roles") RestResult<List<Role>> getRolesByApplicationIdForCurrentUser(@PathVariable("applicationId") long applicationId); @GetMapping("/competition/{competitionId}/competition-name") RestResult<String> getCompetitionName(@PathVariable("competitionId") long competitionId); @GetMapping("/project/{projectId}/competition-name") RestResult<String> getCompetitionNameForProject(@PathVariable("projectId") long projectId); @GetMapping("/project/{projectId}/user-roles") RestResult<List<Role>> getRolesByProjectIdForCurrentUser(@PathVariable("projectId") long projectId); @GetMapping("/assessment/{assessmentId}/competition-name") RestResult<String> getCompetitionNameForAssessment(@PathVariable("assessmentId") long assessmentId); @GetMapping("/project/{projectId}/application-id") RestResult<Long> getApplicationIdForProject(@PathVariable("projectId") long projectId); @GetMapping("/assessment/{assessmentId}/application-id") RestResult<Long> getApplicationIdForAssessment(@PathVariable("assessmentId") long assessmentId); } | @Test public void getApplicationIdForAssessment() throws Exception { final long assessmentId=30L; final long applicationId = 875L; when(googleAnalyticsDataLayerServiceMock.getApplicationIdForAssessment(assessmentId)) .thenReturn(serviceSuccess(applicationId)); mockMvc.perform(get("/analytics/assessment/{assessmentId}/application-id", assessmentId)) .andExpect(status().isOk()) .andExpect(content().string(toJson(applicationId))); verify(googleAnalyticsDataLayerServiceMock, only()).getApplicationIdForAssessment(assessmentId); } |
GrantOfferLetterController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "uploadGrantOfferLetterClicked") public String uploadGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId, @ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, Model model) { return performActionOrBindErrorsToField(projectId, validationHandler, model, "grantOfferLetter", form, () -> { MultipartFile file = form.getGrantOfferLetter(); return grantOfferLetterService.addGrantOfferLetter(projectId, file.getContentType(), file.getSize(), file.getOriginalFilename(), getMultipartFileBytes(file)); }); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/send") String viewGrantOfferLetterSend(@P("projectId") @PathVariable Long projectId, Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/send") String sendGrantOfferLetter(@P("projectId") @PathVariable Long projectId,
Model model,
@ModelAttribute(FORM_ATTR) @Valid GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "uploadGrantOfferLetterClicked") String uploadGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "removeGrantOfferLetterClicked") String removeGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/upload-annex", params = "removeAdditionalContractFileClicked") String removeAdditionalContractFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/signed") String signedGrantOfferLetterApproval(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(APPROVAL_FORM_ATTR) GrantOfferLetterApprovalForm approvalForm); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/additional-contract") @ResponseBody ResponseEntity<ByteArrayResource> downloadAdditionalContractFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadGeneratedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/signed-grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadSignedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(params = "uploadAnnexClicked", value = "/upload-annex") String uploadAnnexFile(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/template") String viewGrantOfferLetterTemplatePage(@PathVariable("projectId") long projectId,
Model model); } | @Test public void uploadGrantOfferLetterFile() throws Exception { Long projectId = 123L; FileEntryResource createdFileDetails = newFileEntryResource().withName("1").withMediaType("application/pdf").withFilesizeBytes(11).build(); when(grantOfferLetterService.addGrantOfferLetter(123L, "application/pdf", 11, "grantOfferLetter.pdf", "My content!".getBytes())). thenReturn(serviceSuccess(createdFileDetails)); MockMultipartFile uploadedFile = new MockMultipartFile("grantOfferLetter", "grantOfferLetter.pdf", "application/pdf", "My content!".getBytes()); mockMvc.perform( fileUpload("/project/"+ projectId + "/grant-offer-letter/grant-offer-letter"). file(uploadedFile).param("uploadGrantOfferLetterClicked", "")). andExpect(status().is3xxRedirection()). andExpect(view().name("redirect:/project/" + projectId + "/grant-offer-letter/send")); verify(grantOfferLetterService).addGrantOfferLetter(123L, "application/pdf", 11, "grantOfferLetter.pdf", "My content!".getBytes()); } |
GrantOfferLetterController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "removeGrantOfferLetterClicked") public String removeGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId) { grantOfferLetterService.removeGrantOfferLetter(projectId); return redirectToGrantOfferLetterPage(projectId); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/send") String viewGrantOfferLetterSend(@P("projectId") @PathVariable Long projectId, Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/send") String sendGrantOfferLetter(@P("projectId") @PathVariable Long projectId,
Model model,
@ModelAttribute(FORM_ATTR) @Valid GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "uploadGrantOfferLetterClicked") String uploadGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "removeGrantOfferLetterClicked") String removeGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/upload-annex", params = "removeAdditionalContractFileClicked") String removeAdditionalContractFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/signed") String signedGrantOfferLetterApproval(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(APPROVAL_FORM_ATTR) GrantOfferLetterApprovalForm approvalForm); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/additional-contract") @ResponseBody ResponseEntity<ByteArrayResource> downloadAdditionalContractFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadGeneratedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/signed-grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadSignedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(params = "uploadAnnexClicked", value = "/upload-annex") String uploadAnnexFile(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/template") String viewGrantOfferLetterTemplatePage(@PathVariable("projectId") long projectId,
Model model); } | @Test public void removeGrantOfferLetterFile() throws Exception { Long projectId = 123L; when(grantOfferLetterService.removeGrantOfferLetter(projectId)).thenReturn(serviceSuccess()); MockMultipartFile fileToDelete = new MockMultipartFile("grantOfferLetter", "grantOfferLetter.pdf", "application/pdf", "My content!".getBytes()); mockMvc.perform( fileUpload("/project/"+ projectId + "/grant-offer-letter/grant-offer-letter"). file(fileToDelete).param("removeGrantOfferLetterClicked", "")). andExpect(status().is3xxRedirection()). andExpect(view().name("redirect:/project/" + projectId + "/grant-offer-letter/send")); verify(grantOfferLetterService).removeGrantOfferLetter(projectId); } |
GrantOfferLetterController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/upload-annex", params = "removeAdditionalContractFileClicked") public String removeAdditionalContractFile(@P("projectId") @PathVariable("projectId") final Long projectId) { grantOfferLetterService.removeAdditionalContractFile(projectId); return redirectToGrantOfferLetterPage(projectId); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/send") String viewGrantOfferLetterSend(@P("projectId") @PathVariable Long projectId, Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/send") String sendGrantOfferLetter(@P("projectId") @PathVariable Long projectId,
Model model,
@ModelAttribute(FORM_ATTR) @Valid GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "uploadGrantOfferLetterClicked") String uploadGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "removeGrantOfferLetterClicked") String removeGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/upload-annex", params = "removeAdditionalContractFileClicked") String removeAdditionalContractFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/signed") String signedGrantOfferLetterApproval(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(APPROVAL_FORM_ATTR) GrantOfferLetterApprovalForm approvalForm); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/additional-contract") @ResponseBody ResponseEntity<ByteArrayResource> downloadAdditionalContractFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadGeneratedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/signed-grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadSignedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(params = "uploadAnnexClicked", value = "/upload-annex") String uploadAnnexFile(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/template") String viewGrantOfferLetterTemplatePage(@PathVariable("projectId") long projectId,
Model model); } | @Test public void removeAdditionalContractLetterFile() throws Exception { Long projectId = 123L; when(grantOfferLetterService.removeAdditionalContractFile(projectId)).thenReturn(serviceSuccess()); MockMultipartFile fileToDelete = new MockMultipartFile("annex", "annex.pdf", "application/pdf", "Annex content".getBytes()); mockMvc.perform( fileUpload("/project/"+ projectId + "/grant-offer-letter/upload-annex"). file(fileToDelete).param("removeAdditionalContractFileClicked", "")). andExpect(status().is3xxRedirection()). andExpect(view().name("redirect:/project/" + projectId + "/grant-offer-letter/send")); verify(grantOfferLetterService).removeAdditionalContractFile(projectId); } |
GrantOfferLetterController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(params = "uploadAnnexClicked", value = "/upload-annex") public String uploadAnnexFile( @P("projectId") @PathVariable("projectId") final Long projectId, @ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, Model model, UserResource loggedInUser) { return performActionOrBindErrorsToField(projectId, validationHandler, model, "annex", form, () -> { MultipartFile file = form.getAnnex(); return grantOfferLetterService.addAdditionalContractFile(projectId, file.getContentType(), file.getSize(), file.getOriginalFilename(), getMultipartFileBytes(file)); }); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/send") String viewGrantOfferLetterSend(@P("projectId") @PathVariable Long projectId, Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/send") String sendGrantOfferLetter(@P("projectId") @PathVariable Long projectId,
Model model,
@ModelAttribute(FORM_ATTR) @Valid GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "uploadGrantOfferLetterClicked") String uploadGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/grant-offer-letter", params = "removeGrantOfferLetterClicked") String removeGrantOfferLetterFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(value = "/upload-annex", params = "removeAdditionalContractFileClicked") String removeAdditionalContractFile(@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping("/signed") String signedGrantOfferLetterApproval(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(APPROVAL_FORM_ATTR) GrantOfferLetterApprovalForm approvalForm); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/additional-contract") @ResponseBody ResponseEntity<ByteArrayResource> downloadAdditionalContractFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadGeneratedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/signed-grant-offer-letter") @ResponseBody ResponseEntity<ByteArrayResource> downloadSignedGrantOfferLetterFile(
@P("projectId") @PathVariable("projectId") final Long projectId); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @PostMapping(params = "uploadAnnexClicked", value = "/upload-annex") String uploadAnnexFile(
@P("projectId") @PathVariable("projectId") final Long projectId,
@ModelAttribute(FORM_ATTR) GrantOfferLetterLetterForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource loggedInUser); @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')") @GetMapping("/template") String viewGrantOfferLetterTemplatePage(@PathVariable("projectId") long projectId,
Model model); } | @Test public void uploadAnnexFile() throws Exception { Long competitionId = 1L; Long projectId = 123L; Long applicationId = 789L; ApplicationResource applicationResource = newApplicationResource().withId(applicationId).build(); ProjectResource projectResource = newProjectResource().withId(projectId).withApplication(applicationResource).build(); Optional<FileEntryResource> annexFileEntryResource = Optional.of(FileEntryResourceBuilder.newFileEntryResource().withName("1").withMediaType("application/pdf").withFilesizeBytes(20).build()); when(projectService.getById(projectId)).thenReturn(projectResource); when(applicationService.getById(applicationId)).thenReturn(newApplicationResource().withId(applicationId).withCompetition(competitionId).build()); CompetitionResource competition = newCompetitionResource().withId(competitionId).build(); when(competitionRestService.getCompetitionById(competitionId)).thenReturn(restSuccess(competition)); when(grantOfferLetterService.getGrantOfferFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.getAdditionalContractFileDetails(projectId)).thenReturn(annexFileEntryResource); when(grantOfferLetterService.getGrantOfferLetterState(projectId)).thenReturn(golState(PENDING)); when(grantOfferLetterService.getSignedGrantOfferLetterFileDetails(projectId)).thenReturn(Optional.empty()); when(grantOfferLetterService.sendGrantOfferLetter(projectId)).thenReturn(serviceSuccess()); MockMultipartFile uploadedFile = new MockMultipartFile("annex", "annex.pdf", "application/pdf", "My content!".getBytes()); FileEntryResource createdFileDetails = newFileEntryResource().withName("1").withMediaType("application/pdf").withFilesizeBytes(20).build(); when(grantOfferLetterService.addAdditionalContractFile(123L, "application/pdf", 11, "annex.pdf", "My content!".getBytes())). thenReturn(serviceSuccess(createdFileDetails)); MvcResult result = mockMvc.perform( fileUpload("/project/"+ projectId + "/grant-offer-letter/upload-annex"). file(uploadedFile).param("uploadAnnexClicked", "")). andExpect(status().is3xxRedirection()). andExpect(view().name("redirect:/project/" + projectId + "/grant-offer-letter/send")). andReturn(); GrantOfferLetterLetterForm form = (GrantOfferLetterLetterForm) result.getModelAndView().getModel().get("form"); assertEquals(uploadedFile, form.getAnnex()); } |
GrantOfferLetterTemplatePopulator { public GrantOfferLetterTemplateViewModel populate(long projectId) { ProjectResource projectResource = projectRestService.getProjectById(projectId).getSuccess(); String projectName = projectResource.getName(); long applicationId = projectResource.getApplication(); CompetitionResource competitionResource = competitionRestService.getCompetitionById(projectResource.getCompetition()).getSuccess(); ProjectUserResource projectUserResource = projectService.getProjectManager(projectId).get(); OrganisationResource leadOrg = organisationRestService.getOrganisationById(projectUserResource.getOrganisation()).getSuccess(); String leadOrgName = leadOrg.getName(); UserResource user = userRestService.retrieveUserById(projectUserResource.getUser()).getSuccess(); String projectManagerFirstName = user.getFirstName(); String projectManagerLastName = user.getLastName(); List<ProjectFinanceResource> allProjectFinances = projectFinanceRestService.getProjectFinances(projectResource.getId()).getSuccess(); List<NoteResource> allProjectNotes = new ArrayList<>(); allProjectFinances.forEach(projectFinance -> projectFinanceNotesRestService.findAll(projectFinance.getId()) .ifSuccessful(allProjectNotes::addAll) ); Map<OrganisationResource, ProjectFinanceResource> financesForOrgs = getFinancesForOrgs(projectResource, allProjectFinances); IndustrialFinanceTableModel industrialFinanceTableModel = industrialFinanceTableModelPopulator.createTable(financesForOrgs, competitionResource); AcademicFinanceTableModel academicFinanceTableModel = academicFinanceTableModelPopulator.createTable(financesForOrgs, competitionResource); SummaryFinanceTableModel summaryFinanceTableModel = summaryFinanceTableModelPopulator.createTable(financesForOrgs, competitionResource); return new GrantOfferLetterTemplateViewModel(applicationId, projectManagerFirstName, projectManagerLastName, getAddressLines(projectResource), projectResource.getCompetitionName(), projectName, leadOrgName, allProjectNotes, competitionResource.getTermsAndConditions().getTemplate(), industrialFinanceTableModel, academicFinanceTableModel, summaryFinanceTableModel, competitionResource.isProcurement()); } @Autowired GrantOfferLetterTemplatePopulator(
ProjectRestService projectRestService,
CompetitionRestService competitionRestService,
ProjectService projectService,
OrganisationRestService organisationRestService,
UserRestService userRestService,
ProjectFinanceRestService projectFinanceRestService,
ProjectFinanceNotesRestService projectFinanceNotesRestService,
IndustrialFinanceTableModelPopulator industrialFinanceTableModelPopulator,
AcademicFinanceTableModelPopulator academicFinanceTableModelPopulator,
SummaryFinanceTableModelPopulator summaryFinanceTableModelPopulator
); GrantOfferLetterTemplateViewModel populate(long projectId); } | @Test public void populate() { long applicationId = 123L; GrantTermsAndConditionsResource tsAndCs = newGrantTermsAndConditionsResource() .withTemplate("Terms and conditions template") .build(); CompetitionResource competition = newCompetitionResource() .withName("Competition name") .withTermsAndConditions(tsAndCs) .build(); AddressResource address = newAddressResource() .withAddressLine1("Address line 1") .withAddressLine2("Address line 2") .build(); ProjectResource project = newProjectResource() .withCompetition(competition.getId()) .withName("Project name") .withApplication(applicationId) .withAddress(address) .build(); OrganisationResource leadOrg = newOrganisationResource(). withName("Organisation name") .build(); UserResource projectManager = newUserResource() .withFirstName("Mr") .withLastName("Manager") .build(); ProjectUserResource projectManagerProjectUser = newProjectUserResource() .withOrganisation(leadOrg.getId()) .withUser(projectManager.getId()) .build(); List<ProjectFinanceResource> projectFinances = newProjectFinanceResource() .withProject(project.getId()) .build(1); List<NoteResource> notes = newNoteResource().build(2); Map<String, ProjectFinanceResource> finances = asMap(leadOrg.getName(), projectFinances); IndustrialFinanceTableModel industrialFinanceTable = new IndustrialFinanceTableModel(true, finances, singletonList(leadOrg.getName()), BigDecimal.TEN, BigDecimal.ONE); AcademicFinanceTableModel academicFinanceTable = new AcademicFinanceTableModel(true, finances, singletonList(leadOrg.getName()), BigDecimal.TEN, BigDecimal.ONE); SummaryFinanceTableModel summaryFinanceTable = new SummaryFinanceTableModel(BigDecimal.ONE, BigDecimal.TEN, BigDecimal.ONE, BigDecimal.ZERO); when(projectRestService.getProjectById(project.getId())).thenReturn(restSuccess(project)); when(competitionRestService.getCompetitionById(competition.getId())).thenReturn(restSuccess(competition)); when(organisationRestService.getOrganisationById(leadOrg.getId())).thenReturn(restSuccess(leadOrg)); when(projectService.getProjectManager(project.getId())).thenReturn(Optional.of(projectManagerProjectUser)); when(userRestService.retrieveUserById(projectManager.getId())).thenReturn(restSuccess(projectManager)); when(projectFinanceRestService.getProjectFinances(project.getId())).thenReturn(restSuccess(projectFinances)); when(projectFinanceNotesRestService.findAll(projectFinances.get(0).getId())).thenReturn(restSuccess(notes)); when(industrialFinanceTableModelPopulator.createTable(any(), any())).thenReturn(industrialFinanceTable); when(academicFinanceTableModelPopulator.createTable(any(), any())).thenReturn(academicFinanceTable); when(summaryFinanceTableModelPopulator.createTable(any(), any())).thenReturn(summaryFinanceTable); GrantOfferLetterTemplateViewModel model = populator.populate(project.getId()); assertEquals(applicationId, model.getApplicationId()); assertEquals(projectManager.getFirstName(), model.getProjectManagerFirstName()); assertEquals(projectManager.getLastName(), model.getProjectManagerLastName()); assertEquals(project.getName(), model.getProjectName()); assertEquals(project.getCompetitionName(), model.getCompetitionName()); assertEquals(address.getAddressLine1(), model.getProjectAddress().get(0)); assertEquals(address.getAddressLine2(), model.getProjectAddress().get(1)); assertEquals(leadOrg.getName(), model.getLeadOrgName()); assertEquals(notes, model.getNotes()); assertEquals(project.getName(), model.getProjectName()); assertEquals(tsAndCs.getTemplate(), model.getTermsAndConditionsTemplate()); assertEquals(industrialFinanceTable, model.getIndustrialFinanceTable()); assertEquals(academicFinanceTable, model.getAcademicFinanceTable()); assertEquals(summaryFinanceTable, model.getSummaryFinanceTable()); } |
ManageInvitationsController { @SecuredBySpring(value = "MANAGE_INVITATIONS", description = "Only project finance users can manage invitations") @PreAuthorize("hasAnyAuthority('project_finance')") @PostMapping(params = "resend-invite") public String resendInvitation(Model model, @RequestParam("resend-invite") long inviteId, @PathVariable long projectId, @ModelAttribute("form") InvitationForm form, BindingResult bindingResult, ValidationHandler validationHandler, HttpServletResponse response) { Supplier<String> failureView = () -> viewInvitations(model, projectId, form); Supplier<String> successView = () -> { cookieFlashMessageFilter.setFlashMessage(response, "emailSent"); return String.format("redirect:/project/%d/grants/invite", projectId); }; validationHandler.addAnyErrors(grantsInviteRestService.resendInvite(projectId, inviteId)); return validationHandler.failNowOrSucceedWith(failureView, successView); } @SecuredBySpring(value = "MANAGE_INVITATIONS", description = "Only project finance users can manage invitations") @PreAuthorize("hasAnyAuthority('project_finance')") @GetMapping String viewInvitations(
Model model,
@PathVariable("projectId") long projectId, @ModelAttribute("form") InvitationForm form); @SecuredBySpring(value = "MANAGE_INVITATIONS", description = "Only project finance users can manage invitations") @PreAuthorize("hasAnyAuthority('project_finance')") @PostMapping(params = "resend-invite") String resendInvitation(Model model, @RequestParam("resend-invite") long inviteId, @PathVariable long projectId, @ModelAttribute("form") InvitationForm form,
BindingResult bindingResult, ValidationHandler validationHandler, HttpServletResponse response); @SecuredBySpring(value = "MANAGE_INVITATIONS", description = "Only project finance users can manage invitations") @PreAuthorize("hasAnyAuthority('project_finance')") @PostMapping(params = "delete-invite") String deleteInvitation(Model model, @RequestParam("delete-invite") long inviteId, @PathVariable long projectId, @ModelAttribute("form") InvitationForm form,
BindingResult bindingResult, ValidationHandler validationHandler, HttpServletResponse response); } | @Test public void resendInvitation() throws Exception { long projectId = 123L; long inviteId = 567L; when(grantsInviteRestService.resendInvite(projectId, inviteId)).thenReturn(restSuccess()); mockMvc.perform(post("/project/{projectId}/grants/invite", projectId) .param("projectId", Long.toString(projectId)) .param("resend-invite", Long.toString(inviteId))) .andExpect(redirectedUrl("/project/123/grants/invite")); verify(grantsInviteRestService).resendInvite(projectId, inviteId); verify(cookieFlashMessageFilter).setFlashMessage(any(), eq("emailSent")); } |
ManageInvitationsController { @SecuredBySpring(value = "MANAGE_INVITATIONS", description = "Only project finance users can manage invitations") @PreAuthorize("hasAnyAuthority('project_finance')") @PostMapping(params = "delete-invite") public String deleteInvitation(Model model, @RequestParam("delete-invite") long inviteId, @PathVariable long projectId, @ModelAttribute("form") InvitationForm form, BindingResult bindingResult, ValidationHandler validationHandler, HttpServletResponse response) { Supplier<String> failureView = () -> viewInvitations(model, projectId, form); Supplier<String> successView = () -> { cookieFlashMessageFilter.setFlashMessage(response, "deleteInvite"); return String.format("redirect:/project/%d/grants/invite", projectId); }; validationHandler.addAnyErrors(grantsInviteRestService.deleteInvite(projectId, inviteId)); return validationHandler.failNowOrSucceedWith(failureView, successView); } @SecuredBySpring(value = "MANAGE_INVITATIONS", description = "Only project finance users can manage invitations") @PreAuthorize("hasAnyAuthority('project_finance')") @GetMapping String viewInvitations(
Model model,
@PathVariable("projectId") long projectId, @ModelAttribute("form") InvitationForm form); @SecuredBySpring(value = "MANAGE_INVITATIONS", description = "Only project finance users can manage invitations") @PreAuthorize("hasAnyAuthority('project_finance')") @PostMapping(params = "resend-invite") String resendInvitation(Model model, @RequestParam("resend-invite") long inviteId, @PathVariable long projectId, @ModelAttribute("form") InvitationForm form,
BindingResult bindingResult, ValidationHandler validationHandler, HttpServletResponse response); @SecuredBySpring(value = "MANAGE_INVITATIONS", description = "Only project finance users can manage invitations") @PreAuthorize("hasAnyAuthority('project_finance')") @PostMapping(params = "delete-invite") String deleteInvitation(Model model, @RequestParam("delete-invite") long inviteId, @PathVariable long projectId, @ModelAttribute("form") InvitationForm form,
BindingResult bindingResult, ValidationHandler validationHandler, HttpServletResponse response); } | @Test public void deleteInvitation() throws Exception { long projectId = 123L; long inviteId = 567L; when(grantsInviteRestService.deleteInvite(projectId, inviteId)).thenReturn(restSuccess()); mockMvc.perform(post("/project/{projectId}/grants/invite", projectId) .param("projectId", Long.toString(projectId)) .param("delete-invite", Long.toString(inviteId))) .andExpect(redirectedUrl("/project/123/grants/invite")); verify(grantsInviteRestService).deleteInvite(projectId, inviteId); verify(cookieFlashMessageFilter).setFlashMessage(any(), eq("deleteInvite")); } |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public List<BindingResult> validateFormInputResponse(Long applicationId, Long formInputId) { List<BindingResult> results = new ArrayList<>(); List<FormInputResponse> responses = formInputResponseRepository.findByApplicationIdAndFormInputId(applicationId, formInputId); if (!responses.isEmpty()) { results.addAll(responses.stream().map(formInputResponse -> applicationValidationUtil.validateResponse(formInputResponse, false)).collect(Collectors.toList())); } else { FormInputResponse emptyResponse = new FormInputResponse(); emptyResponse.setFormInput(formInputRepository.findById(formInputId).orElse(null)); results.add(applicationValidationUtil.validateResponse(emptyResponse, false)); } FormInput formInput = formInputRepository.findById(formInputId).get(); if (formInput.getQuestion().getQuestionSetupType().equals(QuestionSetupType.APPLICATION_DETAILS)) { Application application = applicationRepository.findById(applicationId).orElse(null); results.add(applicationValidationUtil.addValidation(application, new ApplicationDetailsMarkAsCompleteValidator())); } return results; } @Override List<BindingResult> validateFormInputResponse(Long applicationId, Long formInputId); @Override ValidationMessages validateFormInputResponse(Application application, long formInputId, long markedAsCompleteById); @Override List<ValidationMessages> validateCostItem(Long applicationId, FinanceRowType type, Long markedAsCompleteById); @Override FinanceRowHandler getCostHandler(FinanceRowItem costItem); @Override FinanceRowHandler getProjectCostHandler(FinanceRowItem costItem); @Override ValidationMessages validateAcademicUpload(Application application, Long markedAsCompleteById); @Override Boolean isApplicationComplete(Application application); @Override Boolean isFinanceOverviewComplete(Application application); } | @Test public void validateFormInputResponse() { long applicationId = 1L; long formInputId = 2L; List<FormInputResponse> formInputResponses = newFormInputResponse().withValue("response...").build(2); FormInputResponse formInputResponse1 = formInputResponses.get(0); FormInputResponse formInputResponse2 = formInputResponses.get(1); BindingResult bindingResult1 = ValidatorTestUtil.getBindingResult(formInputResponse1); BindingResult bindingResult2 = ValidatorTestUtil.getBindingResult(formInputResponse2); when(formInputResponseRepository.findByApplicationIdAndFormInputId(applicationId, formInputId)).thenReturn(formInputResponses); when(applicationValidationUtil.validateResponse(formInputResponse1, false)).thenReturn(bindingResult1); when(applicationValidationUtil.validateResponse(formInputResponse2, false)).thenReturn(bindingResult2); when(formInputRepository.findById(formInputId)).thenReturn(Optional.of(newFormInput().withQuestion(newQuestion().withQuestionSetupType(QuestionSetupType.ASSESSED_QUESTION).build()).withType(FormInputType.ASSESSOR_SCORE).build())); List<BindingResult> bindingResults = service.validateFormInputResponse(applicationId, formInputId); assertEquals(formInputResponses.size(), bindingResults.size()); assertEquals(Arrays.asList(bindingResult1, bindingResult2), bindingResults); verify(formInputResponseRepository).findByApplicationIdAndFormInputId(applicationId, formInputId); verify(applicationValidationUtil).validateResponse(formInputResponse1, false); verify(applicationValidationUtil).validateResponse(formInputResponse2, false); verify(formInputRepository, times(1)).findById(formInputId); }
@Test public void validateFormInputResponseWhenEmptyResponse() { long applicationId = 1L; long formInputId = 2L; List<FormInputResponse> formInputResponses = emptyList(); FormInputResponse emptyResponse = new FormInputResponse(); BindingResult bindingResultForEmptyResponse = ValidatorTestUtil.getBindingResult(emptyResponse); when(formInputResponseRepository.findByApplicationIdAndFormInputId(applicationId, formInputId)).thenReturn(formInputResponses); when(formInputRepository.findById(formInputId)).thenReturn(Optional.of(newFormInput().withQuestion(newQuestion().withQuestionSetupType(QuestionSetupType.ASSESSED_QUESTION).build()).build())); when(applicationValidationUtil.validateResponse(isA(FormInputResponse.class), eq(false))).thenReturn(bindingResultForEmptyResponse); List<BindingResult> bindingResults = service.validateFormInputResponse(applicationId, formInputId); assertEquals(1, bindingResults.size()); assertEquals(bindingResultForEmptyResponse, bindingResults.get(0)); verify(formInputResponseRepository).findByApplicationIdAndFormInputId(applicationId, formInputId); verify(formInputRepository, times(2)).findById(formInputId); verify(applicationValidationUtil).validateResponse(isA(FormInputResponse.class), eq(false)); }
@Test public void validateFormInputResponseWhenApplicationDetails() { long applicationId = 1L; long formInputId = 2L; List<FormInputResponse> formInputResponses = newFormInputResponse().withValue("response...").build(2); FormInputResponse formInputResponse1 = formInputResponses.get(0); FormInputResponse formInputResponse2 = formInputResponses.get(1); BindingResult bindingResult1 = new DataBinder(formInputResponse1).getBindingResult(); BindingResult bindingResult2 = new DataBinder(formInputResponse2).getBindingResult(); Application application = newApplication().build(); BindingResult applicationBindingResult = new DataBinder(application).getBindingResult(); when(formInputResponseRepository.findByApplicationIdAndFormInputId(applicationId, formInputId)).thenReturn(formInputResponses); when(applicationValidationUtil.validateResponse(formInputResponse1, false)).thenReturn(bindingResult1); when(applicationValidationUtil.validateResponse(formInputResponse2, false)).thenReturn(bindingResult2); when(formInputRepository.findById(formInputId)).thenReturn(Optional.of(newFormInput().withQuestion(newQuestion().withQuestionSetupType(QuestionSetupType.APPLICATION_DETAILS).build()).build())); when(applicationRepository.findById(applicationId)).thenReturn(Optional.of(application)); when(applicationValidationUtil.addValidation(eq(application), isA(Validator.class))).thenReturn(applicationBindingResult); List<BindingResult> bindingResults = service.validateFormInputResponse(applicationId, formInputId); assertEquals(formInputResponses.size() + 1, bindingResults.size()); assertEquals(Arrays.asList(bindingResult1, bindingResult2, applicationBindingResult), bindingResults); verify(formInputResponseRepository).findByApplicationIdAndFormInputId(applicationId, formInputId); verify(applicationValidationUtil).validateResponse(formInputResponse1, false); verify(applicationValidationUtil).validateResponse(formInputResponse2, false); verify(formInputRepository).findById(formInputId); verify(applicationRepository).findById(applicationId); verify(applicationValidationUtil).addValidation(eq(application), isA(Validator.class)); }
@Test public void validateFormInputResponseWhenMarkedAsComplete() { Application application = newApplication().build(); long markedAsCompleteById = 4L; FormInputResponse formInputResponse = newFormInputResponse().build(); BindingResult bindingResult = ValidatorTestUtil.getBindingResult(formInputResponse); FormInput formInput = newFormInput().build(); long formInputId = formInput.getId(); ValidationMessages expectedValidationMessage = ValidationMessages.fromBindingResult(bindingResult); when(formInputResponseRepository.findByApplicationIdAndUpdatedByIdAndFormInputId(application.getId(), markedAsCompleteById, formInputId)).thenReturn(formInputResponse); when(applicationValidationUtil.validateResponse(formInputResponse, false)).thenReturn(bindingResult); when(formInputRepository.findById(formInputId)).thenReturn(Optional.of(formInput)); ValidationMessages actual = service.validateFormInputResponse(application, formInputId, markedAsCompleteById); assertEquals(expectedValidationMessage, actual); verify(formInputResponseRepository, only()).findByApplicationIdAndUpdatedByIdAndFormInputId(application.getId(), markedAsCompleteById, formInputId); verify(applicationValidationUtil).validateResponse(formInputResponse, false); } |
GrantsInviteController { @GetMapping("/send") public String inviteForm(Model model, @PathVariable long projectId, @ModelAttribute("form") GrantsSendInviteForm form) { List<PartnerOrganisationResource> organisations = partnerOrganisationRestService.getProjectPartnerOrganisations(projectId).getSuccess(); model.addAttribute("model", new GrantsInviteSendViewModel(projectRestService.getProjectById(projectId).getSuccess(), organisations)); return "project/grants-invite/invite"; } @GetMapping("/send") String inviteForm(Model model, @PathVariable long projectId, @ModelAttribute("form") GrantsSendInviteForm form); @PostMapping("/send") String sendInvite(Model model, @PathVariable long projectId, @Valid @ModelAttribute("form") GrantsSendInviteForm form,
BindingResult bindingResult, ValidationHandler validationHandler); } | @Test public void inviteForm() throws Exception { ProjectResource project = newProjectResource() .withApplication(2L) .withName("name") .build(); List<PartnerOrganisationResource> partners = newPartnerOrganisationResource() .withOrganisation(5L, 6L) .withOrganisationName("5", "6") .build(2); when(projectRestService.getProjectById(project.getId())).thenReturn(restSuccess(project)); when(partnerOrganisationRestService.getProjectPartnerOrganisations(project.getId())).thenReturn(restSuccess(partners)); MvcResult result = mockMvc.perform(get("/project/" + project.getId()+ "/grants/invite/send")) .andExpect(view().name("project/grants-invite/invite")) .andReturn(); GrantsInviteSendViewModel viewModel = (GrantsInviteSendViewModel) result.getModelAndView().getModel().get("model"); assertEquals(viewModel.getApplicationId(), 2L); assertEquals(viewModel.getProjectName(), "name"); assertEquals(viewModel.getOrganisationNameIdPairs().get(0).getLeft(), partners.get(0).getOrganisation()); assertEquals(viewModel.getOrganisationNameIdPairs().get(0).getRight(), partners.get(0).getOrganisationName()); assertEquals(viewModel.getOrganisationNameIdPairs().get(1).getLeft(), partners.get(1).getOrganisation()); assertEquals(viewModel.getOrganisationNameIdPairs().get(1).getRight(), partners.get(1).getOrganisationName()); } |
ManageInvitationsModelPopulator { public ManageInvitationsViewModel populateManageInvitationsViewModel(long projectId) { ProjectResource project = projectService.getById(projectId); List<SentGrantsInviteResource> grants = grantsInviteRestService.getAllForProject(projectId).getSuccess() .stream().filter(grant -> InviteStatus.SENT == grant.getStatus()) .collect(Collectors.toList()); return new ManageInvitationsViewModel(project.getCompetition(), project.getCompetitionName(), project.getId(), project.getName(), project.getApplication(), grants); } ManageInvitationsViewModel populateManageInvitationsViewModel(long projectId); } | @Test public void shouldPopulate() { Long projectId = 5L; ProjectResource project = ProjectResourceBuilder.newProjectResource() .withCompetition(4L) .withCompetitionName("compName") .withId(projectId) .withName("projName") .withApplication(6L).build(); when(projectService.getById(projectId)).thenReturn(project); List<SentGrantsInviteResource> grants = newSentGrantsInviteResource() .withStatus(InviteStatus.SENT, InviteStatus.CREATED, InviteStatus.SENT, InviteStatus.OPENED) .build(4); when(grantsInviteRestService.getAllForProject(projectId)).thenReturn(restSuccess(grants)); ManageInvitationsViewModel result = populator.populateManageInvitationsViewModel(projectId); assertEquals(4L, result.getCompetitionId()); assertEquals("compName", result.getCompetitionName()); assertEquals(projectId, result.getProjectId()); assertEquals("projName", result.getProjectName()); assertEquals(6L, result.getApplicationId()); assertEquals(Arrays.asList(grants.get(0), grants.get(2)), result.getGrants()); } |
MonitoringOfficerController { @GetMapping("/create/{emailAddress}") public String create(@PathVariable String emailAddress, Model model) { MonitoringOfficerCreateForm form = new MonitoringOfficerCreateForm(); model.addAttribute("emailAddress", emailAddress); model.addAttribute(FORM, form); return "project/monitoring-officer/create-new"; } @GetMapping("/search-by-email") String searchByEmail(Model model); @PostMapping("/search-by-email") String searchByEmail(@Valid @ModelAttribute(FORM) MonitoringOfficerSearchByEmailForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @GetMapping("/{userId}/assign-role") String assignRole(@PathVariable long userId,
Model model); @PostMapping("/{userId}/assign-role") String assignRole(@PathVariable long userId,
@Valid @ModelAttribute(FORM) MonitoringOfficerAssignRoleForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @PostMapping("/{userId}/assign-role-without-edit") String assignRoleWithoutEdit(@PathVariable long userId); @GetMapping("/create/{emailAddress}") String create(@PathVariable String emailAddress,
Model model); @PostMapping("/create") String createUser(@Valid @ModelAttribute(FORM) MonitoringOfficerCreateForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @GetMapping("/{monitoringOfficerId}/projects") String viewProjects(@PathVariable long monitoringOfficerId, Model model); @PostMapping("/{monitoringOfficerId}/assign") String assignProject(@PathVariable long monitoringOfficerId,
@Valid @ModelAttribute(FORM) MonitoringOfficerAssignProjectForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @GetMapping("/{monitoringOfficerId}/unassign/{projectId}") String unassignProject(@PathVariable long monitoringOfficerId,
@PathVariable long projectId); @GetMapping("/view-all") String viewAll(Model model); @GetMapping("/view-monitoring-officer") String redirectToMoProjectPage(@ModelAttribute("form") MonitoringOfficerViewAllForm form); } | @Test public void create() throws Exception { mockMvc.perform(get("/monitoring-officer/create/"+ EMAIL_ADDRESS)) .andExpect(status().isOk()) .andExpect(view().name("project/monitoring-officer/create-new")); } |
MonitoringOfficerController { @PostMapping("/create") public String createUser(@Valid @ModelAttribute(FORM) MonitoringOfficerCreateForm form, BindingResult bindingResult, ValidationHandler validationHandler, Model model) { Supplier<String> failureView = () -> { model.addAttribute("emailAddress", form.getEmailAddress()); model.addAttribute(FORM, form); return "project/monitoring-officer/create-new"; }; return validationHandler .failNowOrSucceedWith(failureView, () -> { MonitoringOfficerCreateResource resource = new MonitoringOfficerCreateResource(form.getFirstName(), form.getLastName(), form.getPhoneNumber(), form.getEmailAddress()); RestResult<Void> result = monitoringOfficerRegistrationRestService.createMonitoringOfficer(resource); return validationHandler .addAnyErrors(result) .failNowOrSucceedWith(failureView, () -> "redirect:/monitoring-officer/view-all"); }); } @GetMapping("/search-by-email") String searchByEmail(Model model); @PostMapping("/search-by-email") String searchByEmail(@Valid @ModelAttribute(FORM) MonitoringOfficerSearchByEmailForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @GetMapping("/{userId}/assign-role") String assignRole(@PathVariable long userId,
Model model); @PostMapping("/{userId}/assign-role") String assignRole(@PathVariable long userId,
@Valid @ModelAttribute(FORM) MonitoringOfficerAssignRoleForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @PostMapping("/{userId}/assign-role-without-edit") String assignRoleWithoutEdit(@PathVariable long userId); @GetMapping("/create/{emailAddress}") String create(@PathVariable String emailAddress,
Model model); @PostMapping("/create") String createUser(@Valid @ModelAttribute(FORM) MonitoringOfficerCreateForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @GetMapping("/{monitoringOfficerId}/projects") String viewProjects(@PathVariable long monitoringOfficerId, Model model); @PostMapping("/{monitoringOfficerId}/assign") String assignProject(@PathVariable long monitoringOfficerId,
@Valid @ModelAttribute(FORM) MonitoringOfficerAssignProjectForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
Model model,
UserResource user); @GetMapping("/{monitoringOfficerId}/unassign/{projectId}") String unassignProject(@PathVariable long monitoringOfficerId,
@PathVariable long projectId); @GetMapping("/view-all") String viewAll(Model model); @GetMapping("/view-monitoring-officer") String redirectToMoProjectPage(@ModelAttribute("form") MonitoringOfficerViewAllForm form); } | @Test public void createUser() throws Exception { when(monitoringOfficerRegistrationRestServiceMock.createMonitoringOfficer(any(MonitoringOfficerCreateResource.class))) .thenReturn(restSuccess()); mockMvc.perform(post("/monitoring-officer/create") .param("emailAddress", "[email protected]") .param("firstName", "Steve") .param("lastName", "Smith") .param("phoneNumber", "01142222222")) .andExpect(status().is3xxRedirection()); verify(monitoringOfficerRegistrationRestServiceMock).createMonitoringOfficer(any(MonitoringOfficerCreateResource.class)); } |
MonitoringOfficerAssignRoleViewModelPopulator { public MonitoringOfficerAssignRoleViewModel populate(long userId) { UserResource userResource = userRestService.retrieveUserById(userId).getSuccess(); return new MonitoringOfficerAssignRoleViewModel( userId, userResource.getFirstName(), userResource.getLastName(), userResource.getEmail(), userResource.getPhoneNumber()); } MonitoringOfficerAssignRoleViewModelPopulator(); MonitoringOfficerAssignRoleViewModel populate(long userId); } | @Test public void populate() { UserResource userResource = newUserResource() .withId(999L) .withEmail("[email protected]") .withFirstName("first") .withLastName("last") .build(); when(userRestService.retrieveUserById(999L)).thenReturn(restSuccess(userResource)); MonitoringOfficerAssignRoleViewModel actual = target.populate(userResource.getId()); assertThat(actual, instanceOf(MonitoringOfficerAssignRoleViewModel.class)); assertThat(actual.getUserId(), is(999L)); assertThat(actual.getEmailAddress(), is("[email protected]")); assertThat(actual.getFirstName(), is("first")); assertThat(actual.getLastName(), is("last")); }
@Test(expected = ObjectNotFoundException.class) public void populateWhenUserNotFound() { long userId = 999L; when(userRestService.retrieveUserById(userId)).thenReturn(restFailure(notFoundError(UserResource.class, userId))); target.populate(userId); } |
FinanceChecksViabilityController { @PostMapping(params = "confirm-viability") public String confirmViability(@PathVariable("projectId") Long projectId, @PathVariable("organisationId") Long organisationId, @ModelAttribute("form") FinanceChecksViabilityForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, Model model) { Supplier<String> successView = () -> "redirect:/project/" + projectId + "/finance-check/organisation/" + organisationId + "/viability"; return doSaveViability(projectId, organisationId, ViabilityState.APPROVED, form, validationHandler, model, successView); } @GetMapping String viewViability(@PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId, Model model); @PostMapping(params = "save-and-continue") String saveAndContinue(@PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId,
@ModelAttribute("form") FinanceChecksViabilityForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @PostMapping(params = "confirm-viability") String confirmViability(@PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId,
@ModelAttribute("form") FinanceChecksViabilityForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); } | @Test public void confirmViability() throws Exception { Long projectId = 123L; Long organisationId = 456L; when(projectFinanceService.saveCreditReportConfirmed(projectId, organisationId, true)). thenReturn(serviceSuccess()); when(projectFinanceService.saveViability(projectId, organisationId, ViabilityState.APPROVED, ViabilityRagStatus.RED)). thenReturn(serviceSuccess()); mockMvc.perform( post("/project/{projectId}/finance-check/organisation/{organisationId}/viability", projectId, organisationId). param("confirm-viability", ""). param("confirmViabilityChecked", "true"). param("creditReportConfirmed", "true"). param("ragStatus", "RED")). andExpect(status().is3xxRedirection()). andExpect(view().name("redirect:/project/" + projectId + "/finance-check/organisation/" + organisationId + "/viability")); verify(projectFinanceService).saveCreditReportConfirmed(projectId, organisationId, true); verify(projectFinanceService).saveViability(projectId, organisationId, ViabilityState.APPROVED, ViabilityRagStatus.RED); } |
FinanceChecksViabilityController { @PostMapping(params = "save-and-continue") public String saveAndContinue(@PathVariable("projectId") Long projectId, @PathVariable("organisationId") Long organisationId, @ModelAttribute("form") FinanceChecksViabilityForm form, @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler, Model model) { Supplier<String> successView = () -> "redirect:/project/" + projectId + "/finance-check"; return doSaveViability(projectId, organisationId, ViabilityState.REVIEW, form, validationHandler, model, successView); } @GetMapping String viewViability(@PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId, Model model); @PostMapping(params = "save-and-continue") String saveAndContinue(@PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId,
@ModelAttribute("form") FinanceChecksViabilityForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); @PostMapping(params = "confirm-viability") String confirmViability(@PathVariable("projectId") Long projectId,
@PathVariable("organisationId") Long organisationId,
@ModelAttribute("form") FinanceChecksViabilityForm form,
@SuppressWarnings("unused") BindingResult bindingResult,
ValidationHandler validationHandler,
Model model); } | @Test public void saveAndContinue() throws Exception { Long projectId = 123L; Long organisationId = 456L; when(projectFinanceService.saveCreditReportConfirmed(projectId, organisationId, false)). thenReturn(serviceSuccess()); when(projectFinanceService.saveViability(projectId, organisationId, ViabilityState.REVIEW, ViabilityRagStatus.UNSET)). thenReturn(serviceSuccess()); mockMvc.perform( post("/project/{projectId}/finance-check/organisation/{organisationId}/viability", projectId, organisationId). param("save-and-continue", ""). param("creditReportConfirmed", "false"). param("confirmViabilityChecked", "false"). param("ragStatus", "UNSET")). andExpect(status().is3xxRedirection()). andExpect(view().name("redirect:/project/" + projectId + "/finance-check")); verify(projectFinanceService).saveCreditReportConfirmed(projectId, organisationId, false); verify(projectFinanceService).saveViability(projectId, organisationId, ViabilityState.REVIEW, ViabilityRagStatus.UNSET); } |
OnHoldController { @GetMapping public String viewOnHoldStatus(@ModelAttribute(value = "form", binding = false) OnHoldCommentForm form, BindingResult bindingResult, @PathVariable long projectId, @PathVariable long competitionId, Model model) { ProjectResource project = projectRestService.getProjectById(projectId).getSuccess(); if (project.getProjectState() != ON_HOLD) { return redirectToManagePage(projectId, competitionId); } ProjectStateCommentsResource comments = projectStateRestService.findOpenComments(projectId).getSuccess(); form.setCommentId(comments.id); model.addAttribute("model", new OnHoldViewModel(project, comments)); return "project/on-hold-status"; } @GetMapping String viewOnHoldStatus(@ModelAttribute(value = "form", binding = false) OnHoldCommentForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
Model model); @PostMapping String resumeProject(@PathVariable long projectId,
@PathVariable long competitionId,
UserResource user,
RedirectAttributes redirectAttributes); @PostMapping(params = "add-comment") String addComment(@Valid @ModelAttribute(value = "form") OnHoldCommentForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
Model model,
UserResource user); } | @Test public void viewOnHoldStatus() throws Exception { long competitionId = 1L; long applicationId = 2L; long projectId = 123L; ProjectResource project = newProjectResource() .withId(projectId) .withName("Name") .withCompetition(competitionId) .withApplication(applicationId) .withProjectState(ON_HOLD).build(); UserResource author = newUserResource() .withRoleGlobal(Role.IFS_ADMINISTRATOR) .withFirstName("Bob") .withLastName("Someone") .build(); ZonedDateTime created = ZonedDateTime.now(); ProjectStateCommentsResource commentsResource = new ProjectStateCommentsResource(1L, projectId, singletonList(new PostResource(2L, author, "Body", emptyList(), created)), ON_HOLD, "Title", created, author, null); when(projectRestService.getProjectById(projectId)).thenReturn(restSuccess(project)); when(projectStateRestService.findOpenComments(projectId)).thenReturn(restSuccess(commentsResource)); MvcResult result = mockMvc.perform(get("/competition/{competitionId}/project/{projectId}/on-hold-status", competitionId, projectId)) .andExpect(view().name("project/on-hold-status")) .andReturn(); OnHoldViewModel viewModel = (OnHoldViewModel) result.getModelAndView().getModel().get("model"); assertEquals(competitionId, viewModel.getCompetitionId()); assertEquals(projectId, viewModel.getProjectId()); assertEquals(applicationId, viewModel.getApplicationId()); assertEquals("Name", viewModel.getProjectName()); assertEquals("Title", viewModel.getTitle()); assertEquals(1, viewModel.getComments().size()); ProjectStateCommentViewModel commentViewModel = viewModel.getComments().get(0); assertEquals("Bob Someone", commentViewModel.getUser()); assertEquals("Innovate UK (IFS Administrator)", commentViewModel.getUserRole()); assertEquals("Body", commentViewModel.getComment()); assertEquals(toUkTimeZone(created), commentViewModel.getDate()); } |
OnHoldController { @PostMapping public String resumeProject(@PathVariable long projectId, @PathVariable long competitionId, UserResource user, RedirectAttributes redirectAttributes) { projectStateRestService.resumeProject(projectId).getSuccess(); redirectAttributes.addFlashAttribute("resumedFromOnHold", true); return user.hasRole(Role.IFS_ADMINISTRATOR) ? redirectToManagePage(projectId, competitionId) : redirectToProjectDetails(projectId, competitionId); } @GetMapping String viewOnHoldStatus(@ModelAttribute(value = "form", binding = false) OnHoldCommentForm form,
BindingResult bindingResult,
@PathVariable long projectId,
@PathVariable long competitionId,
Model model); @PostMapping String resumeProject(@PathVariable long projectId,
@PathVariable long competitionId,
UserResource user,
RedirectAttributes redirectAttributes); @PostMapping(params = "add-comment") String addComment(@Valid @ModelAttribute(value = "form") OnHoldCommentForm form,
BindingResult bindingResult,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
Model model,
UserResource user); } | @Test public void resumeProject_admin() throws Exception { long competitionId = 1L; long projectId = 123L; setLoggedInUser(newUserResource() .withRoleGlobal(Role.IFS_ADMINISTRATOR) .build()); when(projectStateRestService.resumeProject(projectId)).thenReturn(restSuccess()); mockMvc.perform(post("/competition/{competitionId}/project/{projectId}/on-hold-status", competitionId, projectId)) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl(String.format("/competition/%d/project/%d/manage-status", competitionId, projectId))) .andExpect(flash().attribute("resumedFromOnHold", true)); verify(projectStateRestService).resumeProject(projectId); }
@Test public void resumeProject_projectFinance() throws Exception { long competitionId = 1L; long projectId = 123L; setLoggedInUser(newUserResource() .withRoleGlobal(Role.PROJECT_FINANCE) .build()); when(projectStateRestService.resumeProject(projectId)).thenReturn(restSuccess()); mockMvc.perform(post("/competition/{competitionId}/project/{projectId}/on-hold-status", competitionId, projectId)) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl(String.format("/competition/%d/project/%d/details", competitionId, projectId))) .andExpect(flash().attribute("resumedFromOnHold", true)); verify(projectStateRestService).resumeProject(projectId); } |
ManageProjectStateController { @GetMapping public String manageProjectState(@ModelAttribute(value = "form", binding = false) ManageProjectStateForm form, BindingResult result, @PathVariable long projectId, Model model, UserResource user) { model.addAttribute("model", new ManageProjectStateViewModel(projectRestService.getProjectById(projectId).getSuccess(), user.hasRole(Role.IFS_ADMINISTRATOR))); return "project/manage-project-state"; } @GetMapping String manageProjectState(@ModelAttribute(value = "form", binding = false) ManageProjectStateForm form,
BindingResult result,
@PathVariable long projectId,
Model model,
UserResource user); @PostMapping String setProjectState(@Valid @ModelAttribute(value = "form") ManageProjectStateForm form,
BindingResult result,
ValidationHandler validationHandler,
@PathVariable long projectId,
@PathVariable long competitionId,
Model model,
UserResource user); } | @Test public void manageProjectState() throws Exception { long competitionId = 1L; long applicationId = 2L; long projectId = 123L; ProjectResource project = newProjectResource() .withId(projectId) .withName("Name") .withCompetition(competitionId) .withApplication(applicationId) .withProjectState(SETUP).build(); when(projectRestService.getProjectById(projectId)).thenReturn(restSuccess(project)); MvcResult result = mockMvc.perform(get("/competition/{competitionId}/project/{projectId}/manage-status", competitionId, projectId)) .andExpect(view().name("project/manage-project-state")) .andReturn(); ManageProjectStateViewModel viewModel = (ManageProjectStateViewModel) result.getModelAndView().getModel().get("model"); assertEquals(competitionId, viewModel.getCompetitionId()); assertEquals(projectId, viewModel.getProjectId()); assertEquals(applicationId, viewModel.getApplicationId()); assertEquals("Name", viewModel.getProjectName()); assertTrue(viewModel.canHandleOffline()); assertTrue(viewModel.canWithdraw()); assertFalse(viewModel.canCompleteOffline()); assertTrue(viewModel.isInSetup()); assertFalse(viewModel.isHandledOffline()); assertFalse(viewModel.isWithdrawn()); assertFalse(viewModel.isCompletedOffline()); assertFalse(viewModel.isOnHold()); assertFalse(viewModel.isEndState()); assertFalse(viewModel.cantChangeState()); } |
ProjectSpendProfileExportController { @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_SPEND_PROFILE_SECTION')") @GetMapping("/csv") public void exportProjectPartnerSpendProfileAsCSV(@P("projectId")@PathVariable("projectId") final Long projectId, @PathVariable("organisationId") final Long organisationId, UserResource loggedInUser, HttpServletResponse response) throws IOException { SpendProfileCSVResource spendProfileCSVResource = spendProfileService.getSpendProfileCSV(projectId, organisationId); response.setContentType(CONTENT_TYPE); response.setHeader(HEADER_CONTENT_DISPOSITION, getCSVAttachmentHeader(removeComma(spendProfileCSVResource.getFileName()))); response.getOutputStream().print(spendProfileCSVResource.getCsvData()); response.getOutputStream().flush(); } @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_SPEND_PROFILE_SECTION')") @GetMapping("/csv") void exportProjectPartnerSpendProfileAsCSV(@P("projectId")@PathVariable("projectId") final Long projectId,
@PathVariable("organisationId") final Long organisationId,
UserResource loggedInUser,
HttpServletResponse response); } | @Test public void exportProjectPartnerSpendProfileAsCSV() throws Exception { Long organisationId = 1L; ProjectResource projectResource = newProjectResource() .withName("projectName1") .withTargetStartDate(LocalDate.of(2018, 3, 1)) .withDuration(3L) .build(); SpendProfileTableResource expectedTable = buildSpendProfileTableResource(projectResource); SpendProfileCSVResource expectedSpendProfileCSVResource = buildSpendProfileCSVResource(expectedTable); when(projectService.getById(projectResource.getId())).thenReturn(projectResource); when(spendProfileService.getSpendProfileTable(projectResource.getId(), organisationId)).thenReturn(expectedTable); when(spendProfileService.getSpendProfileCSV(projectResource.getId(), organisationId)).thenReturn(expectedSpendProfileCSVResource); mockMvc.perform(get("/project/{projectId}/partner-organisation/{organisationId}/spend-profile-export/csv", projectResource.getId(), organisationId)) .andExpect(status().isOk()) .andExpect(content().contentType(("text/csv"))) .andExpect(header().string("Content-Type", "text/csv")) .andExpect(header().string("Content-disposition", "attachment;filename=TEST_Spend_Profile_2016-10-30_10-11-12.csv")) .andExpect(content().string(generateTestCSVData(expectedTable))); } |
ActivityLogController { @GetMapping public String viewActivityLog(@PathVariable long projectId, Model model, UserResource user) { model.addAttribute("model", activityLogViewModelPopulator.populate(projectId, user)); return "project/activity-log"; } @GetMapping String viewActivityLog(@PathVariable long projectId,
Model model,
UserResource user); } | @Test public void viewActivityLog() throws Exception { long competitionId = 123L; long projectId = 1L; ActivityLogViewModel viewModel = mock(ActivityLogViewModel.class); when(activityLogViewModelPopulator.populate(projectId, getLoggedInUser())).thenReturn(viewModel); mockMvc.perform(get("/competition/{competitionId}/project/{projectId}/activity-log", competitionId, projectId)) .andExpect(view().name("project/activity-log")) .andExpect(model().attribute("model", viewModel)); } |
ActivityLogViewModelPopulator { public ActivityLogViewModel populate(long projectId, UserResource user) { ProjectResource project = projectRestService.getProjectById(projectId).getSuccess(); List<PartnerOrganisationResource> partnerOrganisationResources = partnerOrganisationRestService.getProjectPartnerOrganisations(projectId).getSuccess(); List<ProjectUserResource> projectUserResources = projectRestService.getProjectUsersForProject(projectId).getSuccess(); List<ActivityLogResource> activities = activityLogRestService.findByApplicationId(project.getApplication()).getSuccess(); List<ActivityLogEntryViewModel> views = activities.stream() .map(activity -> { String url = url(activity, project); return new ActivityLogEntryViewModel( title(activity), activity.getOrganisationName(), userText(activity, projectUserResources, partnerOrganisationResources), activity.getCreatedOn(), linkText(activity), url, url != null && userCanSeeLink(activity, user), activity.getActivityType()); }) .collect(toList()); return new ActivityLogViewModel( project, partnerOrganisationResources.stream() .filter(PartnerOrganisationResource::isLeadOrganisation) .findFirst() .map(PartnerOrganisationResource::getOrganisationName) .orElse(""), partnerOrganisationResources.stream() .filter(negate(PartnerOrganisationResource::isLeadOrganisation)) .map(PartnerOrganisationResource::getOrganisationName) .collect(joining(", ")), views ); } ActivityLogViewModel populate(long projectId, UserResource user); } | @Test public void populate() { long projectId = 1L; long competitionId = 2L; long partnerUserId = 6L; long financeUserId = 7L; long organisationId = 8L; long documentId = 9L; long queryId = 10L; String organisationName = "My organisation"; ZonedDateTime now = now(); UserResource user = newUserResource() .withRoleGlobal(Role.STAKEHOLDER) .build(); ProjectResource project = newProjectResource() .withName("Project") .withCompetition(competitionId) .withCompetitionName("Competition") .withApplication(2L) .build(); PartnerOrganisationResource partner = newPartnerOrganisationResource() .withOrganisation(organisationId) .withOrganisationName(organisationName) .build(); ProjectUserResource projectUserResource = newProjectUserResource() .withRole(Role.PROJECT_MANAGER) .withUser(partnerUserId) .withOrganisation(organisationId) .build(); List<ActivityLogResource> activities = newActivityLogResource() .withActivityType(ActivityType.APPLICATION_SUBMITTED, ActivityType.BANK_DETAILS_APPROVED, ActivityType.DOCUMENT_UPLOADED, ActivityType.FINANCE_QUERY) .withAuthoredBy(partnerUserId, financeUserId, partnerUserId, financeUserId) .withAuthoredByRoles(singleton(Role.APPLICANT), singleton(Role.PROJECT_FINANCE), singleton(Role.APPLICANT), singleton(Role.PROJECT_FINANCE)) .withAuthoredByName("Adam Applicant", "Frank Finance", "Adam Applicant", "Frank Finance") .withCreatedOn(now.minusDays(3), now.minusDays(2), now.minusDays(1), now) .withOrganisation(null, organisationId, null, organisationId) .withOrganisationName(null, partner.getOrganisationName(), null, partner.getOrganisationName()) .withDocumentConfig(null, null, documentId, null) .withDocumentConfigName(null, null, "Collaboration agreement", null) .withQuery(null, null, null, queryId) .withQueryType(null, null, null, FinanceChecksSectionType.VIABILITY) .build(4); when(messageSource.getMessage(eq("ifs.activity.log.APPLICATION_SUBMITTED.title"), aryEq(new Object[]{""}), any())).thenReturn("APPLICATION_SUBMITTED"); when(messageSource.getMessage(eq("ifs.activity.log.BANK_DETAILS_APPROVED.title"), aryEq(new Object[]{""}), any())).thenReturn("BANK_DETAILS_APPROVED"); when(messageSource.getMessage(eq("ifs.activity.log.DOCUMENT_UPLOADED.title"), aryEq(new Object[]{""}), any())).thenReturn("DOCUMENT_UPLOADED"); when(messageSource.getMessage(eq("ifs.activity.log.FINANCE_QUERY.title"), aryEq(new Object[]{"Viability"}), any())).thenReturn("FINANCE_QUERY"); when(messageSource.getMessage(eq("ifs.activity.log.APPLICATION_SUBMITTED.link"), aryEq(new Object[]{null, null}), any())).thenReturn("APPLICATION_SUBMITTED"); when(messageSource.getMessage(eq("ifs.activity.log.BANK_DETAILS_APPROVED.link"), aryEq(new Object[]{null, null}), any())).thenReturn("BANK_DETAILS_APPROVED"); when(messageSource.getMessage(eq("ifs.activity.log.DOCUMENT_UPLOADED.link"), aryEq(new Object[]{null, "collaboration agreement"}), any())).thenReturn("DOCUMENT_UPLOADED"); when(messageSource.getMessage(eq("ifs.activity.log.FINANCE_QUERY.link"), aryEq(new Object[]{"viability", null}), any())).thenReturn("FINANCE_QUERY"); when(projectRestService.getProjectById(projectId)).thenReturn(restSuccess(project)); when(partnerOrganisationRestService.getProjectPartnerOrganisations(projectId)).thenReturn(restSuccess(singletonList(partner))); when(projectRestService.getProjectUsersForProject(projectId)).thenReturn(restSuccess(singletonList(projectUserResource))); when(activityLogRestService.findByApplicationId(project.getApplication())).thenReturn(restSuccess(activities)); ActivityLogViewModel viewModel = activityLogViewModelPopulator.populate(projectId, user); assertEquals("Competition", viewModel.getCompetitionName()); assertEquals(4, viewModel.getActivities().size()); ActivityLogEntryViewModel applicationSubmitted = viewModel.getActivities().get(0); assertEquals("APPLICATION_SUBMITTED", applicationSubmitted.getTitle()); assertEquals(null, applicationSubmitted.getOrganisationName()); assertEquals("Adam Applicant, Project manager for My organisation", applicationSubmitted.getUserText()); assertEquals(now.minusDays(3), applicationSubmitted.getCreatedOn()); assertEquals("APPLICATION_SUBMITTED", applicationSubmitted.getLinkText()); assertEquals(format("/management/competition/%d/application/%d", project.getCompetition(), project.getApplication()), applicationSubmitted.getLinkUrl()); assertTrue(applicationSubmitted.isDisplayLink()); ActivityLogEntryViewModel bankDetailsApproved = viewModel.getActivities().get(1); assertEquals("BANK_DETAILS_APPROVED", bankDetailsApproved.getTitle()); assertEquals(organisationName, bankDetailsApproved.getOrganisationName()); assertEquals("Frank Finance, Project Finance", bankDetailsApproved.getUserText()); assertEquals(now.minusDays(2), bankDetailsApproved.getCreatedOn()); assertEquals("BANK_DETAILS_APPROVED", bankDetailsApproved.getLinkText()); assertEquals(format("/project-setup-management/project/%d/organisation/%d/review-bank-details", project.getId(), organisationId), bankDetailsApproved.getLinkUrl()); assertFalse(bankDetailsApproved.isDisplayLink()); ActivityLogEntryViewModel documentUploaded = viewModel.getActivities().get(2); assertEquals("DOCUMENT_UPLOADED", documentUploaded.getTitle()); assertEquals(null, documentUploaded.getOrganisationName()); assertEquals("Adam Applicant, Project manager for My organisation", documentUploaded.getUserText()); assertEquals(now.minusDays(1), documentUploaded.getCreatedOn()); assertEquals("DOCUMENT_UPLOADED", documentUploaded.getLinkText()); assertEquals(format("/project-setup-management/project/%d/document/config/%d", project.getId(), documentId), documentUploaded.getLinkUrl()); assertFalse(documentUploaded.isDisplayLink()); ActivityLogEntryViewModel financeQuery = viewModel.getActivities().get(3); assertEquals("FINANCE_QUERY", financeQuery.getTitle()); assertEquals(organisationName, financeQuery.getOrganisationName()); assertEquals("Frank Finance, Project Finance", financeQuery.getUserText()); assertEquals(now, financeQuery.getCreatedOn()); assertEquals("FINANCE_QUERY", financeQuery.getLinkText()); assertEquals(format("/project-setup-management/project/%d/finance-check/organisation/%d/query?query_section=%s", project.getId(), organisationId, "VIABILITY"), financeQuery.getLinkUrl()); assertFalse(financeQuery.isDisplayLink()); } |
ActivityLogUrlHelper { public static String url(ActivityLogResource log, ProjectResource project) { switch (log.getActivityType()) { case APPLICATION_SUBMITTED: case APPLICATION_REOPENED: return format("/management/competition/%d/application/%d", project.getCompetition(), project.getApplication()); case APPLICATION_INTO_PROJECT_SETUP: return format("/project-setup-management/competition/%d/status/all?applicationSearchString=%d", project.getCompetition(), project.getApplication()); case PROJECT_DETAILS_COMPLETE: case FINANCE_REVIEWER_ADDED: case MANAGED_OFFLINE: case COMPLETE_OFFLINE: case WITHDRAWN: case ON_HOLD: case RESUMED_FROM_ON_HOLD: case MARKED_PROJECT_AS_SUCCESSFUL: case MARKED_PROJECT_AS_UNSUCCESSFUL: return format("/project-setup-management/competition/%d/project/%d/details", project.getCompetition(), project.getId()); case ORGANISATION_REMOVED: case ORGANISATION_ADDED: case PROJECT_MANAGER_NOMINATED: case FINANCE_CONTACT_NOMINATED: return format("/project-setup-management/competition/%d/project/%d/team", project.getCompetition(), project.getId()); case DOCUMENT_UPLOADED: case DOCUMENT_APPROVED: case DOCUMENT_REJECTED: return format("/project-setup-management/project/%d/document/config/%d", project.getId(), log.getDocumentConfig()); case MONITORING_OFFICER_ASSIGNED: return format("/project-setup-management/project/%d/monitoring-officer", project.getId()); case BANK_DETAILS_SUBMITTED: case BANK_DETAILS_APPROVED: case BANK_DETAILS_EDITED: return format("/project-setup-management/project/%d/organisation/%d/review-bank-details", project.getId(), log.getOrganisation()); case VIABILITY_APPROVED: return format("/project-setup-management/project/%d/finance-check/organisation/%d/viability", project.getId(), log.getOrganisation()); case ELIGIBILITY_APPROVED: return format("/project-setup-management/project/%d/finance-check/organisation/%d/eligibility", project.getId(), log.getOrganisation()); case VIABILITY_RESET: return format("/project-setup-management/project/%d/finance-check", project.getId()); case ELIGIBILITY_RESET: return format("/project-setup-management/project/%d/finance-check", project.getId()); case FINANCE_CHECKS_RESET: return format("/project-setup-management/project/%d/finance-check", project.getId()); case FINANCE_QUERY: case FINANCE_QUERY_RESPONDED: return log.getQueryType() != null ? format("/project-setup-management/project/%d/finance-check/organisation/%d/query?query_section=%s", project.getId(), log.getOrganisation(), log.getQueryType().name()) : null; case SPEND_PROFILE_GENERATED: return format("/project-setup-management/project/%d/finance-check", project.getId()); case SPEND_PROFILE_SENT: case SPEND_PROFILE_APPROVED: case SPEND_PROFILE_REJECTED: return format("/project-setup-management/project/%d/spend-profile/approval", project.getId()); case GRANT_OFFER_LETTER_UPLOADED: case GRANT_OFFER_LETTER_PUBLISHED: case GRANT_OFFER_LETTER_SIGNED: case GRANT_OFFER_LETTER_APPROVED: case GRANT_OFFER_LETTER_REJECTED: return format("/project-setup-management/project/%d/grant-offer-letter/send", project.getId()); default: return null; } } static String url(ActivityLogResource log, ProjectResource project); static boolean linkInvalidIfOrganisationRemoved(ActivityLogResource log); } | @Test public void url() { long projectId = 1L; long applicationId = 2L; long competitionId = 3L; long queryId = 4L; long documentId = 5L; long organisationId = 6L; ProjectResource project = newProjectResource() .withId(projectId) .withApplication(applicationId) .withCompetition(competitionId) .build(); ActivityLogResourceBuilder activity = newActivityLogResource() .withQuery(queryId) .withQueryType(FinanceChecksSectionType.VIABILITY) .withDocumentConfig(documentId) .withOrganisation(organisationId); stream(ActivityType.values()) .filter(type -> !asList(NONE, GRANTS_FINANCE_CONTACT_INVITED, GRANTS_MONITORING_OFFICER_INVITED, GRANTS_PROJECT_MANAGER_INVITED, SPEND_PROFILE_DELETED, GRANT_OFFER_LETTER_RESET) .contains(type)) .forEach((type) -> assertNotNull("Expected not null " + type, ActivityLogUrlHelper. url(activity.withActivityType(type).build(), project)) ); } |
FinanceOverviewController { @SecuredBySpring(value = "TODO", description = "TODO") @GetMapping @PreAuthorize("hasAnyAuthority('project_finance', 'comp_admin', 'external_finance')") public String view(@PathVariable("projectId") Long projectId, Model model) { model.addAttribute("model", buildFinanceCheckOverviewViewModel(projectId)); return "project/financecheck/overview"; } @SecuredBySpring(value = "TODO", description = "TODO") @GetMapping @PreAuthorize("hasAnyAuthority('project_finance', 'comp_admin', 'external_finance')") String view(@PathVariable("projectId") Long projectId,
Model model); } | @Test public void views() throws Exception { long projectId = 123L; long organisationId = 456L; CompetitionResource competition = newCompetitionResource() .withFundingType(FundingType.LOAN) .withFinanceRowTypes(singletonList(FinanceRowType.GRANT_CLAIM_AMOUNT)) .build(); List<PartnerOrganisationResource> partnerOrganisationResources = newPartnerOrganisationResource() .withOrganisationName("EGGS", "Ludlow", "Empire").withLeadOrganisation(false, false, true).withProject(projectId).build(3); FinanceCheckEligibilityResource financeCheckEligibilityResource = newFinanceCheckEligibilityResource().withTotalCost(BigDecimal.valueOf(280009)).build(); when(partnerOrganisationRestService.getProjectPartnerOrganisations(projectId)).thenReturn(restSuccess(partnerOrganisationResources)); when(financeCheckServiceMock.getFinanceCheckOverview(projectId)).thenReturn(serviceSuccess(mockFinanceOverview())); when(financeCheckServiceMock.getFinanceCheckEligibilityDetails(projectId, organisationId)).thenReturn(financeCheckEligibilityResource); when(projectFinanceService.getProjectFinances(projectId)).thenReturn(emptyList()); ProjectResource projectResource = newProjectResource().withCompetition(competition.getId()).build(); when(projectService.getById(projectId)).thenReturn(projectResource); when(competitionRestService.getCompetitionById(projectResource.getCompetition())).thenReturn(restSuccess(competition)); when(financeCheckServiceMock.getFinanceCheckSummary(projectId)).thenReturn(serviceSuccess(newFinanceCheckSummaryResource().withPartnerStatusResources(emptyList()).build())); MvcResult result = mockMvc.perform(get("/project/{projectId}/finance-check-overview", projectId)). andExpect(view().name("project/financecheck/overview")). andReturn(); FinanceCheckOverviewViewModel financeCheckOverviewViewModel = (FinanceCheckOverviewViewModel) result.getModelAndView().getModel().get("model"); assertEquals(LocalDate.of(2016, 1, 1), financeCheckOverviewViewModel.getOverview().getProjectStartDate()); assertEquals("test-project", financeCheckOverviewViewModel.getOverview().getProjectName()); verify(financeCheckServiceMock).getFinanceCheckOverview(projectId); verify(financeCheckServiceMock, times(3)).getFinanceCheckEligibilityDetails(anyLong(), isNull()); verify(projectFinanceService).getProjectFinances(projectId); } |
FlywayVersionComparator implements Comparator<List<Integer>> { @Override public int compare(final List<Integer> o1,final List<Integer> o2) { if (o1.isEmpty() && o2.isEmpty()){ return 0; } else if (o1.isEmpty()){ return -1; } else if (o2.isEmpty()) { return 1; } else if (o1.get(0).compareTo(o2.get(0)) == 0) { return compare(o1.subList(1, o1.size()), o2.subList(1, o2.size())); } else { return o1.get(0).compareTo(o2.get(0)); } } @Override int compare(final List<Integer> o1,final List<Integer> o2); } | @Test public void testCompareTo(){ final FlywayVersionComparator comparator = new FlywayVersionComparator(); assertEquals(0, comparator.compare(new ArrayList<>(), new ArrayList<>())); assertEquals(1, comparator.compare(asList(10), asList(1))); assertEquals(-1, comparator.compare(asList(1), asList(10))); assertEquals(1, comparator.compare(asList(1, 1), asList(1))); assertEquals(-1, comparator.compare(asList(1), asList(1, 1))); assertEquals(1, comparator.compare(asList(1, 2), asList(1, 1))); assertEquals(0, comparator.compare(asList(1, 2), asList(1, 2))); assertEquals(1, comparator.compare(asList(1, 2, 3, 4, 6), asList(1, 2, 3, 4, 5))); assertEquals(1, comparator.compare(asList(127, 2), asList(127, 1))); assertEquals(1, comparator.compare(asList(128, 2), asList(128, 1))); } |
FlywayVersionContentTreeCallback extends AbstractContentTreeCallback { static List<Pair<String, List<Integer>>> sortAndFilter(final List<Pair<String, List<Integer>>> unsorted) { final List<Pair<String, List<Integer>>> sorted = new ArrayList<>(unsorted); final Iterator<Pair<String, List<Integer>>> iterator = sorted.iterator(); while (iterator.hasNext()) { final Pair<String, List<Integer>> toRemove = iterator.next(); if (toRemove.getValue().isEmpty()) { iterator.remove(); } } sorted.sort(FLYWAY_VERSION_COMPARATOR); return sorted; } FlywayVersionContentTreeCallback(final Consumer<List<Pair<String, List<Integer>>>> callBack); @Override boolean onTreeNode(final ContentTreeNode node); @Override void onEnd(final ContentTreeSummary summary); } | @Test public void testSortAndFilter() { final List<Pair<String, List<Integer>>> unsorted = new ArrayList<>(); unsorted.add(of("V1_2_3__Patch.sql", asList(1, 2, 3))); unsorted.add(of("V1__Patch.sql", asList(1))); unsorted.add(of("NotAPatch.java", asList())); unsorted.add(of("V2_3_5__Patch.sql", asList(2, 3, 5))); unsorted.add(of("V2_3_5__Patch.sql", asList(2, 3, 5))); unsorted.add(of("V2_5__Patch.sql", asList(2, 5))); unsorted.add(of("V10__Patch.sql", asList(10))); final List<Pair<String, List<Integer>>> sortedAndFiltered = sortAndFilter(unsorted); assertEquals(of("V1__Patch.sql", asList(1)), sortedAndFiltered.get(0)); assertEquals(of("V1_2_3__Patch.sql", asList(1, 2, 3)), sortedAndFiltered.get(1)); assertEquals(of("V2_3_5__Patch.sql", asList(2, 3, 5)), sortedAndFiltered.get(2)); assertEquals(of("V2_3_5__Patch.sql", asList(2, 3, 5)), sortedAndFiltered.get(3)); assertEquals(of("V2_5__Patch.sql", asList(2, 5)), sortedAndFiltered.get(4)); assertEquals(of("V10__Patch.sql", asList(10)), sortedAndFiltered.get(5)); } |
FlywayVersionContentTreeCallback extends AbstractContentTreeCallback { static Pair<String, List<Integer>> versionFromName(final String name) { final List<Integer> version = new ArrayList<>(); final Matcher matcher = FLYWAY_PATCH_PATTERN.matcher(name); if (matcher.find()) { final Matcher major = FLYWAY_MAJOR_PATCH_PATTERN.matcher(name); major.find(); version.add(parseInt(major.group(1))); for (final Matcher minor = FLYWAY_MINOR_PATCH_PATTERN.matcher(name); minor.find(); ) { version.add(parseInt(minor.group(1))); } } return of(name, version); } FlywayVersionContentTreeCallback(final Consumer<List<Pair<String, List<Integer>>>> callBack); @Override boolean onTreeNode(final ContentTreeNode node); @Override void onEnd(final ContentTreeSummary summary); } | @Test public void testVersionFromName(){ assertEquals(of("V12_22_1_7__test.sql", asList(12,22,1,7)), versionFromName("V12_22_1_7__test.sql")); assertEquals(of("V12__test.sql", asList(12)), versionFromName("V12__test.sql")); assertEquals(of("V12__test__some_more.sql", asList(12)), versionFromName("V12__test__some_more.sql")); assertEquals(of("12__not_valid.sql", asList()), versionFromName("12__not_valid.sql")); assertEquals(of("V12_22_not_valid.sql", asList()), versionFromName("V12_22_not_valid.sql")); assertEquals(of("V12_22__not_valid.java", asList()), versionFromName("V12_22__not_valid.java")); } |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public ValidationMessages validateAcademicUpload(Application application, Long markedAsCompleteById) { return getProcessRole(markedAsCompleteById).andOnSuccessReturn(role -> { OrganisationResource organisation = organisationService.findById(role.getOrganisationId()).getSuccess(); if (application.getCompetition().applicantShouldUseJesFinances(organisation.getOrganisationTypeEnum())) { if (financeFileIsNotPresent(application, organisation)) { return new ValidationMessages(fieldError("jesFileUpload", null, "validation.application.jes.upload.required")); } } return noErrors(); }).getSuccess(); } @Override List<BindingResult> validateFormInputResponse(Long applicationId, Long formInputId); @Override ValidationMessages validateFormInputResponse(Application application, long formInputId, long markedAsCompleteById); @Override List<ValidationMessages> validateCostItem(Long applicationId, FinanceRowType type, Long markedAsCompleteById); @Override FinanceRowHandler getCostHandler(FinanceRowItem costItem); @Override FinanceRowHandler getProjectCostHandler(FinanceRowItem costItem); @Override ValidationMessages validateAcademicUpload(Application application, Long markedAsCompleteById); @Override Boolean isApplicationComplete(Application application); @Override Boolean isFinanceOverviewComplete(Application application); } | @Test public void validateFormInputResponseWhenIsResearchUser() { Application application = newApplication().withCompetition(newCompetition().withIncludeJesForm(true).build()).build(); long markedAsCompleteById = 4L; long organisationId = 999L; ProcessRole processRole = newProcessRole() .withOrganisationId(organisationId) .withId(markedAsCompleteById) .build(); FormInputResponse formInputResponse = newFormInputResponse().build(); OrganisationResource organisationResult = newOrganisationResource().withOrganisationType(OrganisationTypeEnum.RESEARCH.getId()).build(); UserResource loggedInUser = newUserResource().build(); setLoggedInUser(loggedInUser); User user = newUser().build(); ValidationMessages expectedValidationMessage = new ValidationMessages(); expectedValidationMessage.addError(fieldError("jesFileUpload", null, "validation.application.jes.upload.required")); when(processRoleRepository.findById(markedAsCompleteById)).thenReturn(Optional.of(processRole)); when(organisationService.findById(organisationId)).thenReturn(ServiceResult.serviceSuccess(organisationResult)); when(userRepository.findById(loggedInUser.getId())).thenReturn(Optional.of(user)); ValidationMessages actual = service.validateAcademicUpload(application, markedAsCompleteById); assertEquals(expectedValidationMessage, actual); } |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public List<ValidationMessages> validateCostItem(Long applicationId, FinanceRowType type, Long markedAsCompleteById) { return getProcessRole(markedAsCompleteById).andOnSuccess(role -> financeService.financeDetails(applicationId, role.getOrganisationId()).andOnSuccessReturn(financeDetails -> financeValidationUtil.validateCostItem(type, financeDetails.getFinanceOrganisationDetails().get(type) ) ) ).getSuccess(); } @Override List<BindingResult> validateFormInputResponse(Long applicationId, Long formInputId); @Override ValidationMessages validateFormInputResponse(Application application, long formInputId, long markedAsCompleteById); @Override List<ValidationMessages> validateCostItem(Long applicationId, FinanceRowType type, Long markedAsCompleteById); @Override FinanceRowHandler getCostHandler(FinanceRowItem costItem); @Override FinanceRowHandler getProjectCostHandler(FinanceRowItem costItem); @Override ValidationMessages validateAcademicUpload(Application application, Long markedAsCompleteById); @Override Boolean isApplicationComplete(Application application); @Override Boolean isFinanceOverviewComplete(Application application); } | @Test public void validateCostItem() { long applicationId = 1L; long organisationId = 999L; Question question = newQuestion().build(); long questionId = question.getId(); long markedAsCompleteById = 5L; List<ValidationMessages> validationMessages = emptyList(); ProcessRole processRole = newProcessRole() .withOrganisationId(organisationId) .withId(1L) .build(); ApplicationFinanceResource expectedFinances = newApplicationFinanceResource() .withId(1L) .withApplication(1L) .withFinanceFileEntry(1L) .build(); List<FinanceRowItem> costItems = Arrays.asList(new TravelCost(expectedFinances.getId()), new TravelCost(expectedFinances.getId())); FinanceRowCostCategory costCategory = newDefaultCostCategory().withCosts(costItems).build(); expectedFinances.setFinanceOrganisationDetails(asMap(TRAVEL, costCategory)); List<ValidationMessages> expected = emptyList(); when(processRoleRepository.findById(markedAsCompleteById)).thenReturn(Optional.of(processRole)); when(financeService.financeDetails(applicationId, organisationId)).thenReturn(serviceSuccess(expectedFinances)); when(financeValidationUtil.validateCostItem(TRAVEL, costCategory)).thenReturn(validationMessages); List<ValidationMessages> result = service.validateCostItem(applicationId, FinanceRowType.TRAVEL, markedAsCompleteById); assertEquals(expected, result); verify(processRoleRepository).findById(markedAsCompleteById); verify(financeService).financeDetails(applicationId, organisationId); verify(financeValidationUtil).validateCostItem(TRAVEL, costCategory); }
@Test public void validateCostItemWhenMarkedAsCompleteByIdIsNull() { long applicationId = 1L; long organisationId = 999L; Question question = newQuestion().build(); long questionId = question.getId(); long applicationFinanceId = 1L; Long markedAsCompleteById = null; List<ValidationMessages> validationMessages = emptyList(); ProcessRole processRole = newProcessRole() .withOrganisationId(organisationId) .withId(1L) .build(); ApplicationFinanceResource expectedFinances = newApplicationFinanceResource() .withId(1L) .withApplication(1L) .withFinanceFileEntry(1L) .build(); List<FinanceRowItem> costItems = Arrays.asList(new TravelCost(expectedFinances.getId()), new TravelCost(expectedFinances.getId())); FinanceRowCostCategory costCategory = newDefaultCostCategory().withCosts(costItems).build(); expectedFinances.setFinanceOrganisationDetails(asMap(TRAVEL, costCategory)); when(processRoleRepository.findById(markedAsCompleteById)).thenReturn(Optional.of(processRole)); when(financeService.financeDetails(applicationId, organisationId)).thenReturn(serviceSuccess(expectedFinances)); when(financeValidationUtil.validateCostItem(TRAVEL, costCategory)).thenReturn(validationMessages); List<ValidationMessages> result = service.validateCostItem(applicationId, FinanceRowType.TRAVEL, markedAsCompleteById); assertEquals(validationMessages, result); verify(processRoleRepository).findById(markedAsCompleteById); verify(financeService).financeDetails(applicationId, organisationId); verify(financeValidationUtil).validateCostItem(TRAVEL, costCategory); } |
FileFunctions { public static final List<String> pathElementsToAbsolutePathElements(List<String> pathElements, String absolutePathPrefix) { if (pathElements.get(0).startsWith(absolutePathPrefix)) { return pathElements; } String absoluteFirstSegment = absolutePathPrefix + pathElements.get(0); return combineLists(absoluteFirstSegment, pathElements.subList(1, pathElements.size())); } private FileFunctions(); static final String pathElementsToPathString(List<String> pathElements); static final List<String> pathStringToPathElements(final String pathString); static final String pathElementsToAbsolutePathString(List<String> pathElements, String absolutePathPrefix); static final List<String> pathElementsToAbsolutePathElements(List<String> pathElements, String absolutePathPrefix); static final File pathElementsToFile(List<String> pathElements); static final Path pathElementsToPath(List<String> pathElements); } | @Test public void testPathElementsToAbsolutePathElements() { List<String> absolutePath = FileFunctions.pathElementsToAbsolutePathElements(asList("path", "to", "file"), "/"); assertEquals(asList("/path", "to", "file"), absolutePath); }
@Test public void testPathElementsToAbsolutePathElementsButAlreadyAbsolute() { List<String> absolutePath = FileFunctions.pathElementsToAbsolutePathElements(asList("/path", "to", "file"), "/"); assertEquals(asList("/path", "to", "file"), absolutePath); } |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public FinanceRowHandler getCostHandler(FinanceRowItem costItem) { return financeRowCostsService.getCostHandler(costItem.getId()); } @Override List<BindingResult> validateFormInputResponse(Long applicationId, Long formInputId); @Override ValidationMessages validateFormInputResponse(Application application, long formInputId, long markedAsCompleteById); @Override List<ValidationMessages> validateCostItem(Long applicationId, FinanceRowType type, Long markedAsCompleteById); @Override FinanceRowHandler getCostHandler(FinanceRowItem costItem); @Override FinanceRowHandler getProjectCostHandler(FinanceRowItem costItem); @Override ValidationMessages validateAcademicUpload(Application application, Long markedAsCompleteById); @Override Boolean isApplicationComplete(Application application); @Override Boolean isFinanceOverviewComplete(Application application); } | @Test public void getCostHandler() { TravelCost travelCost = new TravelCost(1L, "transport", new BigDecimal("25.00"), 5, 1L); FinanceRowHandler expected = new TravelCostHandler(); when(financeRowCostsService.getCostHandler(1L)).thenReturn(expected); FinanceRowHandler result = service.getCostHandler(travelCost); assertEquals(expected, result); verify(financeRowCostsService, only()).getCostHandler(1L); } |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public FinanceRowHandler getProjectCostHandler(FinanceRowItem costItem) { return projectFinanceRowService.getCostHandler(costItem); } @Override List<BindingResult> validateFormInputResponse(Long applicationId, Long formInputId); @Override ValidationMessages validateFormInputResponse(Application application, long formInputId, long markedAsCompleteById); @Override List<ValidationMessages> validateCostItem(Long applicationId, FinanceRowType type, Long markedAsCompleteById); @Override FinanceRowHandler getCostHandler(FinanceRowItem costItem); @Override FinanceRowHandler getProjectCostHandler(FinanceRowItem costItem); @Override ValidationMessages validateAcademicUpload(Application application, Long markedAsCompleteById); @Override Boolean isApplicationComplete(Application application); @Override Boolean isFinanceOverviewComplete(Application application); } | @Test public void getProjectCostHandler() { GrantClaimPercentage grantClaim = new GrantClaimPercentage(1L, BigDecimal.valueOf(20), 1L); FinanceRowHandler expected = new GrantClaimPercentageHandler(); when(projectFinanceRowService.getCostHandler(grantClaim)).thenReturn(expected); FinanceRowHandler result = service.getProjectCostHandler(grantClaim); assertEquals(expected, result); verify(projectFinanceRowService, only()).getCostHandler(grantClaim); } |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public Boolean isApplicationComplete(Application application) { BigDecimal progressPercentage = applicationProgressService.getApplicationProgress(application.getId()).getSuccess(); return isFinanceOverviewComplete(application) && isApplicationProgressComplete(progressPercentage); } @Override List<BindingResult> validateFormInputResponse(Long applicationId, Long formInputId); @Override ValidationMessages validateFormInputResponse(Application application, long formInputId, long markedAsCompleteById); @Override List<ValidationMessages> validateCostItem(Long applicationId, FinanceRowType type, Long markedAsCompleteById); @Override FinanceRowHandler getCostHandler(FinanceRowItem costItem); @Override FinanceRowHandler getProjectCostHandler(FinanceRowItem costItem); @Override ValidationMessages validateAcademicUpload(Application application, Long markedAsCompleteById); @Override Boolean isApplicationComplete(Application application); @Override Boolean isFinanceOverviewComplete(Application application); } | @Test public void isApplicationComplete() { long applicationId = 1l; long competitionId = 2l; CompetitionApplicationConfig competitionApplicationConfig = new CompetitionApplicationConfig(); Competition competition = newCompetition() .withId(competitionId) .withMaxResearchRatio(100) .withCompetitionApplicationConfig(competitionApplicationConfig) .withCollaborationLevel(CollaborationLevel.SINGLE).build(); Application application = newApplication() .withCompetition(competition) .withId(applicationId) .build(); List<ApplicationFinanceResource> applicationFinanceResources = newApplicationFinanceResource() .withIndustrialCosts() .withGrantClaimAmount(new BigDecimal(999)) .build(1); when(applicationProgressService.getApplicationProgress(applicationId)).thenReturn(serviceSuccess(BigDecimal.valueOf(100))); when(applicationFinanceHandler.getApplicationTotals(applicationId)).thenReturn(applicationFinanceResources); when(applicationFinanceHandler.getResearchParticipationPercentage(applicationId)).thenReturn(new BigDecimal("29")); boolean result = service.isApplicationComplete(application); assertTrue(result); }
@Test public void applicationNotReadyComplete_ResearchParticipationTooHigh() { long applicationId = 1l; long competitionId = 2l; CompetitionApplicationConfig competitionApplicationConfig = new CompetitionApplicationConfig(); Competition competition = newCompetition() .withId(competitionId) .withMaxResearchRatio(50) .withCompetitionApplicationConfig(competitionApplicationConfig) .withCollaborationLevel(CollaborationLevel.SINGLE).build(); Application application = newApplication() .withCompetition(competition) .withId(applicationId) .build(); List<ApplicationFinanceResource> applicationFinanceResources = newApplicationFinanceResource() .withIndustrialCosts() .withGrantClaimAmount(new BigDecimal(999)) .build(1); when(applicationProgressService.getApplicationProgress(applicationId)).thenReturn(serviceSuccess(BigDecimal.valueOf(100))); when(applicationFinanceHandler.getApplicationTotals(applicationId)).thenReturn(applicationFinanceResources); when(applicationFinanceHandler.getResearchParticipationPercentage(applicationId)).thenReturn(new BigDecimal("60")); boolean result = service.isApplicationComplete(application); assertFalse(result); }
@Test public void applicationNotReadyComplete_ProgressNotComplete() { long applicationId = 1l; long competitionId = 2l; CompetitionApplicationConfig competitionApplicationConfig = new CompetitionApplicationConfig(); Competition competition = newCompetition() .withId(competitionId) .withMaxResearchRatio(100) .withCompetitionApplicationConfig(competitionApplicationConfig) .withCollaborationLevel(CollaborationLevel.SINGLE).build(); Application application = newApplication() .withCompetition(competition) .withId(applicationId) .build(); List<ApplicationFinanceResource> applicationFinanceResources = newApplicationFinanceResource() .withIndustrialCosts() .withGrantClaimAmount(new BigDecimal(999)) .build(1); when(applicationProgressService.getApplicationProgress(applicationId)).thenReturn(serviceSuccess(BigDecimal.valueOf(7))); when(applicationFinanceHandler.getApplicationTotals(applicationId)).thenReturn(applicationFinanceResources); when(applicationFinanceHandler.getResearchParticipationPercentage(applicationId)).thenReturn(new BigDecimal("29")); boolean result = service.isApplicationComplete(application); assertFalse(result); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") public boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user) { return userIsConnectedToApplicationResource(application, user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void usersConnectedToTheApplicationCanView() { assertTrue(rules.usersConnectedToTheApplicationCanView(applicationResource1, leadOnApplication1)); assertTrue(rules.usersConnectedToTheApplicationCanView(applicationResource2, user2)); assertFalse(rules.usersConnectedToTheApplicationCanView(applicationResource1, user2)); assertFalse(rules.usersConnectedToTheApplicationCanView(applicationResource2, leadOnApplication1)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") public boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user) { return usersConnectedToTheApplicationCanView(applicationResource, user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void usersConnectedToTheApplicationCanViewInnovationAreas() { assertTrue(rules.usersConnectedToTheApplicationCanViewInnovationAreas(applicationResource1, leadOnApplication1)); assertTrue(rules.usersConnectedToTheApplicationCanViewInnovationAreas(applicationResource2, user2)); assertFalse(rules.usersConnectedToTheApplicationCanViewInnovationAreas(applicationResource1, user2)); assertFalse(rules.usersConnectedToTheApplicationCanViewInnovationAreas(applicationResource2, leadOnApplication1)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") public boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user) { return !isInnovationLead(user) && isInternal(user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void internalUsersOtherThanInnovationLeadAndStakeholderCanViewApplications() { assertTrue(rules.internalUsersCanViewApplications(applicationResource1, compAdmin)); assertTrue(rules.internalUsersCanViewApplications(applicationResource1, projectFinanceUser())); assertFalse(rules.internalUsersCanViewApplications(applicationResource1, innovationLeadUser())); assertFalse(rules.internalUsersCanViewApplications(applicationResource1, stakeholderUser())); assertFalse(rules.internalUsersCanViewApplications(applicationResource1, leadOnApplication1)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") public boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user) { return application != null && application.getCompetition() != null && userIsInnovationLeadOnCompetition(application.getCompetition(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void onlyInnovationLeadAssignedCompetitionForApplicationCanAccessApplication() { assertTrue(rules.innovationLeadAssignedToCompetitionCanViewApplications(applicationResource1, innovationLeadOnApplication1)); assertFalse(rules.innovationLeadAssignedToCompetitionCanViewApplications(applicationResource1, innovationLeadUser())); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") public boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user) { return application != null && application.getCompetition() != null && userIsStakeholderInCompetition(application.getCompetition(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void onlyStakeholdersAssignedToCompetitionForApplicationCanAccessApplication() { when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.stakeholderAssignedToCompetitionCanViewApplications(applicationResource1, stakeholderUserResourceOnCompetition)); assertFalse(rules.stakeholderAssignedToCompetitionCanViewApplications(applicationResource1, monitoringOfficerUser())); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") public boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user) { return application != null && application.getCompetition() != null && userIsExternalFinanceInCompetition(application.getCompetition(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void onlyCompetitionFinanceUserAssignedToCompetitionForApplicationCanAccessApplication() { when(externalFinanceRepository.existsByCompetitionIdAndUserId(competition.getId(), competitionFinanceUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.competitionFinanceUsersAssignedToCompetitionCanViewApplications(applicationResource1, competitionFinanceUserResourceOnCompetition)); assertFalse(rules.competitionFinanceUsersAssignedToCompetitionCanViewApplications(applicationResource1, monitoringOfficerUser())); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") public boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user) { return application != null && application.getCompetition() != null && projectMonitoringOfficerRepository.existsByProjectApplicationIdAndUserId(application.getId(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void monitoringOfficerAssignedToProjectCanViewApplications() { assertTrue(rules.monitoringOfficerAssignedToProjectCanViewApplications(applicationResource1, monitoringOfficerOnProjectForApplication1)); assertFalse(rules.monitoringOfficerAssignedToProjectCanViewApplications(applicationResource1, stakeholderUser())); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") public boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user) { return isAssessor(applicationResource.getId(), user) || isPanelAssessor(applicationResource.getId(), user) || isInterviewAssessor(applicationResource.getId(), user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void assessorCanSeeTheApplicationFinancesTotals() { assertTrue(rules.assessorCanSeeTheApplicationFinancesTotals(applicationResource1, assessor)); assertFalse(rules.assessorCanSeeTheApplicationFinancesTotals(applicationResource1, user2)); assertFalse(rules.assessorCanSeeTheApplicationFinancesTotals(applicationResource1, leadOnApplication1)); assertFalse(rules.usersConnectedToTheApplicationCanView(applicationResource2, assessor)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") public boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user) { return isKta(applicationResource.getId(), user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void ktaCanSeeTheApplicationFinancesTotals() { assertTrue(rules.ktaCanSeeTheApplicationFinanceTotals(applicationResource1, kta)); assertFalse(rules.ktaCanSeeTheApplicationFinanceTotals(applicationResource1, compAdmin)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") public boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user) { return isInternal(user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void internalUsersCanSeeApplicationFinanceTotals() { ApplicationResource applicationResource = newApplicationResource().build(); allGlobalRoleUsers.forEach(user -> { if (user.hasRole(COMP_ADMIN) || user.hasRole(PROJECT_FINANCE) || user.hasRole(SUPPORT) || user.hasRole(INNOVATION_LEAD) || user.hasRole(IFS_ADMINISTRATOR)) { assertTrue(rules.internalUserCanSeeApplicationFinancesTotals(applicationResource, user)); } else { assertFalse(rules.internalUserCanSeeApplicationFinancesTotals(applicationResource, user)); } }); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") public boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user) { return monitoringOfficerCanViewApplication(applicationResource.getId(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void monitoringOfficerCanSeeApplicationFinanceTotals() { Project project = newProject().build(); when(projectRepository.findOneByApplicationId(anyLong())).thenReturn(project); when(projectMonitoringOfficerRepository.existsByProjectIdAndUserId(project.getId(), monitoringOfficerUser().getId())).thenReturn(true); ApplicationResource applicationResource = newApplicationResource().build(); allGlobalRoleUsers.forEach(user -> { if (user.hasRole(MONITORING_OFFICER)) { assertTrue(rules.monitoringOfficersCanSeeApplicationFinancesTotals(applicationResource, monitoringOfficerUser())); } else { assertFalse(rules.monitoringOfficersCanSeeApplicationFinancesTotals(applicationResource, user)); } }); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") public boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user) { return userIsStakeholderInCompetition(applicationResource.getCompetition(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void stakeholdersCanSeeTheResearchParticipantPercentageInApplications() { ApplicationResource applicationResource = newApplicationResource() .withCompetition(competition.getId()) .build(); when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.stakeholdersCanSeeTheResearchParticipantPercentageInApplications(applicationResource, stakeholderUserResourceOnCompetition)); assertFalse(rules.stakeholdersCanSeeTheResearchParticipantPercentageInApplications(applicationResource, user2)); assertFalse(rules.stakeholdersCanSeeTheResearchParticipantPercentageInApplications(applicationResource, user3)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") public boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user) { return userIsExternalFinanceInCompetition(applicationResource.getCompetition(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications() { ApplicationResource applicationResource = newApplicationResource() .withCompetition(competition.getId()) .build(); when(externalFinanceRepository.existsByCompetitionIdAndUserId(competition.getId(), competitionFinanceUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(applicationResource, competitionFinanceUserResourceOnCompetition)); assertFalse(rules.competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(applicationResource, user2)); assertFalse(rules.competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(applicationResource, user3)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") public boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user) { return monitoringOfficerCanViewApplication(applicationResource.getId(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications() { Project project = newProject().build(); when(projectRepository.findOneByApplicationId(anyLong())).thenReturn(project); when(projectMonitoringOfficerRepository.existsByProjectIdAndUserId(project.getId(), monitoringOfficerUser().getId())).thenReturn(true); ApplicationResource applicationResource = newApplicationResource().build(); allGlobalRoleUsers.forEach(user -> { if (user.hasRole(MONITORING_OFFICER)) { assertTrue(rules.monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(applicationResource, monitoringOfficerUser())); } else { assertFalse(rules.monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(applicationResource, user)); } }); } |
FileServiceImpl extends RootTransactionalService implements FileService { @Override @Transactional public ServiceResult<Pair<File, FileEntry>> createFile(FileEntryResource resource, Supplier<InputStream> inputStreamSupplier) { return createTemporaryFileForValidation(resource.getName(), inputStreamSupplier).andOnSuccess(validationFile -> { try { return find( validateMediaType(validationFile, MediaType.parseMediaType(resource.getMediaType())), validateContentLength(resource.getFilesizeBytes(), validationFile)). andOnSuccess((mediaType, contentLength) -> saveFileEntry(resource).andOnSuccess(savedFileEntry -> { LOG.info("[FileLogging] New FileEntry record created with id " + savedFileEntry.getId()); return createFileForFileEntry(savedFileEntry, validationFile); }) ); } finally { deleteFile(validationFile); } }); } @Override @Transactional ServiceResult<Pair<File, FileEntry>> createFile(FileEntryResource resource, Supplier<InputStream> inputStreamSupplier); @Override ServiceResult<Supplier<InputStream>> getFileByFileEntryId(Long fileEntryId); @Override @Transactional ServiceResult<Pair<File, FileEntry>> updateFile(FileEntryResource fileToUpdate, Supplier<InputStream> inputStreamSupplier); @Override @Transactional @Deprecated ServiceResult<FileEntry> deleteFile(long fileEntryId); @Override @Transactional ServiceResult<FileEntry> deleteFileIgnoreNotFound(long fileEntryId); } | @Test public void testCreateFile() throws IOException { FileEntryResource fileResource = newFileEntryResource(). with(id(null)). withFilesizeBytes(17). build(); FileEntryBuilder fileBuilder = newFileEntry().withFilesizeBytes(17); FileEntry unpersistedFile = fileBuilder.with(id(null)).build(); FileEntry persistedFile = fileBuilder.with(id(456L)).build(); List<String> fullPathToNewFile = combineLists("path", "to", "file"); List<String> fullPathPlusFilename = combineLists(fullPathToNewFile, "thefilename"); when(fileEntryRepository.save(unpersistedFile)).thenReturn(persistedFile); when(temporaryHoldingFileStorageStrategy.createFile(eq(persistedFile), isA(File.class))).thenReturn(serviceSuccess(pathElementsToFile(fullPathPlusFilename))); ServiceResult<Pair<File, FileEntry>> result = service.createFile(fileResource, fakeInputStreamSupplier()); assertNotNull(result); assertTrue(result.isSuccess()); File newFileResult = result.getSuccess().getKey(); assertEquals("thefilename", newFileResult.getName()); String expectedPath = pathElementsToPathString(fullPathToNewFile); assertEquals(expectedPath + File.separator + "thefilename", newFileResult.getPath()); verify(fileEntryRepository).save(unpersistedFile); verify(temporaryHoldingFileStorageStrategy).createFile(eq(persistedFile), isA(File.class)); }
@Test public void testCreateFileFailureToCreateFileOnFilesystemHandledGracefully() { FileEntryResource fileResource = newFileEntryResource(). with(id(null)). withFilesizeBytes(17). build(); FileEntryBuilder fileBuilder = newFileEntry().withFilesizeBytes(17); FileEntry unpersistedFile = fileBuilder.with(id(null)).build(); FileEntry persistedFile = fileBuilder.with(id(456L)).build(); when(fileEntryRepository.save(unpersistedFile)).thenReturn(persistedFile); when(temporaryHoldingFileStorageStrategy.createFile(eq(persistedFile), isA(File.class))).thenReturn(serviceFailure(new Error(FILES_UNABLE_TO_CREATE_FOLDERS))); ServiceResult<Pair<File, FileEntry>> result = service.createFile(fileResource, fakeInputStreamSupplier()); assertTrue(result.isFailure()); assertTrue(result.getFailure().is(new Error(FILES_UNABLE_TO_CREATE_FOLDERS))); verify(fileEntryRepository).save(unpersistedFile); verify(temporaryHoldingFileStorageStrategy).createFile(eq(persistedFile), isA(File.class)); }
@Test public void testCreateFileWithIncorrectContentLength() throws IOException { int incorrectFilesize = 1234; FileEntryResource fileResource = newFileEntryResource(). with(id(null)). withFilesizeBytes(incorrectFilesize). build(); ServiceResult<Pair<File, FileEntry>> result = service.createFile(fileResource, fakeInputStreamSupplier()); assertTrue(result.isFailure()); assertTrue(result.getFailure().is(FILES_INCORRECTLY_REPORTED_FILESIZE, 17)); }
@Test public void testCreateFileWithIncorrectContentType() throws IOException { FileEntryResource fileResource = newFileEntryResource(). with(id(null)). withFilesizeBytes(17). withMediaType("application/pdf"). build(); ServiceResult<Pair<File, FileEntry>> result = service.createFile(fileResource, fakeInputStreamSupplier()); assertTrue(result.isFailure()); assertTrue(result.getFailure().is(FILES_INCORRECTLY_REPORTED_MEDIA_TYPE, "text/plain")); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") public boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user) { return userIsStakeholderInCompetition(applicationResource.getCompetition(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void stakeholdersCanSeeApplicationFinancesTotals() { ApplicationResource applicationResource = newApplicationResource() .withCompetition(competition.getId()) .build(); when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.stakeholdersCanSeeApplicationFinancesTotals(applicationResource, stakeholderUserResourceOnCompetition)); assertFalse(rules.stakeholdersCanSeeApplicationFinancesTotals(applicationResource, user2)); assertFalse(rules.stakeholdersCanSeeApplicationFinancesTotals(applicationResource, user3)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") public boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user) { return userIsExternalFinanceInCompetition(applicationResource.getCompetition(), user.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void competitionFinanceUserCanSeeApplicationFinancesTotals() { ApplicationResource applicationResource = newApplicationResource() .withCompetition(competition.getId()) .build(); when(externalFinanceRepository.existsByCompetitionIdAndUserId(competition.getId(), competitionFinanceUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.competitionFinanceUserCanSeeApplicationFinancesTotals(applicationResource, competitionFinanceUserResourceOnCompetition)); assertFalse(rules.competitionFinanceUserCanSeeApplicationFinancesTotals(applicationResource, user2)); assertFalse(rules.competitionFinanceUserCanSeeApplicationFinancesTotals(applicationResource, user3)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") public boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user) { Set<Role> allApplicantRoles = EnumSet.of(Role.LEADAPPLICANT, Role.COLLABORATOR); List<ProcessRole> applicantProcessRoles = processRoleRepository.findByUserIdAndRoleInAndApplicationId(user.getId(), allApplicantRoles, application.getId()); return !applicantProcessRoles.isEmpty(); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void onlyUsersPartOfTheApplicationCanChangeApplicationResource() { assertTrue(rules.applicantCanUpdateApplicationResource(applicationResource1, leadOnApplication1)); assertTrue(rules.applicantCanUpdateApplicationResource(applicationResource1, user2)); assertFalse(rules.applicantCanUpdateApplicationResource(applicationResource1, user3)); } |
ApplicationPermissionRules extends BasePermissionRules { boolean userIsConnectedToApplicationResource(ApplicationResource application, UserResource user) { return processRoleRepository.existsByUserIdAndApplicationId(user.getId(), application.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void userIsConnectedToApplicationResource() { assertTrue(rules.userIsConnectedToApplicationResource(applicationResource1, leadOnApplication1)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") public boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user) { return isAssessorForApplication(applicationResource, user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess() { assertTrue(rules.assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(applicationResource1, assessor)); assertTrue(rules.assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(applicationResource1, panelAssessor)); assertTrue(rules.assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(applicationResource1, interviewAssessor)); assertFalse(rules.assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(applicationResource1, compAdmin)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") public boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user) { return isMemberOfProjectTeam(applicationResource.getId(), user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void consortiumCanSeeTheResearchParticipantPercentage() { assertTrue(rules.consortiumCanSeeTheResearchParticipantPercentage(applicationResource1, leadOnApplication1)); assertFalse(rules.consortiumCanSeeTheResearchParticipantPercentage(applicationResource1, compAdmin)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") public boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user) { return isKtaForApplication(applicationResource, user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void ktaCanSeeTheResearchParticipantPercentage() { assertTrue(rules.ktaCanSeeTheResearchParticipantPercentage(applicationResource1, kta)); assertFalse(rules.ktaCanSeeTheResearchParticipantPercentage(applicationResource1, compAdmin)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") public boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user) { return isLeadApplicant(applicationResource.getId(), user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void leadApplicantCanUpdateTheInnovationArea() { assertTrue(rules.leadApplicantCanUpdateApplicationResource(applicationResource1, leadOnApplication1)); assertFalse(rules.leadApplicantCanUpdateApplicationResource(applicationResource1, user2)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") public boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user) { return isLeadApplicant(applicationResource.getId(), user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void leadApplicantCanSeeTheApplicationFinanceDetails() { assertTrue(rules.leadApplicantCanSeeTheApplicationFinanceDetails(applicationResource1, leadOnApplication1)); assertFalse(rules.leadApplicantCanSeeTheApplicationFinanceDetails(applicationResource1, user2)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") public boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user) { return isKta(applicationResource.getId(), user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void ktaCanSeeTheApplicationFinanceDetails() { assertTrue(rules.ktaCanSeeTheApplicationFinanceDetails(applicationResource1, kta)); assertFalse(rules.ktaCanSeeTheApplicationFinanceDetails(applicationResource1, compAdmin)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") public boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user) { return isInternal(user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void internalUsersCanSeeTheResearchParticipantPercentageInApplications() { assertTrue(rules.internalUsersCanSeeTheResearchParticipantPercentageInApplications(applicationResource1, compAdmin)); assertTrue(rules.internalUsersCanSeeTheResearchParticipantPercentageInApplications(applicationResource1, projectFinanceUser())); assertFalse(rules.internalUsersCanSeeTheResearchParticipantPercentageInApplications(applicationResource1, leadOnApplication1)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") public boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user) { return isLeadApplicant(applicationResource.getId(), user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void sendNotificationApplicationSubmitted() { assertTrue(rules.aLeadApplicantCanSendApplicationSubmittedNotification(applicationResource1, leadOnApplication1)); assertFalse(rules.aLeadApplicantCanSendApplicationSubmittedNotification(applicationResource1, user2)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") public boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user) { return isProjectFinanceUser(user) && !application.isInPublishedAssessorFeedbackCompetitionState(); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished() { assertTrue(rules.projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(applicationResource1, projectFinanceUser())); assertFalse(rules.projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(applicationResource1, user2)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") public boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user) { return isInternal(user) && application.isInEditableAssessorFeedbackCompetitionState(); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void internalUserCanUploadAssessorFeedbackToApplicationWhenCompetitionInFundersPanelOrAssessorFeedbackState() { asList(CompetitionStatus.values()).forEach(competitionStatus -> { allGlobalRoleUsers.forEach(user -> { ApplicationResource application = newApplicationResource().withCompetitionStatus(competitionStatus).build(); if (!allInternalUsers.contains(user)) { assertFalse(rules.internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(application, user)); verifyNoMoreInteractions(competitionRepository, processRoleRepository); } else { if (asList(FUNDERS_PANEL, ASSESSOR_FEEDBACK).contains(competitionStatus)) { assertTrue(rules.internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(application, user)); } else { assertFalse(rules.internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(application, user)); } } }); }); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") public boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user) { return isCompAdmin(user) && !application.isInPublishedAssessorFeedbackCompetitionState(); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished() { asList(CompetitionStatus.values()).forEach(competitionStatus -> { allGlobalRoleUsers.forEach(user -> { ApplicationResource application = newApplicationResource().withCompetitionStatus(competitionStatus).build(); if (!user.equals(compAdminUser())) { assertFalse(rules.compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(application, user)); verifyNoMoreInteractions(competitionRepository, processRoleRepository); } else { if (!singletonList(PROJECT_SETUP).contains(competitionStatus)) { assertTrue(rules.compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(application, user)); } else { assertFalse(rules.compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(application, user)); } verifyNoMoreInteractions(competitionRepository); reset(competitionRepository); } }); }); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") public boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user) { return isInternal(user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime() { asList(CompetitionStatus.values()).forEach(competitionStatus -> { allGlobalRoleUsers.forEach(user -> { Competition competition = newCompetition().withCompetitionStatus(competitionStatus).build(); ApplicationResource application = newApplicationResource().withCompetition(competition.getId()).build(); if (!allInternalUsers.contains(user)) { assertFalse(rules.internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(application, user)); verifyNoMoreInteractions(competitionRepository, processRoleRepository); } else { assertTrue(rules.internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(application, user)); verifyNoMoreInteractions(competitionRepository, processRoleRepository); } }); }); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") public boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user) { return application.isInPublishedAssessorFeedbackCompetitionState() && isMemberOfProjectTeam(application.getId(), user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications() { long competitionId = 123L; ApplicationResource application = newApplicationResource().withCompetition(competitionId).build(); UserResource leadApplicantUser = newUserResource().build(); UserResource collaboratorUser = newUserResource().build(); UserResource assessorUser = newUserResource().build(); List<UserResource> allUsersToTests = combineLists(allGlobalRoleUsers, leadApplicantUser, collaboratorUser, assessorUser); asList(CompetitionStatus.values()).forEach(competitionStatus -> { application.setCompetitionStatus(competitionStatus); allUsersToTests.forEach(user -> { reset(processRoleRepository); when(processRoleRepository.existsByUserIdAndApplicationIdAndRole(leadApplicantUser.getId(), application.getId(), LEADAPPLICANT)).thenReturn(true); when(processRoleRepository.existsByUserIdAndApplicationIdAndRole(collaboratorUser.getId(), application.getId(), COLLABORATOR)).thenReturn(true); when(processRoleRepository.existsByUserIdAndApplicationIdAndRole(assessorUser.getId(), application.getId(), ASSESSOR)).thenReturn(true); if (user == leadApplicantUser || user == collaboratorUser) { if (singletonList(PROJECT_SETUP).contains(competitionStatus)) { assertTrue(rules.applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(application, user)); if (user == leadApplicantUser) { verify(processRoleRepository, times(1)).existsByUserIdAndApplicationIdAndRole(user.getId(), application.getId(), LEADAPPLICANT); } else { verify(processRoleRepository, times(1)).existsByUserIdAndApplicationIdAndRole(user.getId(), application.getId(), COLLABORATOR); verify(processRoleRepository, times(1)).existsByUserIdAndApplicationIdAndRole(user.getId(), application.getId(), LEADAPPLICANT); } } else { assertFalse(rules.applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(application, user)); verify(processRoleRepository, never()).findOneByUserIdAndRoleInAndApplicationId(user.getId(), applicantProcessRoles(), application.getId()); } verifyNoMoreInteractions(competitionRepository, processRoleRepository); } else { assertFalse(rules.applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(application, user)); if (singletonList(PROJECT_SETUP).contains(competitionStatus)) { verify(processRoleRepository, times(1)).existsByUserIdAndApplicationIdAndRole(user.getId(), application.getId(), COLLABORATOR); verify(processRoleRepository, times(1)).existsByUserIdAndApplicationIdAndRole(user.getId(), application.getId(), LEADAPPLICANT); } else { verify(processRoleRepository, never()).findOneByUserIdAndRoleInAndApplicationId(user.getId(), applicantProcessRoles(), application.getId()); } verifyNoMoreInteractions(competitionRepository, processRoleRepository); } }); }); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") public boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user) { return isLeadApplicant(applicationResource.getId(), user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void leadApplicantCanUpdateApplicationState() { assertTrue(rules.leadApplicantCanUpdateApplicationState(applicationResource1, leadOnApplication1)); assertFalse(rules.leadApplicantCanUpdateApplicationState(applicationResource1, compAdmin)); assertFalse(rules.leadApplicantCanUpdateApplicationState(applicationResource1, user2)); } |
ApplicationPermissionRules extends BasePermissionRules { @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") public boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user) { return isCompAdmin(user); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The consortium can see the participation percentage for their applications") boolean consortiumCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The assessor can see the participation percentage for applications they assess") boolean assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The kta can see the participation percentage for applications they assess") boolean ktaCanSeeTheResearchParticipantPercentage(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "The internal users can see the participation percentage for applications they assess") boolean internalUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Stakeholders can see the participation percentage for applications they are assigned to") boolean stakeholdersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Competition finance users can see the participation percentage for applications they are assigned to") boolean competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE", description = "Monitoring officers can see the participation percentage for applications they are assigned to") boolean monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications(final ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The consortium can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean leadApplicantCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_DETAILS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceDetails(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The consortium can see the application finance totals", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean consortiumCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The assessor can see the application finance totals in the applications they assess", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean assessorCanSeeTheApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Internal users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean internalUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Competition finance users can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean competitionFinanceUserCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Monitoring officers can view the finance totals.") boolean monitoringOfficersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "Stakeholders can view the finance totals.", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean stakeholdersCanSeeApplicationFinancesTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ_FINANCE_TOTALS", description = "The kta can see the application finance details", additionalComments = "This rule secures ApplicationResource which can contain more information than this rule should allow. Consider a new cut down object based on ApplicationResource") boolean ktaCanSeeTheApplicationFinanceTotals(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_SUBMITTED_NOTIFICATION", description = "A lead applicant can send the notification of a submitted application") boolean aLeadApplicantCanSendApplicationSubmittedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "APPLICATION_REOPENED_NOTIFICATION", description = "A lead applicant can send the notification of a reopened application") boolean aLeadApplicantCanSendApplicationReopenedNotification(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "READ", description = "Internal users (other than innovation lead) can see all application resources") boolean internalUsersCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "A user can see an application resource which they are connected to") boolean usersConnectedToTheApplicationCanView(ApplicationResource application, UserResource user); @PermissionRule(value = "READ", description = "Innovation leads can see application resources for competitions assigned to them.") boolean innovationLeadAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Stakeholders can see application resources for competitions assigned to them.") boolean stakeholderAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Competition finance users can see application resources for competitions assigned to them.") boolean competitionFinanceUsersAssignedToCompetitionCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Monitoring officers can see application resources for projects assigned to them.") boolean monitoringOfficerAssignedToProjectCanViewApplications(final ApplicationResource application, final UserResource user); @PermissionRule(value = "READ", description = "Project Partners can see applications that are linked to their Projects") boolean projectPartnerCanViewApplicationsLinkedToTheirProjects(final ApplicationResource application, final UserResource user); @PermissionRule(value = "UPDATE", description = "A user can update their own application if they are a lead applicant or collaborator of the application") boolean applicantCanUpdateApplicationResource(ApplicationResource application, UserResource user); @PermissionRule(value = "READ_AVAILABLE_INNOVATION_AREAS", description = "A user can view the Innovation Areas that are available to their applications") boolean usersConnectedToTheApplicationCanViewInnovationAreas(ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_INNOVATION_AREA", description = "A lead applicant can update their application's Innovation Area") boolean leadApplicantCanUpdateApplicationResource(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_RESEARCH_CATEGORY", description = "A lead applicant can update their application's Research Category") boolean leadApplicantCanUpdateResearchCategory(ApplicationResource applicationResource, UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A lead applicant can update the state of their own application") boolean leadApplicantCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A comp admin can update the state of an application") boolean compAdminCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "REOPEN_APPLICATION", description = "A lead applicant can reopen their application if competition is open and they have not revieved a funding decision") boolean leadApplicantCanReopenTheirApplication(final ApplicationResource applicationResource, final UserResource user); @PermissionRule(value = "UPDATE_APPLICATION_STATE", description = "A project finance user can update the state of an application") boolean projectFinanceCanUpdateApplicationState(final ApplicationResource applicationResource, final UserResource user); @PermissionRule( value = "UPLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can upload Assessor Feedback documentation for an Application whilst " + "the Application's Competition is in Funders' Panel or Assessor Feedback state", particularBusinessState = "Application's Competition Status = 'Funders Panel' or 'Assessor Feedback'") boolean internalUserCanUploadAssessorFeedbackToApplicationInFundersPanelOrAssessorFeedbackState(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Comp Admin user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "REMOVE_ASSESSOR_FEEDBACK", description = "A Project Finance user can remove Assessor Feedback documentation so long as the Feedback has not yet been published", particularBusinessState = "Application's Competition Status != 'Project Setup' or beyond") boolean projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "An Internal user can see and download Assessor Feedback at any time for any Application") boolean internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime(ApplicationResource application, UserResource user); @PermissionRule( value = "DOWNLOAD_ASSESSOR_FEEDBACK", description = "A member of the Application Team can see and download Assessor Feedback attached to their Application when it has been published", particularBusinessState = "Application's Competition Status = 'Project Setup' or beyond") boolean applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications(ApplicationResource application, UserResource user); @PermissionRule(value = "CREATE", description = "Any logged in user with global roles or user with system registrar role can create an application but only for open competitions", particularBusinessState = "Competition is in Open state") boolean userCanCreateNewApplication(CompetitionResource competition, UserResource user); @PermissionRule(value = "MARK_AS_INELIGIBLE", description = "Application can be marked as ineligible by internal admin user and innovation lead only until ", particularBusinessState = "competition is in assessment state") boolean markAsInelgibileAllowedBeforeAssesment(ApplicationResource application, UserResource user); @PermissionRule(value = "CHECK_COLLABORATIVE_FUNDING_CRITERIA_MET", description = "The consortium can check collaborative funding criteria is met") boolean consortiumCanCheckCollaborativeFundingCriteriaIsMet(final ApplicationResource applicationResource,
final UserResource user); @PermissionRule(value = "CHECK_FUNDING_SOUGHT_VALID", description = "The consortium can check funding sought is valid") boolean consortiumCanCheckFundingSoughtIsValid(final ApplicationResource applicationResource,
final UserResource user); } | @Test public void compAdminCanUpdateApplicationState() { assertTrue(rules.compAdminCanUpdateApplicationState(applicationResource1, compAdmin)); assertFalse(rules.compAdminCanUpdateApplicationState(applicationResource1, leadOnApplication1)); assertFalse(rules.compAdminCanUpdateApplicationState(applicationResource1, user2)); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.