src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
DocumentsServiceImpl extends AbstractProjectServiceImpl implements DocumentsService { @Override public ServiceResult<FileAndContents> getFileContents(long projectId, long documentConfigId) { return getProject(projectId).andOnSuccess(project -> { FileEntry fileEntry = getFileEntry(project, documentConfigId); return file...
@Test public void getFileContents() { FileEntryResource fileEntryResource = FileEntryResourceBuilder.newFileEntryResource().build(); Supplier<InputStream> inputStreamSupplier = () -> null; when(fileServiceMock.getFileByFileEntryId(fileEntryId)).thenReturn(serviceSuccess(inputStreamSupplier)); when(fileEntryMapperMock.m...
DocumentsServiceImpl extends AbstractProjectServiceImpl implements DocumentsService { @Override public ServiceResult<FileEntryResource> getFileEntryDetails(long projectId, long documentConfigId) { return getProject(projectId) .andOnSuccessReturn(project -> fileEntryMapper.mapToResource(getFileEntry(project, documentCon...
@Test public void getFileEntryDetails() { FileEntryResource fileEntryResource = FileEntryResourceBuilder.newFileEntryResource().build(); when(fileEntryMapperMock.mapToResource(fileEntry)).thenReturn(fileEntryResource); ServiceResult<FileEntryResource> result = service.getFileEntryDetails(projectId, documentConfigId); a...
DocumentsServiceImpl extends AbstractProjectServiceImpl implements DocumentsService { @Override @Transactional public ServiceResult<Void> deleteDocument(long projectId, long documentConfigId) { return find(getProject(projectId), getCompetitionDocumentConfig(documentConfigId)). andOnSuccess((project, projectDocumentConf...
@Test public void deleteDocumentWhenProjectNotInSetup() { when(projectWorkflowHandlerMock.getState(project)).thenReturn(ProjectState.LIVE); ServiceResult<Void> result = service.deleteDocument(projectId, documentConfigId); assertTrue(result.isFailure()); assertTrue(result.getFailure().is(PROJECT_SETUP_ALREADY_COMPLETE))...
UserPermissionRules { @PermissionRule(value = "UPDATE_USER_EMAIL", description = "System Maintenance update all users email addresses") public boolean systemMaintenanceUserCanUpdateUsersEmailAddresses(UserResource userToUpdate, UserResource user) { return isSystemMaintenanceUser(user); } @PermissionRule(value = "CREAT...
@Test public void systemMaintenanceUserCanUpdateUsersEmailAddresses() { UserResource userResource = newUserResource().withRoleGlobal(APPLICANT).build(); allGlobalRoleUsers.forEach(user -> { if (user.equals(systemMaintenanceUser())) { assertTrue(rules.systemMaintenanceUserCanUpdateUsersEmailAddresses(userResource, user)...
DocumentsServiceImpl extends AbstractProjectServiceImpl implements DocumentsService { @Override @Transactional public ServiceResult<Void> submitDocument(long projectId, long documentConfigId) { return find(getProject(projectId), getCompetitionDocumentConfig(documentConfigId)). andOnSuccess((project, projectDocumentConf...
@Test public void submitDocumentWhenProjectNotInSetup() { when(projectWorkflowHandlerMock.getState(project)).thenReturn(ProjectState.LIVE); ServiceResult<Void> result = service.submitDocument(projectId, documentConfigId); assertTrue(result.isFailure()); assertTrue(result.getFailure().is(PROJECT_SETUP_ALREADY_COMPLETE))...
DocumentsServiceImpl extends AbstractProjectServiceImpl implements DocumentsService { @Override @Transactional public ServiceResult<Void> documentDecision(long projectId, long documentConfigId, ProjectDocumentDecision decision) { return validateProjectDocumentDecision(decision) .andOnSuccess(() -> find(getProject(proje...
@Test public void documentDecisionWhenDecisionInvalid() { ProjectDocumentDecision documentDecision = new ProjectDocumentDecision(); ServiceResult<Void> result = service.documentDecision(projectId, documentConfigId, documentDecision); assertTrue(result.isFailure()); assertTrue(result.getFailure().is(PROJECT_SETUP_PROJEC...
UserPermissionRules { @PermissionRule(value = "UPDATE_USER_EMAIL", description = "Support users can update external users email addresses ") public boolean supportCanUpdateExternalUsersEmailAddresses(UserResource userToUpdate, UserResource user) { return userToUpdate.isExternalUser() && user.hasRole(SUPPORT); } @Permi...
@Test public void supportCanUpdateExternalUsersEmailAddresses() { UserResource externalUser = newUserResource().withRoleGlobal(APPLICANT).build(); UserResource internalUser = newUserResource().withRoleGlobal(IFS_ADMINISTRATOR).build(); allGlobalRoleUsers.forEach(user -> { if (user.hasRole(SUPPORT)) { assertTrue(rules.s...
BankDetailsPermissionRules extends BasePermissionRules { @PermissionRule( value = "READ", description = "Partners can see their own organisations bank details") public boolean partnersCanSeeTheirOwnOrganisationsBankDetails(BankDetailsResource bankDetailsResource, UserResource user) { return isPartner(bankDetailsResourc...
@Test public void partnersCanSeeBankDetailsOfTheirOwnOrg() { when(projectUserRepository.findByProjectIdAndUserIdAndRoleIsIn(project.getId(), user.getId(), PROJECT_USER_ROLES.stream().collect(Collectors.toList()))).thenReturn(partnerProjectUser); when(projectUserRepository.findFirstByProjectIdAndUserIdAndOrganisationIdA...
BankDetailsPermissionRules extends BasePermissionRules { @PermissionRule( value = "SUBMIT", description = "Partners can submit their own organisations bank details") public boolean partnersCanSubmitTheirOwnOrganisationsBankDetails(BankDetailsResource bankDetailsResource, UserResource user) { return isPartner(bankDetail...
@Test public void partnersCanUpdateTheirOwnOrganisationBankDetails() { when(projectProcessRepository.findOneByTargetId(project.getId())).thenReturn(projectProcess); when(projectUserRepository.findByProjectIdAndUserIdAndRoleIsIn(project.getId(), user.getId(), PROJECT_USER_ROLES.stream().collect(Collectors.toList()))).th...
BankDetailsPermissionRules extends BasePermissionRules { @PermissionRule( value = "READ", description = "Project finance user can see all bank details on all projects") public boolean projectFinanceUsersCanSeeAllBankDetailsOnAllProjects(BankDetailsResource bankDetailsResource, UserResource user) { return isProjectFinan...
@Test public void projectFinanceUserCanSeeAllBankDetailsForAllOrganisations() { assertTrue(rules.projectFinanceUsersCanSeeAllBankDetailsOnAllProjects(bankDetailsResource, projectFinanceUser)); }
BankDetailsPermissionRules extends BasePermissionRules { @PermissionRule( value = "UPDATE", description = "Project finance users can update any organisations bank details") public boolean projectFinanceUsersCanUpdateAnyOrganisationsBankDetails(BankDetailsResource bankDetailsResource, UserResource user) { return isProje...
@Test public void projectFinanceUserCanUpdateBankDetailsForAllOrganisations() { when(projectProcessRepository.findOneByTargetId(project.getId())).thenReturn(projectProcess); assertTrue(rules.projectFinanceUsersCanUpdateAnyOrganisationsBankDetails(bankDetailsResource, projectFinanceUser)); }
CompetitionsBankDetailsController { @GetMapping("/pending-bank-details-approvals") public RestResult<List<BankDetailsReviewResource>> getPendingBankDetailsApprovals() { return bankDetailsService.getPendingBankDetailsApprovals().toGetResponse(); } @GetMapping("/pending-bank-details-approvals") RestResult<List<BankDetai...
@Test public void getPendingBankDetailsApprovals() throws Exception { List<BankDetailsReviewResource> pendingBankDetails = singletonList(new BankDetailsReviewResource(1L, 11L, "Comp1", 12L, "project1", 22L, "Org1")); when(bankDetailsServiceMock.getPendingBankDetailsApprovals()).thenReturn(serviceSuccess(pendingBankDeta...
UserPermissionRules { @PermissionRule(value = "UPDATE_USER_EMAIL", description = "IFS admins can update all users email addresses") public boolean ifsAdminCanUpdateAllEmailAddresses(UserResource userToUpdate, UserResource user) { return user.hasRole(IFS_ADMINISTRATOR); } @PermissionRule(value = "CREATE", description =...
@Test public void ifsAdminCanUpdateAllEmailAddresses() { UserResource userResource = newUserResource().withRoleGlobal(APPLICANT).build(); allGlobalRoleUsers.forEach(user -> { if (user.hasRole(IFS_ADMINISTRATOR)) { assertTrue(rules.ifsAdminCanUpdateAllEmailAddresses(userResource, user)); } else { assertFalse(rules.ifsAd...
CompetitionsBankDetailsController { @GetMapping("/count-pending-bank-details-approvals") public RestResult<Long> countPendingBankDetailsApprovals() { return bankDetailsService.countPendingBankDetailsApprovals().toGetResponse(); } @GetMapping("/pending-bank-details-approvals") RestResult<List<BankDetailsReviewResource>...
@Test public void countPendingBankDetailsApprovals() throws Exception { Long pendingBankDetailsCount = 8L; when(bankDetailsServiceMock.countPendingBankDetailsApprovals()).thenReturn(serviceSuccess(pendingBankDetailsCount)); mockMvc.perform(get("/competitions/count-pending-bank-details-approvals")) .andExpect(status().i...
BankDetailsServiceImpl implements BankDetailsService { @Override public ServiceResult<BankDetailsResource> getByProjectAndOrganisation(Long projectId, Long organisationId) { return find(bankDetailsRepository.findByProjectIdAndOrganisationId(projectId, organisationId), new Error(BANK_DETAILS_DONT_EXIST_FOR_GIVEN_PROJECT...
@Test public void getBankDetailsByProjectAndOrganisation() { when(bankDetailsRepositoryMock.findByProjectIdAndOrganisationId(project.getId(), organisation.getId())).thenReturn(Optional.of(bankDetails)); when(bankDetailsMapperMock.mapToResource(bankDetails)).thenReturn(bankDetailsResource); ServiceResult<BankDetailsReso...
BankDetailsServiceImpl implements BankDetailsService { @Override @Transactional public ServiceResult<Void> submitBankDetails(ProjectOrganisationCompositeId projectOrganisationCompositeId, BankDetailsResource bankDetailsResource) { return bankDetailsDontExist(bankDetailsResource.getProject(), bankDetailsResource.getOrga...
@Test public void saveValidBankDetails() { ValidationResult validationResult = new ValidationResult(); validationResult.setCheckPassed(true); when(silExperianEndpointMock.validate(silBankDetails)).thenReturn(serviceSuccess(validationResult)); VerificationResult verificationResult = new VerificationResult(); when(silExp...
BankDetailsServiceImpl implements BankDetailsService { @Override @Transactional public ServiceResult<Void> updateBankDetails(ProjectOrganisationCompositeId projectOrganisationCompositeId, BankDetailsResource bankDetailsResource) { Address address = toExperianAddressFormat(bankDetailsResource.getAddress()); AccountDetai...
@Test public void updateOfBankDetailsWithExistingBankDetailsPresent() { when(bankDetailsRepositoryMock.findByProjectIdAndOrganisationId(bankDetailsResource.getProject(), bankDetailsResource.getOrganisation())).thenReturn(Optional.of(bankDetails)); when(projectDetailsWorkflowHandlerMock.isSubmitted(project)).thenReturn(...
UserPermissionRules { @PermissionRule(value = "DEACTIVATE", description = "A Support user can deactivate external Users") public boolean supportUserCanDeactivateExternalUsers(UserResource userToDeactivate, UserResource user) { return userToDeactivate.isExternalUser() && user.hasRole(SUPPORT); } @PermissionRule(value =...
@Test public void supportUserCanDeactivateExternalUsers() { UserResource externalUser = newUserResource().withRoleGlobal(APPLICANT).build(); UserResource internalUser = newUserResource().withRoleGlobal(IFS_ADMINISTRATOR).build(); allGlobalRoleUsers.forEach(user -> { if (user.hasRole(SUPPORT)) { assertTrue(rules.support...
BankDetailsServiceImpl implements BankDetailsService { @Override public ServiceResult<ProjectBankDetailsStatusSummary> getProjectBankDetailsStatusSummary(Long projectId) { Project project = projectRepository.findById(projectId).get(); ProcessRole leadProcessRole = project.getApplication().getLeadApplicantProcessRole();...
@Test public void getProjectBankDetailsStatusSummary() { Long projectId = 123L; Competition competition = newCompetition().withName("Greener Jet Engines").build(); Application application = newApplication().withCompetition(competition).build(); organisation.setOrganisationType(newOrganisationType().withOrganisationType...
BankDetailsServiceImpl implements BankDetailsService { @Override public ServiceResult<List<BankDetailsReviewResource>> getPendingBankDetailsApprovals() { List<BankDetailsReviewResource> pendingBankDetails = bankDetailsRepository.getPendingBankDetailsApprovalsForProjectStateNotIn(asList(WITHDRAWN, HANDLED_OFFLINE, COMPL...
@Test public void getPendingBankDetailsApprovals() { List<BankDetailsReviewResource> pendingBankDetails = singletonList(new BankDetailsReviewResource( 1L, 11L, "Comp1", 12L, "project1", 22L, "Org1")); when(bankDetailsRepositoryMock.getPendingBankDetailsApprovalsForProjectStateNotIn(asList(WITHDRAWN, HANDLED_OFFLINE, CO...
BankDetailsServiceImpl implements BankDetailsService { @Override public ServiceResult<Long> countPendingBankDetailsApprovals() { Long countBankDetails = bankDetailsRepository.countPendingBankDetailsApprovalsForProjectStateNotIn(asList(WITHDRAWN, HANDLED_OFFLINE, COMPLETED_OFFLINE)); return serviceSuccess(countBankDetai...
@Test public void countPendingBankDetailsApprovals() { Long pendingBankDetailsCount = 8L; when(bankDetailsRepositoryMock.countPendingBankDetailsApprovalsForProjectStateNotIn(asList(WITHDRAWN, HANDLED_OFFLINE, COMPLETED_OFFLINE))).thenReturn(pendingBankDetailsCount); ServiceResult<Long> result = service.countPendingBank...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "UPLOAD_SIGNED_GRANT_OFFER", description = "Project manager or Lead partner can upload signed grant offer letter") public boolean leadPartnerCanUploadGrantOfferLetter(ProjectResource project, UserResource user) { return isLeadPartner...
@Test public void leadPartnersCanCreateSignedGrantOfferLetter() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource() .withProjectState(ProjectState.SETUP) .build(); setupUserAsLeadPartner(project, user); when(projectProcessRepository.findOneByTargetId(project.getId())).thenRet...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "UPLOAD_SIGNED_GRANT_OFFER", description = "Project manager or Lead partner can upload signed grant offer letter") public boolean projectManagerCanUploadGrantOfferLetter(ProjectResource project, UserResource user) { return isProjectM...
@Test public void projectManagerCanCreateSignedGrantOfferLetter() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource() .withProjectState(ProjectState.SETUP) .build(); setUpUserAsProjectManager(project, user); when(projectProcessRepository.findOneByTargetId(project.getId())).th...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER", description = "Partners can view grant offer documents (Unsigned grant offer, signed grant offer, Additional contract)") public boolean partnersCanViewGrantOfferLetter(ProjectResource project, UserResource user) {...
@Test public void partnersCanViewGrantOfferLetterDetails() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); setupUserAsPartner(project, user); assertTrue(rules.partnersCanViewGrantOfferLetter(project, user)); } @Test public void nonPartnersCannotViewGrantOfferLett...
UserPermissionRules { @PermissionRule(value = "ACTIVATE", description = "A Support user can reactivate external Users") public boolean supportUserCanReactivateExternalUsers(UserResource userToActivate, UserResource user) { return userToActivate.isExternalUser() && user.hasRole(SUPPORT); } @PermissionRule(value = "CREA...
@Test public void supportUserCanReactivateExternalUsers() { UserResource externalUser = newUserResource().withRoleGlobal(APPLICANT).build(); UserResource internalUser = newUserResource().withRoleGlobal(IFS_ADMINISTRATOR).build(); allGlobalRoleUsers.forEach(user -> { if (user.hasRole(SUPPORT)) { assertTrue(rules.support...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "DOWNLOAD_GRANT_OFFER", description = "Partners can download grant offer documents (Unsigned grant offer, signed grant offer, Additional contract)") public boolean partnersCanDownloadGrantOfferLetter(ProjectResource project, UserReso...
@Test public void partnersCanDownloadGrantOfferLetterDocuments() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); setupUserAsPartner(project, user); assertTrue(rules.partnersCanDownloadGrantOfferLetter(project, user)); } @Test public void nonPartnersCannotDownload...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "DOWNLOAD_GRANT_OFFER", description = "Competitions team & Project Finance can download grant offer documents (Unsigned grant offer, signed grant offer, Additional contract)") public boolean internalUsersCanDownloadGrantOfferLetter(P...
@Test public void compAdminsCanDownloadGrantOfferLetterDocuments() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); setUpUserAsCompAdmin(project, user); assertTrue(rules.internalUsersCanDownloadGrantOfferLetter(project, user)); } @Test public void nonCompAdminsCan...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER", description = "Competitions team & Project Finance can view grant offer documents (Unsigned grant offer, signed grant offer, Additional contract)") public boolean internalUsersCanViewGrantOfferLetter(ProjectResour...
@Test public void compAdminsCanViewGrantOfferLetterDocuments() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); setUpUserAsCompAdmin(project, user); assertTrue(rules.internalUsersCanViewGrantOfferLetter(project, user)); } @Test public void nonCompAdminsCannotViewG...
UserPermissionRules { @PermissionRule(value = "AGREE_TERMS", description = "A user can accept the site terms and conditions") public boolean usersCanAgreeSiteTermsAndConditions(UserResource userToUpdate, UserResource user) { return userToUpdate.getId().equals(user.getId()); } @PermissionRule(value = "CREATE", descript...
@Test public void usersCanAgreeSiteTermsAndConditionsForThemselves() { allGlobalRoleUsers.forEach(user -> allGlobalRoleUsers.forEach(otherUser -> { if (user.equals(otherUser)) { assertTrue(rules.usersCanAgreeSiteTermsAndConditions(otherUser, user)); } else { assertFalse(rules.usersCanAgreeSiteTermsAndConditions(otherUs...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "SUBMIT_GRANT_OFFER_LETTER", description = "Project manager can submit the grant offer letter, or get details to do so with DocuSign") public boolean projectManagerSubmitGrantOfferLetter(ProjectCompositeId projectCompositeId, UserRes...
@Test public void projectManagerCanSubmitOfferLetter() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource() .withProjectState(ProjectState.SETUP) .build(); setUpUserAsProjectManager(project, user); when(projectProcessRepository.findOneByTargetId(project.getId())).thenReturn(pr...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "APPROVE_SIGNED_GRANT_OFFER_LETTER", description = "Internal users can approve the signed Grant Offer Letter") public boolean internalUsersCanApproveOrRejectSignedGrantOfferLetter(ProjectResource project, UserResource user) { return ...
@Test public void compAdminsCanApproveSignedGrantOfferLetters() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource() .withProjectState(ProjectState.SETUP) .build(); setUpUserAsCompAdmin(project, user); when(projectProcessRepository.findOneByTargetId(project.getId())).thenRetur...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "DELETE_SIGNED_GRANT_OFFER", description = "Lead partner can delete signed grant offer letter") public boolean leadPartnerCanDeleteSignedGrantOfferLetter(ProjectResource project, UserResource user) { return isLeadPartner(project.getI...
@Test public void leadPartnerCanDeleteSignedGrantOfferLetter() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource() .withProjectState(ProjectState.SETUP) .build(); setupUserAsLeadPartner(project, user); when(projectProcessRepository.findOneByTargetId(project.getId())).thenRetu...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "SEND_GRANT_OFFER_LETTER", description = "Internal users can send the Grant Offer Letter notification") public boolean internalUserCanSendGrantOfferLetter(ProjectResource project, UserResource user) { return isInternal(user) && isPro...
@Test public void projectFinanceUserCanSendGrantOfferLetter() { ProjectResource project = newProjectResource() .withProjectState(ProjectState.SETUP) .build(); when(projectProcessRepository.findOneByTargetId(project.getId())).thenReturn(projectProcess); assertTrue(rules.internalUserCanSendGrantOfferLetter(project, proje...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER_LETTER_SEND_STATUS", description = "Internal users can view the send status of Grant Offer Letter for a project") public boolean internalAdminUserCanViewSendGrantOfferLetterStatus(ProjectResource project, UserResour...
@Test public void internalUserCanViewSendGrantOfferLetterStatus() { ProjectResource project = newProjectResource().build(); allGlobalRoleUsers.forEach(user -> { if (user.equals(projectFinanceUser()) || user.equals(compAdminUser())) { assertTrue(rules.internalAdminUserCanViewSendGrantOfferLetterStatus(project, user)); }...
UserPermissionRules { @PermissionRule(value = "GRANT_ROLE", description = "An assessor can request applicant role") public boolean assessorCanRequestApplicantRole(GrantRoleCommand roleCommand, UserResource user) { return roleCommand.getTargetRole().equals(APPLICANT) && user.getId().equals(roleCommand.getUserId()) && us...
@Test public void assessorCanRequestApplicantRole() { UserResource otherAssessor = newUserResource().withRolesGlobal(singletonList(ASSESSOR)).build(); assertFalse(rules.assessorCanRequestApplicantRole(new GrantRoleCommand(assessorUser().getId(), APPLICANT), compAdminUser())); assertFalse(rules.assessorCanRequestApplica...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER_LETTER_SEND_STATUS", description = "Partners can view the send status of Grant Offer Letter for a project") public boolean externalUserCanViewSendGrantOfferLetterStatus(ProjectResource project, UserResource user) { ...
@Test public void partnersCanViewSendGrantOfferLetterStatus() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); setupUserAsPartner(project, user); assertTrue(rules.externalUserCanViewSendGrantOfferLetterStatus(project, user)); } @Test public void nonPartnersCannotV...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER_LETTER_SEND_STATUS", description = "Support users can view the send status of Grant Offer Letter for a project") public boolean supportUserCanViewSendGrantOfferLetterStatus(ProjectResource project, UserResource user...
@Test public void supportUserCanViewSendGrantOfferLetterStatus() { ProjectResource project = newProjectResource().build(); allGlobalRoleUsers.forEach(user -> { if (user.equals(supportUser())) { assertTrue(rules.supportUserCanViewSendGrantOfferLetterStatus(project, user)); } else { assertFalse(rules.supportUserCanViewSe...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER_LETTER_SEND_STATUS", description = "Stakeholders view the send status of Grant Offer Letter for a project from competition assigned to them") public boolean stakeholdersCanViewSendGrantOfferLetterStatus(ProjectResou...
@Test public void onlyStakeholdersAssignedToCompetitionCanViewSendGrantOfferLetterStatus() { when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.stakeholdersCanViewSendGrantOfferLetterStatus(projectResource1, st...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "DOWNLOAD_GRANT_OFFER", description = "Support users can download grant offer documents (Unsigned grant offer, signed grant offer, Additional contract)") public boolean supportUsersCanDownloadGrantOfferLetter(ProjectResource project,...
@Test public void supportUsersCanDownloadGrantOfferLetter() { ProjectResource project = newProjectResource().build(); allGlobalRoleUsers.forEach(user -> { if (user.equals(supportUser())) { assertTrue(rules.supportUsersCanDownloadGrantOfferLetter(project, user)); } else { assertFalse(rules.supportUsersCanDownloadGrantOf...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "DOWNLOAD_GRANT_OFFER", description = "Innovation lead users can download grant offer documents (Unsigned grant offer, signed grant offer, Additional contract), of projects from competition assigned to them") public boolean innovatio...
@Test public void onlyInnovationLeadUsersAssignedToCompetitionCanDownloadGrantOfferLetter() { assertTrue(rules.innovationLeadUsersCanDownloadGrantOfferLetter(projectResource1, innovationLeadUserResourceOnProject1)); assertFalse(rules.innovationLeadUsersCanDownloadGrantOfferLetter(projectResource1, innovationLeadUser())...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "DOWNLOAD_GRANT_OFFER", description = "Stakeholders can download grant offer documents (Unsigned grant offer, signed grant offer, Additional contract), of projects from competition assigned to them") public boolean stakeholdersCanDow...
@Test public void onlyStakeholdersAssignedToCompetitionCanDownloadGrantOfferLetter() { when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.stakeholdersCanDownloadGrantOfferLetter(projectResource1, stakeholderUse...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER", description = "Innovation lead users can view grant offer documents (Unsigned grant offer, signed grant offer, Additional contract), of projects from competition assigned to them") public boolean innovationLeadUse...
@Test public void onlyInnovationLeadUsersAssignedToCompetitionCanViewGrantOfferLetter() { assertTrue(rules.innovationLeadUsersCanViewGrantOfferLetter(projectResource1, innovationLeadUserResourceOnProject1)); assertFalse(rules.innovationLeadUsersCanViewGrantOfferLetter(projectResource1, innovationLeadUser())); }
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER", description = "Stakeholders can view grant offer documents (Unsigned grant offer, signed grant offer, Additional contract), of projects from competition assigned to them") public boolean stakeholdersCanViewGrantOf...
@Test public void onlyStakeholdersAssignedToCompetitionCanViewGrantOfferLetter() { when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.stakeholdersCanViewGrantOfferLetter(projectResource1, stakeholderUserResourc...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER", description = "Monitoring officer can view grant offer documents (Unsigned grant offer, signed grant offer, Additional contract), of projects from competition assigned to them") public boolean monitoringOfficerCan...
@Test public void monitoringOfficersCanViewGrantOfferLetterOnTheirProjects() { when(projectMonitoringOfficerRepository.existsByProjectIdAndUserId(projectResource1.getId(), monitoringOfficerUser().getId())).thenReturn(true); assertTrue(rules.monitoringOfficerCanViewGrantOfferLetter(projectResource1, monitoringOfficerUse...
UserPermissionRules { @PermissionRule(value = "GRANT_ROLE", description = "An stakeholder can request applicant role") public boolean stakeholderCanRequestApplicantRole(GrantRoleCommand roleCommand, UserResource user) { return roleCommand.getTargetRole().equals(APPLICANT) && user.getId().equals(roleCommand.getUserId())...
@Test public void stakeholderCanRequestApplicantRole() { UserResource otherStakeholder = newUserResource().withRolesGlobal(singletonList(STAKEHOLDER)).build(); assertFalse(rules.stakeholderCanRequestApplicantRole(new GrantRoleCommand(stakeholderUser().getId(), APPLICANT), compAdminUser())); assertFalse(rules.stakeholde...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER_LETTER_SEND_STATUS", description = "Monitoring officers can view the send status of Grant Offer Letter for a project") public boolean monitoringOfficerCanViewSendGrantOfferLetterStatus(ProjectResource project, UserR...
@Test public void monitoringOfficersCanViewSendGrantOfferLetterOnTheirProjects() { when(projectMonitoringOfficerRepository.existsByProjectIdAndUserId(projectResource1.getId(), monitoringOfficerUser().getId())).thenReturn(true); assertTrue(rules.monitoringOfficerCanViewSendGrantOfferLetterStatus(projectResource1, monito...
GrantOfferLetterPermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_GRANT_OFFER", description = "Support users can view grant offer documents (Unsigned grant offer, signed grant offer, Additional contract)") public boolean supportUsersCanViewGrantOfferLetter(ProjectResource project, UserResourc...
@Test public void supportUsersCanViewGrantOfferLetter() { ProjectResource project = newProjectResource().build(); allGlobalRoleUsers.forEach(user -> { if (user.equals(supportUser())) { assertTrue(rules.supportUsersCanViewGrantOfferLetter(project, user)); } else { assertFalse(rules.supportUsersCanViewGrantOfferLetter(pr...
GrantOfferLetterController { @GetMapping("/{projectId}/signed-grant-offer") public @ResponseBody ResponseEntity<Object> getGrantOfferLetterFileContents( @PathVariable("projectId") long projectId) throws IOException { return fileControllerUtils.handleFileDownload(() -> grantOfferLetterService.getSignedGrantOfferLetterFi...
@Test public void getGrantOfferLetterFileContents() throws Exception { Function<GrantOfferLetterService, ServiceResult<FileAndContents>> serviceCallToUpload = (service) -> service.getGrantOfferLetterFileAndContents(projectId); assertGetFileContents("/project/{projectId}/grant-offer", new Object[] {projectId}, emptyMap(...
GrantOfferLetterController { @GetMapping("/{projectId}/additional-contract") public @ResponseBody ResponseEntity<Object> getAdditionalContractFileContents( @PathVariable("projectId") long projectId) throws IOException { return fileControllerUtils.handleFileDownload(() -> grantOfferLetterService.getAdditionalContractFil...
@Test public void getAdditionalContractFileContents() throws Exception { Function<GrantOfferLetterService, ServiceResult<FileAndContents>> serviceCallToUpload = (service) -> service.getAdditionalContractFileAndContents(projectId); assertGetFileContents("/project/{projectId}/additional-contract", new Object[] {projectId...
GrantOfferLetterController { @GetMapping(value = "/{projectId}/grant-offer/details", produces = "application/json") public RestResult<FileEntryResource> getGrantOfferLetterFileEntryDetails( @PathVariable("projectId") long projectId) throws IOException { return grantOfferLetterService.getGrantOfferLetterFileEntryDetails...
@Test public void getGrantOfferLetterFileEntryDetails() throws Exception { Function<GrantOfferLetterService, ServiceResult<FileEntryResource>> serviceCallToUpload = (service) -> service.getSignedGrantOfferLetterFileEntryDetails(projectId); assertGetFileDetails("/project/{projectId}/signed-grant-offer/details", new Obje...
GrantOfferLetterController { @GetMapping(value = "/{projectId}/additional-contract/details", produces = "application/json") public RestResult<FileEntryResource> getAdditionalContractFileEntryDetails( @PathVariable("projectId") long projectId) throws IOException { return grantOfferLetterService.getAdditionalContractFile...
@Test public void getAdditionalContractFileEntryDetails() throws Exception { Function<GrantOfferLetterService, ServiceResult<FileEntryResource>> serviceCallToUpload = (service) -> service.getAdditionalContractFileEntryDetails(projectId); assertGetFileDetails("/project/{projectId}/additional-contract/details", new Objec...
GrantOfferLetterController { @PostMapping(value = "/{projectId}/additional-contract", produces = "application/json") public RestResult<FileEntryResource> addAdditionalContractFile( @RequestHeader(value = "Content-Type", required = false) String contentType, @RequestHeader(value = "Content-Length", required = false) Str...
@Test public void addAdditionalContractFile() throws Exception { BiFunction<GrantOfferLetterService, FileEntryResource, ServiceResult<FileEntryResource>> serviceCallToUpload = (service, fileToUpload) -> service.createAdditionalContractFileEntry(eq(projectId), eq(fileToUpload), fileUploadInputStreamExpectations()); asse...
GrantOfferLetterController { @DeleteMapping(value = "/{projectId}/grant-offer", produces = "application/json") public RestResult<Void> removeGrantOfferLetterFile(@PathVariable(value = "projectId") long projectId) { return grantOfferLetterService.removeGrantOfferLetterFileEntry(projectId).toDeleteResponse(); } @GetMapp...
@Test public void removeGrantOfferLetterFile() throws Exception { when(grantOfferLetterService.removeGrantOfferLetterFileEntry(projectId)).thenReturn(serviceSuccess()); mockMvc.perform(delete("/project/{projectId}/grant-offer", projectId)). andExpect(status().isNoContent()). andDo(document("project/{method-name}")); }
GrantOfferLetterController { @DeleteMapping(value = "/{projectId}/grant-offer/reset") public RestResult<Void> resetGrantOfferLetter( @PathVariable long projectId) { return grantOfferLetterService.resetGrantOfferLetter(projectId).toDeleteResponse(); } @GetMapping("/{projectId}/signed-grant-offer") @ResponseBody Respons...
@Test public void resetGrantOfferLetter() throws Exception { when(grantOfferLetterService.resetGrantOfferLetter(projectId)).thenReturn(serviceSuccess()); mockMvc.perform(delete("/project/{projectId}/grant-offer/reset", projectId)). andExpect(status().isNoContent()). andDo(document("project/{method-name}")); }
GrantOfferLetterController { @DeleteMapping(value = "/{projectId}/signed-grant-offer-letter", produces = "application/json") public RestResult<Void> removeSignedGrantOfferLetterFile(@PathVariable(value = "projectId") long projectId) { return grantOfferLetterService.removeSignedGrantOfferLetterFileEntry(projectId).toDel...
@Test public void removeSignedGrantOfferLetterFile() throws Exception { when(grantOfferLetterService.removeSignedGrantOfferLetterFileEntry(projectId)).thenReturn(serviceSuccess()); mockMvc.perform(delete("/project/{projectId}/signed-grant-offer-letter", projectId)). andExpect(status().isNoContent()). andDo(document("pr...
UserPermissionRules { @PermissionRule(value = "GRANT_ROLE", description = "An monitoring officer can request applicant role") public boolean monitoringOfficerCanRequestApplicantRole(GrantRoleCommand roleCommand, UserResource user) { return roleCommand.getTargetRole().equals(APPLICANT) && user.getId().equals(roleCommand...
@Test public void monitoringOfficerCanRequestApplicantRole() { UserResource otherMonitoringOfficer = newUserResource().withRolesGlobal(singletonList(MONITORING_OFFICER)).build(); assertFalse(rules.monitoringOfficerCanRequestApplicantRole(new GrantRoleCommand(monitoringOfficerUser().getId(), APPLICANT), compAdminUser())...
SilEmailService implements EmailService { @Override public ServiceResult<List<EmailAddress>> sendEmail(EmailAddress from, List<EmailAddress> to, String subject, String plainTextBodyContent, String htmlBodyContent) { SilEmailAddress fromEmail = new SilEmailAddress(from.getName(), from.getEmailAddress()); List<SilEmailAd...
@Test public void testSendEmail() { EmailAddress from = newEmailAddressResource().with(name("From User")).withEmail("from@email.com").build(); List<EmailAddress> to = newEmailAddressResource().with(names("To User 1", "To User 2")).withEmail("to1@email.com", "to2@email.com").build(2); SilEmailAddress silEmailFrom = new ...
GrantOfferLetterController { @PostMapping("/{projectId}/signed-grant-offer-letter/approval") public RestResult<Void> approveOrRejectSignedGrantOfferLetter(@PathVariable("projectId") final Long projectId, @RequestBody final GrantOfferLetterApprovalResource grantOfferLetterApprovalResource) { return grantOfferLetterServi...
@Test public void approveOrRejectSignedGrantOfferLetter() throws Exception { GrantOfferLetterApprovalResource grantOfferLetterApprovalResource = new GrantOfferLetterApprovalResource(ApprovalType.APPROVED, null); when(grantOfferLetterService.approveOrRejectSignedGrantOfferLetter(projectId, grantOfferLetterApprovalResour...
GrantOfferLetterController { @GetMapping("/{projectId}/grant-offer-letter/current-state") public RestResult<GrantOfferLetterStateResource> getGrantOfferLetterState(@PathVariable("projectId") final Long projectId) { return grantOfferLetterService.getGrantOfferLetterState(projectId).toGetResponse(); } @GetMapping("/{pro...
@Test public void getGrantOfferLetterState() throws Exception { GrantOfferLetterStateResource stateInformation = stateInformationForNonPartnersView(GrantOfferLetterState.APPROVED, GOL_SIGNED); when(grantOfferLetterService.getGrantOfferLetterState(projectId)).thenReturn(serviceSuccess(stateInformation)); mockMvc.perform...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<FileEntryResource> createSignedGrantOfferLetterFileEntry(Long projectId, FileEntryResource fileEntryResource, Supplier<InputStream> inputStreamSupplier) { return getProject(pro...
@Test public void createSignedGrantOfferLetterFileEntry() { assertCreateFile( project::getSignedGrantOfferLetter, (fileToCreate, inputStreamSupplier) -> service.createSignedGrantOfferLetterFileEntry(123L, fileToCreate, inputStreamSupplier)); }
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<FileEntryResource> createGrantOfferLetterFileEntry(Long projectId, FileEntryResource fileEntryResource, Supplier<InputStream> inputStreamSupplier) { return getProject(projectId...
@Test public void createGrantOfferLetterFileEntry() { assertCreateFile( project::getGrantOfferLetter, (fileToCreate, inputStreamSupplier) -> service.createGrantOfferLetterFileEntry(123L, fileToCreate, inputStreamSupplier)); }
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<FileEntryResource> createAdditionalContractFileEntry(Long projectId, FileEntryResource fileEntryResource, Supplier<InputStream> inputStreamSupplier) { return getProject(project...
@Test public void createAdditionalContractFileEntry() { assertCreateFile( project::getAdditionalContractFile, (fileToCreate, inputStreamSupplier) -> service.createAdditionalContractFileEntry(123L, fileToCreate, inputStreamSupplier)); }
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override public ServiceResult<FileEntryResource> getAdditionalContractFileEntryDetails(Long projectId) { return getProject(projectId).andOnSuccess(project -> { FileEntry fileEntry = project.getAdditionalContractFile(); if...
@Test public void getAdditionalContractFileEntryDetails() { assertGetFileDetails( project::setAdditionalContractFile, () -> service.getAdditionalContractFileEntryDetails(123L)); }
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override public ServiceResult<FileEntryResource> getGrantOfferLetterFileEntryDetails(Long projectId) { return getProject(projectId).andOnSuccess(project -> { FileEntry fileEntry = project.getGrantOfferLetter(); if (fileEn...
@Test public void getGrantOfferLetterFileEntryDetails() { assertGetFileDetails( project::setGrantOfferLetter, () -> service.getGrantOfferLetterFileEntryDetails(123L)); }
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override public ServiceResult<FileEntryResource> getSignedGrantOfferLetterFileEntryDetails(Long projectId) { return getProject(projectId).andOnSuccess(project -> { FileEntry fileEntry = project.getSignedGrantOfferLetter()...
@Test public void getSignedGrantOfferLetterFileEntryDetails() { assertGetFileDetails( project::setSignedGrantOfferLetter, () -> service.getSignedGrantOfferLetterFileEntryDetails(123L)); }
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override public ServiceResult<FileAndContents> getAdditionalContractFileAndContents(Long projectId) { return getProject(projectId).andOnSuccess(project -> { FileEntry fileEntry = project.getAdditionalContractFile(); retur...
@Test public void getAdditionalContractFileContents() { assertGetFileContents( project::setAdditionalContractFile, () -> service.getAdditionalContractFileAndContents(123L)); }
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override public ServiceResult<FileAndContents> getGrantOfferLetterFileAndContents(Long projectId) { return getProject(projectId).andOnSuccess(project -> { FileEntry fileEntry = project.getGrantOfferLetter(); return getFil...
@Test public void getGrantOfferLetterFileContents() { assertGetFileContents( project::setGrantOfferLetter, () -> service.getGrantOfferLetterFileAndContents(123L)); }
UserPermissionRules { @PermissionRule(value = "GRANT_ROLE", description = "An admin user can grant monitoring officer role") public boolean isGrantingMonitoringOfficerRoleAndHasPermission(GrantRoleCommand roleCommand, UserResource user) { return hasPermissionToGrantRole(user) && roleCommand.getTargetRole().equals(MONIT...
@Test public void correctRolesCanGrantMonitoringOfficerRole() { GrantRoleCommand grantMonitoringOfficerRole = new GrantRoleCommand(assessorUser().getId(), MONITORING_OFFICER); assertTrue(rules.isGrantingMonitoringOfficerRoleAndHasPermission(grantMonitoringOfficerRole, compAdminUser())); assertTrue(rules.isGrantingMonit...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override public ServiceResult<FileAndContents> getSignedGrantOfferLetterFileAndContents(Long projectId) { return getProject(projectId).andOnSuccess(project -> { FileEntry fileEntry = project.getSignedGrantOfferLetter(); r...
@Test public void getSignedGrantOfferLetterFileContents() { assertGetFileContents( project::setSignedGrantOfferLetter, () -> service.getSignedGrantOfferLetterFileAndContents(123L)); }
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<Void> updateSignedGrantOfferLetterFile(Long projectId, FileEntryResource fileEntryResource, Supplier<InputStream> inputStreamSupplier) { return getProject(projectId).andOnSucce...
@Test public void updateSignedGrantOfferLetterFileEntry() { when(golWorkflowHandler.isSent(any())).thenReturn(true); when(projectWorkflowHandler.getState(project)).thenReturn(SETUP); assertUpdateFile( project::getSignedGrantOfferLetter, (fileToUpdate, inputStreamSupplier) -> service.updateSignedGrantOfferLetterFile(123...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<Void> submitGrantOfferLetter(Long projectId) { return getProject(projectId).andOnSuccess(project -> { if (project.getSignedGrantOfferLetter() == null) { return serviceFailure(C...
@Test public void submitGrantOfferLetterFailureNoSignedGolFile() { ServiceResult<Void> result = service.submitGrantOfferLetter(projectId); assertTrue(result.getFailure().is(CommonFailureKeys.SIGNED_GRANT_OFFER_LETTER_MUST_BE_UPLOADED_BEFORE_SUBMIT)); Assert.assertThat(project.getOfferSubmittedDate(), nullValue()); } @T...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<Void> removeGrantOfferLetterFileEntry(Long projectId) { return getProject(projectId). andOnSuccess(project -> validateProjectIsActive(project). andOnSuccess(() -> validateRemov...
@Test public void removeGrantOfferLetterFileEntry() { UserResource internalUserResource = newUserResource().build(); User internalUser = newUser().withId(internalUserResource.getId()).build(); setLoggedInUser(internalUserResource); FileEntry existingGOLFile = newFileEntry().build(); project.setGrantOfferLetter(existing...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<Void> removeSignedGrantOfferLetterFileEntry(Long projectId) { return getProject(projectId). andOnSuccess(this::validateProjectIsActive). andOnSuccess(project -> getCurrentlyLog...
@Test public void removeSignedGrantOfferLetterFileEntry() { UserResource externalUser = newUserResource().build(); setLoggedInUser(externalUser); FileEntry existingSignedGOLFile = newFileEntry().build(); project.setSignedGrantOfferLetter(existingSignedGOLFile); when(userRepository.findById(externalUser.getId())).thenRe...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<Void> resetGrantOfferLetter(Long projectId) { Project project = getProject(projectId).getSuccess(); if (project.getGrantOfferLetter() != null) { fileService.deleteFileIgnoreNot...
@Test public void resetGrantOfferLetter() { UserResource externalUser = newUserResource().build(); setLoggedInUser(externalUser); FileEntry existingSignedGOLFile = newFileEntry().build(); project.setSignedGrantOfferLetter(existingSignedGOLFile); when(userRepository.findById(externalUser.getId())).thenReturn(Optional.of...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<Void> sendGrantOfferLetter(Long projectId) { return getProject(projectId).andOnSuccess(project -> { if (project.getGrantOfferLetter() == null) { return serviceFailure(CommonFai...
@Test public void sendGrantOfferLetterNoGol() { List<ProjectUser> pu = newProjectUser().withRole(PROJECT_MANAGER).withUser(user).withOrganisation(nonAcademicUnfunded).withInvite(newProjectUserInvite().build()).build(1); Project p = newProject() .withProjectUsers(pu) .withPartnerOrganisations(newPartnerOrganisation() .w...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { private ServiceResult<Void> sendGrantOfferLetterSuccess(Project project) { return getCurrentlyLoggedInUser().andOnSuccess(user -> { if (golWorkflowHandler.grantOfferLetterSent(project, user)) { return serviceSuccess(); } e...
@Test public void sendGrantOfferLetterSuccess() { FileEntry golFile = newFileEntry().withFilesizeBytes(10).withMediaType("application/pdf").build(); List<ProjectUser> pu = newProjectUser().withRole(PROJECT_MANAGER).withUser(user).withOrganisation(nonAcademicUnfunded).withInvite(newProjectUserInvite().build()).build(1);...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<Void> approveOrRejectSignedGrantOfferLetter(Long projectId, GrantOfferLetterApprovalResource grantOfferLetterApprovalResource) { return validateApprovalOrRejection(grantOfferLe...
@Test public void approveOrRejectSignedGrantOfferLetterRejectionSuccess() { User u = newUser().withFirstName("A").withLastName("B").withEmailAddress("a@b.com").build(); setLoggedInUser(newUserResource().withId(u.getId()).build()); when(projectRepository.findById(projectId)).thenReturn(Optional.of(project)); when(golWor...
UserPermissionRules { @PermissionRule(value = "READ", description = "Comp admins and project finance can view assessors") public boolean compAdminAndProjectFinanceCanViewAssessors(UserPageResource usersToView, UserResource user) { return usersToView.getContent().stream().allMatch(u -> u.hasAnyRoles(ASSESSOR_ROLES)) && ...
@Test public void compAdminAndProjectFinanceCanViewAssessors() { UserPageResource userPageResourceWithOnlyAssessors = new UserPageResource(); userPageResourceWithOnlyAssessors.setContent(newUserResource().withRoleGlobal(ASSESSOR).build(1)); UserPageResource userPageResourceWithNonAssessors = new UserPageResource(); use...
RoleProfileStatusPermissionRoles { @PermissionRule(value = "RETRIEVE_USER_ROLE_PROFILE", description = "Comp admin, project finance or support can retrieve a users status") public boolean adminsAndSupportCanRetrieveUserRoleProfile(UserResource userToCheck, UserResource user) { return isInternalAdmin(user) || isSupport(...
@Test public void internalUsersCanRetrieveRoleProfiles() { UserResource otherUser = newUserResource().build(); allGlobalRoleUsers.forEach(user -> { if (isInternalAdmin(user) || isSupport(user)) { assertTrue(rules.adminsAndSupportCanRetrieveUserRoleProfile(otherUser, user)); } else { assertFalse(rules.adminsAndSupportCa...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override public ServiceResult<GrantOfferLetterStateResource> getGrantOfferLetterState(Long projectId) { return getProject(projectId).andOnSuccess( golWorkflowHandler::getExtendedState); } @Override ServiceResult<FileAndC...
@Test public void getGrantOfferLetterStateWhenProjectDoesNotExist() { when(projectRepository.findById(projectId)).thenReturn(Optional.empty()); ServiceResult<GrantOfferLetterStateResource> result = service.getGrantOfferLetterState(projectId); assertTrue(result.isFailure()); assertTrue(result.getFailure().is(notFoundErr...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override public ServiceResult<StringResource> getDocusignUrl(long projectId) { return getProject(projectId).andOnSuccessReturn(project -> { User projectManager = getExistingProjectManager(project).get().getUser(); return ...
@Test public void getDocusignUrl() { List<ProjectUser> pu = newProjectUser().withRole(PROJECT_MANAGER).withUser(user).withOrganisation(nonAcademicUnfunded).withInvite(newProjectUserInvite().build()).build(1); Competition competition = newCompetition() .withName("Competition 1") .build(); Application application = newAp...
GrantOfferLetterServiceImpl extends BaseTransactionalService implements GrantOfferLetterService { @Override @Transactional public ServiceResult<Void> importGrantOfferLetter(long projectId) { return getProject(projectId).andOnSuccess(project -> docusignService.importDocument(project.getSignedGolDocusignDocument().getEnv...
@Test public void importGrantOfferLetter() { List<ProjectUser> pu = newProjectUser().withRole(PROJECT_MANAGER).withUser(user).withOrganisation(nonAcademicUnfunded).withInvite(newProjectUserInvite().build()).build(1); Competition competition = newCompetition() .withName("Competition 1") .build(); Application application...
ProjectPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "A user can see projects that they are partners on") public boolean partnersOnProjectCanView(ProjectResource project, UserResource user) { return project != null && isPartner(project.getId(), user.getId()); } @Permission...
@Test public void partnersOnProjectCanView() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource().build(); setupUserAsPartner(project, user); assertTrue(rules.partnersOnProjectCanView(project, user)); } @Test public void partnersOnProjectCanViewButUserNotPartner() { UserResour...
ProjectPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Internal users can see project resources") public boolean internalUsersCanViewProjects(final ProjectResource project, final UserResource user) { return isInternal(user); } @PermissionRule(value = "READ", description = "...
@Test public void internalUsersCanViewProjects() { ProjectResource project = newProjectResource().build(); allGlobalRoleUsers.forEach(user -> { if (allInternalUsers.contains(user)) { assertTrue(rules.internalUsersCanViewProjects(project, user)); } else { assertFalse(rules.internalUsersCanViewProjects(project, user)); }...
ProjectPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Stakeholders can see project resources") public boolean stakeholdersCanViewProjects(final ProjectResource project, final UserResource user) { return userIsStakeholderInCompetition(project.getCompetition(), user.getId());...
@Test public void stakeholdersCanViewProjects() { User stakeholderUserOnCompetition = newUser().withRoles(singleton(STAKEHOLDER)).build(); UserResource stakeholderUserResourceOnCompetition = newUserResource().withId(stakeholderUserOnCompetition.getId()).withRolesGlobal(singletonList(STAKEHOLDER)).build(); Competition c...
ProjectPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Competition finance users can see project resources") public boolean competitionFinanceUsersCanViewProjects(final ProjectResource project, final UserResource user) { return userIsExternalFinanceInCompetition(project.getC...
@Test public void competitionFinanceUsersCanViewProjects() { User competitionFinanceUserOnCompetition = newUser().withRoles(singleton(EXTERNAL_FINANCE)).build(); UserResource competitionFinanceUserResourceOnCompetition = newUserResource().withId(competitionFinanceUserOnCompetition.getId()).withRolesGlobal(singletonList...
ProjectPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "A monitoring officer can see projects that they are assigned to") public boolean monitoringOfficerOnProjectCanView(final ProjectResource project, final UserResource user) { return project != null && isMonitoringOfficer(p...
@Test public void monitoringOfficerOnProjectCanView() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource().build(); setupUserAsMonitoringOfficer(project, user); assertTrue(rules.monitoringOfficerOnProjectCanView(project, user)); } @Test public void monitoringOfficerOnProjectCa...
RoleProfileStatusPermissionRoles { @PermissionRule(value = "RETRIEVE_USER_ROLE_PROFILE", description = "kta can retrieve a users status") public boolean ktaCanRetrieveUserRoleProfile(UserResource userToCheck, UserResource user) { return isKta(user); } @PermissionRule(value = "RETRIEVE_USER_ROLE_PROFILE", description =...
@Test public void ktaCanRetrieveRoleProfiles() { UserResource otherUser = newUserResource().build(); allGlobalRoleUsers.forEach(user -> { if (isKta(user)) { assertTrue(rules.ktaCanRetrieveUserRoleProfile(otherUser, user)); } else { assertFalse(rules.ktaCanRetrieveUserRoleProfile(otherUser, user)); } }); }
ProjectPermissionRules extends BasePermissionRules { @PermissionRule(value = "ADD_PARTNER", description = "The System Registration user can add a partner to a project") public boolean systemRegistrarCanAddPartnersToProject(final ProjectResource project, final UserResource user) { return isSystemRegistrationUser(user) &...
@Test public void systemRegistrarCanAddPartnersToProject() { ProjectResource project = newProjectResource().build(); ProjectProcess projectProcess = newProjectProcess().withActivityState(ProjectState.SETUP).build(); when(projectProcessRepository.findOneByTargetId(project.getId())).thenReturn(projectProcess); allGlobalR...
ProjectPermissionRules extends BasePermissionRules { @PermissionRule(value = "VIEW_FINANCE_REVIEWER", description = "Project finance users can view finance reviewer.") public boolean projectFinanceCanViewFinanceReviewer(final ProjectResource project, final UserResource user) { return isProjectFinanceUser(user); } @Per...
@Test public void projectFinanceCanViewFinanceReviewer() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource().build(); setUpUserAsProjectFinanceUser(project, user); assertTrue(rules.projectFinanceCanViewFinanceReviewer(project, user)); } @Test public void nonProjectFinanceCann...
ProjectPermissionRules extends BasePermissionRules { @PermissionRule(value = "VIEW_FINANCE_REVIEWER", description = "Comp admin users can view finance reviewer.") public boolean compAdminCanViewFinanceReviewer(final ProjectResource project, final UserResource user) { return isCompAdmin(user); } @PermissionRule(value =...
@Test public void compAdminCanViewFinanceReviewer() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource().build(); setUpUserAsCompAdmin(project, user); assertTrue(rules.compAdminCanViewFinanceReviewer(project, user)); } @Test public void nonCompAdminCannotViewFinanceReviewer() ...
ProjectPermissionRules extends BasePermissionRules { @PermissionRule(value = "VIEW_FINANCE_REVIEWER", description = "Support users can view finance reviewer.") public boolean supportCanViewFinanceReviewer(final ProjectResource project, final UserResource user) { return isSupport(user); } @PermissionRule(value = "READ"...
@Test public void supportCanViewFinanceReviewer() { UserResource user = newUserResource().build(); ProjectResource project = newProjectResource().build(); setUpUserAsSupport(project, user); assertTrue(rules.supportCanViewFinanceReviewer(project, user)); } @Test public void nonSupportCannotViewFinanceReviewer() { UserRe...
PartnerOrganisationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "A partner can see a list of all partner organisations on their project") public boolean partnersOnProjectCanView(final PartnerOrganisationResource partnerOrganisation, final UserResource user) { return isPart...
@Test public void partnersCanView() { UserResource user = newUserResource().withRolesGlobal(singletonList(COMP_ADMIN)).build(); Project project = newProject().build(); ProjectUser projectUser = newProjectUser().withProject(project).build(); when(projectUserRepository.findByProjectIdAndUserIdAndRoleIsIn(project.getId(),...
RoleProfileStatusPermissionRoles { @PermissionRule(value = "RETRIEVE_USER_ROLE_PROFILE", description = "Assessors can retrieve their own status") public boolean usersCanRetrieveTheirOwnUserRoleProfile(UserResource userToCheck, UserResource user) { return userToCheck.equals(user); } @PermissionRule(value = "RETRIEVE_US...
@Test public void usersCanRetrieveTheirOwnRoleProfiles() { UserResource user = newUserResource().build(); assertTrue(rules.usersCanRetrieveTheirOwnUserRoleProfile(user, user)); }
PartnerOrganisationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Internal users can see partner organisations for any project") public boolean internalUsersCanView(PartnerOrganisationResource partnerOrganisation, UserResource user) { return isInternal(user); } @Permission...
@Test public void internalUserCanView() { UserResource user = newUserResource().withRolesGlobal(singletonList(COMP_ADMIN)).build(); Project project = newProject().build(); PartnerOrganisationResource partnerOrg = newPartnerOrganisationResource().withProject(project.getId()).build(); assertTrue(rules.internalUsersCanVie...
PartnerOrganisationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Monitoring officers can see partner organisations on a project they are assigned to") public boolean monitoringOfficersUsersCanView(PartnerOrganisationResource partnerOrganisation, UserResource user) { return...
@Test public void monitoringOfficerCanView() { UserResource user = newUserResource().withRolesGlobal(singletonList(MONITORING_OFFICER)).build(); Project project = newProject().build(); PartnerOrganisationResource partnerOrg = newPartnerOrganisationResource().withProject(project.getId()).build(); when(projectMonitoringO...
PartnerOrganisationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Competition finances users can see partner organisations on projects in competitions they are assigned to") public boolean competitionFinanceUsersCanViewProjects(PartnerOrganisationResource partnerOrganisatio...
@Test public void externalFinanceUserCanView() { long projectId = 1L; Competition competition = newCompetition().build(); Organisation organisation = newOrganisation().build(); UserResource user = newUserResource().withRolesGlobal(singletonList(EXTERNAL_FINANCE)).build(); Project project = newProject().withId(projectId...
PartnerOrganisationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_PENDING_PARTNER_PROGRESS", description = "Partners can read their own progress when setting up their organisation") public boolean partnersCanReadTheirOwnPendingPartnerProgress(final PartnerOrganisationResource partnerOrganis...
@Test public void partnersCannotViewOtherPendingPartnerProgress() { long projectId = 1L; long organisationId = 2L; UserResource user = newUserResource().build(); PartnerOrganisationResource partnerOrg = newPartnerOrganisationResource() .withProject(projectId) .withOrganisation(organisationId) .build(); when(projectUser...
PartnerOrganisationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_PENDING_PARTNER_PROGRESS", description = "Internal users can read partner progress in project setup") public boolean internalUsersCanReadPendingPartnerProgress(final PartnerOrganisationResource partnerOrganisation, final User...
@Test public void internalUsersCanViewPendingPartnerProgress() { long projectId = 1L; long organisationId = 2L; UserResource user = newUserResource().build(); user.isInternalUser(); PartnerOrganisationResource partnerOrg = newPartnerOrganisationResource() .withProject(projectId) .withOrganisation(organisationId) .build...
PartnerOrganisationPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ_PENDING_PARTNER_PROGRESS", description = "Competition finance users can read partner progress in project setup in competitions they are assigned to") public boolean competitionFinanceUsersCanReadPendingPartnerProgress(final P...
@Test public void externalFinanceUsersCanViewPendingPartnerProgress() { long projectId = 1L; long organisationId = 2L; Competition competition = newCompetition().build(); UserResource user = newUserResource().withRoleGlobal(EXTERNAL_FINANCE).build(); Project project = newProject().withId(projectId).withApplication(newA...