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)... | @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(ex... |
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") ProjectT... | @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... |
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... | @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(redirectedU... |
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") ProjectTeamFo... | @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 = "someone@gmail... |
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 co... | @Test public void resendInvite() throws Exception { long projectId = 4L; long competitionId = 5L; long organisationId = 21L; long inviteId = 3L; String invitedUserName = "test"; String invitedUserEmail = "test@test.com"; OrganisationResource leadOrganisation = newOrganisationResource().withName("Lead Organisation").bui... |
GoogleAnalyticsDataLayerController { @GetMapping("/application/{applicationId}/user-roles") public RestResult<List<Role>> getRolesByApplicationIdForCurrentUser(@PathVariable("applicationId") long applicationId) { return googleAnalyticsDataLayerService.getRolesByApplicationIdForCurrentUser(applicationId).toGetResponse()... | @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/applicatio... |
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 co... | @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-i... |
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") lo... | @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/" ... |
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... | @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") ... |
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... | @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") ... |
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,... | @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/" + applicantOrgani... |
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 @ModelA... | @Test public void testSaveNewNote() throws Exception { ProjectFinanceResource projectFinanceResource = newProjectFinanceResource().withProject(projectId).withOrganisation(applicantOrganisationId).withId(projectFinanceId).build(); when(projectFinanceService.getProjectFinance(projectId, applicantOrganisationId)).thenRetu... |
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, ... | @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 = createOrigi... |
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 organ... | @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()); MvcRes... |
ProjectDetailsStartDateViewModel implements BasicProjectDetailsViewModel { public boolean isKtpCompetition() { return ktpCompetition; } ProjectDetailsStartDateViewModel(ProjectResource project, CompetitionResource competition); String getProjectName(); long getProjectDurationInMonths(); Long getProjectId(); Long getApp... | @Test public void testKtpCompetition() { ProjectResource projectResource = ProjectResourceBuilder.newProjectResource() .withDuration(15L).build(); CompetitionResource competitionResource = CompetitionResourceBuilder.newCompetitionResource() .withFundingType(FundingType.KTP).build(); ProjectDetailsStartDateViewModel vie... |
GoogleAnalyticsDataLayerController { @GetMapping("/project/{projectId}/user-roles") public RestResult<List<Role>> getRolesByProjectIdForCurrentUser(@PathVariable("projectId") long projectId) { return googleAnalyticsDataLayerService.getRolesByProjectIdForCurrentUser(projectId).toGetResponse(); } @GetMapping("/applicati... | @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/... |
ProjectDetailsViewModel { public boolean isKtpCompetition() { return ktpCompetition; } ProjectDetailsViewModel(ProjectResource project,
Long competitionId,
String competitionName,
UserResource userResource,
... | @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 ProjectDetai... |
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 detail... | @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(Fundi... |
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") fin... | @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... |
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"... | @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 proj... |
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 projec... | @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_GEN... |
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", popul... | @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(... |
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, ... | @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, ... |
GoogleAnalyticsDataLayerController { @GetMapping("/project/{projectId}/application-id") public RestResult<Long> getApplicationIdForProject(@PathVariable("projectId") long projectId) { return googleAnalyticsDataLayerService.getApplicationIdForProject(projectId).toGetResponse(); } @GetMapping("/application/{applicationI... | @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",... |
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, @Pa... | @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.getFileConte... |
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, @M... | @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/" + docu... |
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(pr... | @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-com... |
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 S... | @Test public void viewPendingBankDetailsApprovals() throws Exception { List<BankDetailsReviewResource> pendingBankDetails = singletonList(new BankDetailsReviewResource(1L, 11L, "Comp1", 12L, "project1", 22L, "Org1")); when(bankDetailsRestService.getPendingBankDetailsApprovals()).thenReturn(restSuccess(pendingBankDetail... |
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, UserR... | @Test public void testViewPartnerBankDetails() throws Exception { Long projectId = 123L; final ProjectBankDetailsStatusSummary bankDetailsStatusSummary = newProjectBankDetailsStatusSummary().withBankDetailsStatusResources(newBankDetailsStatusResource().withBankDetailsStatus(ProjectActivityStates.NOT_REQUIRED).build(1))... |
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 or... | @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(yourProjec... |
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 FinanceRowTy... | @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) i... |
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, @Pat... | @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.p... |
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) @Vali... | @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()).... |
GoogleAnalyticsDataLayerController { @GetMapping("/assessment/{assessmentId}/application-id") public RestResult<Long> getApplicationIdForAssessment(@PathVariable("assessmentId") long assessmentId) { return googleAnalyticsDataLayerService.getApplicationIdForAssessment(assessmentId).toGetResponse(); } @GetMapping("/appl... | @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}/a... |
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") @Path... | @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, "grantOfferLe... |
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") @Path... | @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!".getBy... |
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") @Pa... | @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())... |
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... | @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(app... |
GrantOfferLetterTemplatePopulator { public GrantOfferLetterTemplateViewModel populate(long projectId) { ProjectResource projectResource = projectRestService.getProjectById(projectId).getSuccess(); String projectName = projectResource.getName(); long applicationId = projectResource.getApplication(); CompetitionResource ... | @Test public void populate() { long applicationId = 123L; GrantTermsAndConditionsResource tsAndCs = newGrantTermsAndConditionsResource() .withTemplate("Terms and conditions template") .build(); CompetitionResource competition = newCompetitionResource() .withName("Competition name") .withTermsAndConditions(tsAndCs) .bui... |
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 invit... | @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("rese... |
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 invit... | @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("dele... |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public List<BindingResult> validateFormInputResponse(Long applicationId, Long formInputId) { List<BindingResult> results = new ArrayList<>(); List<FormInputResponse> responses = formInputResponseRepositor... | @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 = formInputRespons... |
GrantsInviteController { @GetMapping("/send") public String inviteForm(Model model, @PathVariable long projectId, @ModelAttribute("form") GrantsSendInviteForm form) { List<PartnerOrganisationResource> organisations = partnerOrganisationRestService.getProjectPartnerOrganisations(projectId).getSuccess(); model.addAttribu... | @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.get... |
ManageInvitationsModelPopulator { public ManageInvitationsViewModel populateManageInvitationsViewModel(long projectId) { ProjectResource project = projectService.getById(projectId); List<SentGrantsInviteResource> grants = grantsInviteRestService.getAllForProject(projectId).getSuccess() .stream().filter(grant -> InviteS... | @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<S... |
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-of... | @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())... | @Test public void createUser() throws Exception { when(monitoringOfficerRegistrationRestServiceMock.createMonitoringOfficer(any(MonitoringOfficerCreateResource.class))) .thenReturn(restSuccess()); mockMvc.perform(post("/monitoring-officer/create") .param("emailAddress", "test@test.com") .param("firstName", "Steve") .pa... |
MonitoringOfficerAssignRoleViewModelPopulator { public MonitoringOfficerAssignRoleViewModel populate(long userId) { UserResource userResource = userRestService.retrieveUserById(userId).getSuccess(); return new MonitoringOfficerAssignRoleViewModel( userId, userResource.getFirstName(), userResource.getLastName(), userRes... | @Test public void populate() { UserResource userResource = newUserResource() .withId(999L) .withEmail("email@email.email") .withFirstName("first") .withLastName("last") .build(); when(userRestService.retrieveUserById(999L)).thenReturn(restSuccess(userResource)); MonitoringOfficerAssignRoleViewModel actual = target.popu... |
FinanceChecksViabilityController { @PostMapping(params = "confirm-viability") public String confirmViability(@PathVariable("projectId") Long projectId, @PathVariable("organisationId") Long organisationId, @ModelAttribute("form") FinanceChecksViabilityForm form, @SuppressWarnings("unused") BindingResult bindingResult, V... | @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, Vi... |
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, Va... | @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, Viab... |
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).getSuc... | @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(); UserRes... |
OnHoldController { @PostMapping public String resumeProject(@PathVariable long projectId, @PathVariable long competitionId, UserResource user, RedirectAttributes redirectAttributes) { projectStateRestService.resumeProject(projectId).getSuccess(); redirectAttributes.addFlashAttribute("resumedFromOnHold", true); return u... | @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/{competitio... |
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.g... | @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(pr... |
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("... | @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 = buildSpendProfileTa... |
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,
... | @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}/pr... |
ActivityLogViewModelPopulator { public ActivityLogViewModel populate(long projectId, UserResource user) { ProjectResource project = projectRestService.getProjectById(projectId).getSuccess(); List<PartnerOrganisationResource> partnerOrganisationResources = partnerOrganisationRestService.getProjectPartnerOrganisations(pr... | @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... |
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_INT... | @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(); ActivityLogResou... |
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... | @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> partnerOrganisa... |
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 com... | @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,... |
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.iter... | @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))); unsort... |
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_PATTE... | @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.s... |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public ValidationMessages validateAcademicUpload(Application application, Long markedAsCompleteById) { return getProcessRole(markedAsCompleteById).andOnSuccessReturn(role -> { OrganisationResource organis... | @Test public void validateFormInputResponseWhenIsResearchUser() { Application application = newApplication().withCompetition(newCompetition().withIncludeJesForm(true).build()).build(); long markedAsCompleteById = 4L; long organisationId = 999L; ProcessRole processRole = newProcessRole() .withOrganisationId(organisation... |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public List<ValidationMessages> validateCostItem(Long applicationId, FinanceRowType type, Long markedAsCompleteById) { return getProcessRole(markedAsCompleteById).andOnSuccess(role -> financeService.finan... | @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() .withOrganisati... |
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(absolut... | @Test public void testPathElementsToAbsolutePathElements() { List<String> absolutePath = FileFunctions.pathElementsToAbsolutePathElements(asList("path", "to", "file"), "/"); assertEquals(asList("/path", "to", "file"), absolutePath); }
@Test public void testPathElementsToAbsolutePathElementsButAlreadyAbsolute() { List<S... |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public FinanceRowHandler getCostHandler(FinanceRowItem costItem) { return financeRowCostsService.getCostHandler(costItem.getId()); } @Override List<BindingResult> validateFormInputResponse(Long applicati... | @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); assertE... |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public FinanceRowHandler getProjectCostHandler(FinanceRowItem costItem) { return projectFinanceRowService.getCostHandler(costItem); } @Override List<BindingResult> validateFormInputResponse(Long applicat... | @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.getPr... |
ApplicationValidatorServiceImpl extends BaseTransactionalService implements ApplicationValidatorService { @Override public Boolean isApplicationComplete(Application application) { BigDecimal progressPercentage = applicationProgressService.getApplicationProgress(application.getId()).getSuccess(); return isFinanceOvervie... | @Test public void isApplicationComplete() { long applicationId = 1l; long competitionId = 2l; CompetitionApplicationConfig competitionApplicationConfig = new CompetitionApplicationConfig(); Competition competition = newCompetition() .withId(competitionId) .withMaxResearchRatio(100) .withCompetitionApplicationConfig(com... |
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 userIsConnectedToApplicationResou... | @Test public void usersConnectedToTheApplicationCanView() { assertTrue(rules.usersConnectedToTheApplicationCanView(applicationResource1, leadOnApplication1)); assertTrue(rules.usersConnectedToTheApplicationCanView(applicationResource2, user2)); assertFalse(rules.usersConnectedToTheApplicationCanView(applicationResource... |
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, ... | @Test public void usersConnectedToTheApplicationCanViewInnovationAreas() { assertTrue(rules.usersConnectedToTheApplicationCanViewInnovationAreas(applicationResource1, leadOnApplication1)); assertTrue(rules.usersConnectedToTheApplicationCanViewInnovationAreas(applicationResource2, user2)); assertFalse(rules.usersConnect... |
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 !isInnovationLe... | @Test public void internalUsersOtherThanInnovationLeadAndStakeholderCanViewApplications() { assertTrue(rules.internalUsersCanViewApplications(applicationResource1, compAdmin)); assertTrue(rules.internalUsersCanViewApplications(applicationResource1, projectFinanceUser())); assertFalse(rules.internalUsersCanViewApplicati... |
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... | @Test public void onlyInnovationLeadAssignedCompetitionForApplicationCanAccessApplication() { assertTrue(rules.innovationLeadAssignedToCompetitionCanViewApplications(applicationResource1, innovationLeadOnApplication1)); assertFalse(rules.innovationLeadAssignedToCompetitionCanViewApplications(applicationResource1, innov... |
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) { ret... | @Test public void onlyStakeholdersAssignedToCompetitionForApplicationCanAccessApplication() { when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.stakeholderAssignedToCompetitionCanViewApplications(applicationRe... |
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... | @Test public void onlyCompetitionFinanceUserAssignedToCompetitionForApplicationCanAccessApplication() { when(externalFinanceRepository.existsByCompetitionIdAndUserId(competition.getId(), competitionFinanceUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.competitionFinanceUsersAssignedToCompetition... |
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) ... | @Test public void monitoringOfficerAssignedToProjectCanViewApplications() { assertTrue(rules.monitoringOfficerAssignedToProjectCanViewApplications(applicationResource1, monitoringOfficerOnProjectForApplication1)); assertFalse(rules.monitoringOfficerAssignedToProjectCanViewApplications(applicationResource1, stakeholderU... |
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 shoul... | @Test public void assessorCanSeeTheApplicationFinancesTotals() { assertTrue(rules.assessorCanSeeTheApplicationFinancesTotals(applicationResource1, assessor)); assertFalse(rules.assessorCanSeeTheApplicationFinancesTotals(applicationResource1, user2)); assertFalse(rules.assessorCanSeeTheApplicationFinancesTotals(applicat... |
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 obj... | @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 ... | @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_A... |
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 moni... | @Test public void monitoringOfficerCanSeeApplicationFinanceTotals() { Project project = newProject().build(); when(projectRepository.findOneByApplicationId(anyLong())).thenReturn(project); when(projectMonitoringOfficerRepository.existsByProjectIdAndUserId(project.getId(), monitoringOfficerUser().getId())).thenReturn(tr... |
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 Applic... | @Test public void stakeholdersCanSeeTheResearchParticipantPercentageInApplications() { ApplicationResource applicationResource = newApplicationResource() .withCompetition(competition.getId()) .build(); when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.ge... |
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 competitionFinanceUsersCanSeeTheResearchParticipantPercentageInA... | @Test public void competitionFinanceUsersCanSeeTheResearchParticipantPercentageInApplications() { ApplicationResource applicationResource = newApplicationResource() .withCompetition(competition.getId()) .build(); when(externalFinanceRepository.existsByCompetitionIdAndUserId(competition.getId(), competitionFinanceUserRe... |
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... | @Test public void monitoringOfficersCanSeeTheResearchParticipantPercentageInApplications() { Project project = newProject().build(); when(projectRepository.findOneByApplicationId(anyLong())).thenReturn(project); when(projectMonitoringOfficerRepository.existsByProjectIdAndUserId(project.getId(), monitoringOfficerUser().... |
FileServiceImpl extends RootTransactionalService implements FileService { @Override @Transactional public ServiceResult<Pair<File, FileEntry>> createFile(FileEntryResource resource, Supplier<InputStream> inputStreamSupplier) { return createTemporaryFileForValidation(resource.getName(), inputStreamSupplier).andOnSuccess... | @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 = ... |
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 ba... | @Test public void stakeholdersCanSeeApplicationFinancesTotals() { ApplicationResource applicationResource = newApplicationResource() .withCompetition(competition.getId()) .build(); when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.getId())).thenReturn(tr... |
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 d... | @Test public void competitionFinanceUserCanSeeApplicationFinancesTotals() { ApplicationResource applicationResource = newApplicationResource() .withCompetition(competition.getId()) .build(); when(externalFinanceRepository.existsByCompetitionIdAndUserId(competition.getId(), competitionFinanceUserResourceOnCompetition.ge... |
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) { S... | @Test public void onlyUsersPartOfTheApplicationCanChangeApplicationResource() { assertTrue(rules.applicantCanUpdateApplicationResource(applicationResource1, leadOnApplication1)); assertTrue(rules.applicantCanUpdateApplicationResource(applicationResource1, user2)); assertFalse(rules.applicantCanUpdateApplicationResource... |
ApplicationPermissionRules extends BasePermissionRules { boolean userIsConnectedToApplicationResource(ApplicationResource application, UserResource user) { return processRoleRepository.existsByUserIdAndApplicationId(user.getId(), application.getId()); } @PermissionRule(value = "READ_RESEARCH_PARTICIPATION_PERCENTAGE",... | @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 Applicati... | @Test public void assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess() { assertTrue(rules.assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(applicationResource1, assessor)); assertTrue(rules.assessorCanSeeTheResearchParticipantPercentageInApplicationsTheyAssess(applicationResour... |
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 applicationReso... | @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, Us... | @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 isLead... | @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 ... | @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 ob... | @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 Applicat... | @Test public void internalUsersCanSeeTheResearchParticipantPercentageInApplications() { assertTrue(rules.internalUsersCanSeeTheResearchParticipantPercentageInApplications(applicationResource1, compAdmin)); assertTrue(rules.internalUsersCanSeeTheResearchParticipantPercentageInApplications(applicationResource1, projectFi... |
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... | @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 Setu... | @Test public void projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished() { assertTrue(rules.projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(applicationResource1, projectFinanceUser())); assertFalse(rules.projectFinanceUserCanRemoveAssessorFeedbackThatHasNotYetBeenPublished(applica... |
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 ... | @Test public void internalUserCanUploadAssessorFeedbackToApplicationWhenCompetitionInFundersPanelOrAssessorFeedbackState() { asList(CompetitionStatus.values()).forEach(competitionStatus -> { allGlobalRoleUsers.forEach(user -> { ApplicationResource application = newApplicationResource().withCompetitionStatus(competition... |
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... | @Test public void compAdminCanRemoveAssessorFeedbackThatHasNotYetBeenPublished() { asList(CompetitionStatus.values()).forEach(competitionStatus -> { allGlobalRoleUsers.forEach(user -> { ApplicationResource application = newApplicationResource().withCompetitionStatus(competitionStatus).build(); if (!user.equals(compAdmi... |
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 applicatio... | @Test public void internalUserCanSeeAndDownloadAllAssessorFeedbackAtAnyTime() { asList(CompetitionStatus.values()).forEach(competitionStatus -> { allGlobalRoleUsers.forEach(user -> { Competition competition = newCompetition().withCompetitionStatus(competitionStatus).build(); ApplicationResource application = newApplica... |
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 = ... | @Test public void applicationTeamCanSeeAndDownloadPublishedAssessorFeedbackForTheirApplications() { long competitionId = 123L; ApplicationResource application = newApplicationResource().withCompetition(competitionId).build(); UserResource leadApplicantUser = newUserResource().build(); UserResource collaboratorUser = ne... |
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) { ret... | @Test public void leadApplicantCanUpdateApplicationState() { assertTrue(rules.leadApplicantCanUpdateApplicationState(applicationResource1, leadOnApplication1)); assertFalse(rules.leadApplicantCanUpdateApplicationState(applicationResource1, compAdmin)); assertFalse(rules.leadApplicantCanUpdateApplicationState(applicatio... |
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... | @Test public void compAdminCanUpdateApplicationState() { assertTrue(rules.compAdminCanUpdateApplicationState(applicationResource1, compAdmin)); assertFalse(rules.compAdminCanUpdateApplicationState(applicationResource1, leadOnApplication1)); assertFalse(rules.compAdminCanUpdateApplicationState(applicationResource1, user... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.