src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
PartnerOrganisationPermissionRules extends BasePermissionRules { @PermissionRule(value = "UPDATE_PENDING_PARTNER_PROGRESS", description = "Partners can update their own progress when setting up their organisation") public boolean partnersCanUpdateTheirOwnPendingPartnerProgress(final PartnerOrganisationResource partnerO...
@Test public void partnersCanUpdateTheirOwnPendingPartnerProgress() { long projectId = 1L; long organisationId = 2L; UserResource user = newUserResource().build(); PartnerOrganisationResource partnerOrg = newPartnerOrganisationResource() .withProject(projectId) .withOrganisation(organisationId) .build(); ProjectUser pr...
PartnerOrganisationPermissionRules extends BasePermissionRules { @PermissionRule(value = "REMOVE_PARTNER_ORGANISATION", description = "Internal users can remove partner organisations for any project") public boolean internalUsersCanRemovePartnerOrganisations(final PartnerOrganisationResource partnerOrganisation, final ...
@Test public void internalUsersCanRemovePartnerOrganisations() { long projectId = 1L; long organisationId = 2L; PartnerOrganisationResource partnerOrg = newPartnerOrganisationResource() .withProject(projectId) .withOrganisation(organisationId) .build(); allGlobalRoleUsers.forEach(user -> { if (isInternalAdmin(user)) { ...
UserLookupStrategies { @PermissionEntityLookupStrategy public UserResource findById(Long id) { return userMapper.mapIdToResource(id); } @PermissionEntityLookupStrategy UserResource findById(Long id); }
@Test public void testFindById() { UserResource user = newUserResource().build(); when(userMapperMock.mapIdToResource(123L)).thenReturn(user); assertEquals(user, lookup.findById(123L)); }
ProjectController { @GetMapping("/{id}") public RestResult<ProjectResource> getProjectById(@PathVariable long id) { return projectService.getProjectById(id).toGetResponse(); } @GetMapping("/{id}") RestResult<ProjectResource> getProjectById(@PathVariable long id); @GetMapping("/application/{applicationId}") RestResult<...
@Test public void getProjectById() throws Exception { ProjectResource project1 = newProjectResource().build(); ProjectResource project2 = newProjectResource().build(); when(projectServiceMock.getProjectById(project1.getId())).thenReturn(serviceSuccess(project1)); when(projectServiceMock.getProjectById(project2.getId())...
ProjectController { @GetMapping public RestResult<List<ProjectResource>> findAll() { return projectService.findAll().toGetResponse(); } @GetMapping("/{id}") RestResult<ProjectResource> getProjectById(@PathVariable long id); @GetMapping("/application/{applicationId}") RestResult<ProjectResource> getByApplicationId(@Pat...
@Test public void findAll() throws Exception { int projectNumber = 3; List<ProjectResource> projects = newProjectResource().build(projectNumber); when(projectServiceMock.findAll()).thenReturn(serviceSuccess(projects)); mockMvc.perform(get("/project/").contentType(APPLICATION_JSON).accept(APPLICATION_JSON)) .andExpect(s...
ProjectController { @GetMapping("/{projectId}/project-users") public RestResult<List<ProjectUserResource>> getProjectUsers(@PathVariable long projectId) { return projectService.getProjectUsersByProjectIdAndRoleIn(projectId, PROJECT_USER_ROLES.stream().collect(Collectors.toList())).toGetResponse(); } @GetMapping("/{id}...
@Test public void getProjectUsers() throws Exception { List<ProjectUserResource> projectUsers = newProjectUserResource().build(3); when(projectServiceMock.getProjectUsersByProjectIdAndRoleIn(123L, PROJECT_USER_ROLES.stream().collect(Collectors.toList()))).thenReturn(serviceSuccess(projectUsers)); mockMvc.perform(get("/...
ProjectController { @PostMapping("/create-project/application/{applicationId}") public RestResult<ProjectResource> createProjectFromApplication(@PathVariable long applicationId) { return projectService.createProjectFromApplication(applicationId).toPostWithBodyResponse(); } @GetMapping("/{id}") RestResult<ProjectResour...
@Test public void createProjectFromApplication() throws Exception { long applicationId = 1; ProjectResource expectedProject = newProjectResource().build(); when(projectServiceMock.createProjectFromApplication(applicationId)).thenReturn(serviceSuccess(expectedProject)); mockMvc.perform(post("/project/create-project/appl...
ProjectController { @GetMapping("/{projectId}/lead-organisation") public RestResult<OrganisationResource> getLeadOrganisation(@PathVariable long projectId){ return projectService.getLeadOrganisation(projectId).toGetResponse(); } @GetMapping("/{id}") RestResult<ProjectResource> getProjectById(@PathVariable long id); @G...
@Test public void getLeadOrganisation() throws Exception { long projectId = 5; OrganisationResource organisationResource = newOrganisationResource().build(); when(projectServiceMock.getLeadOrganisation(projectId)).thenReturn(serviceSuccess(organisationResource)); mockMvc.perform(get("/project/{projectId}/lead-organisat...
ProjectController { @GetMapping("/{projectId}/project-finance-contacts") public RestResult<List<ProjectUserResource>> getProjectFinanceContacts(@PathVariable(value = "projectId") Long projectId) { return projectService.getProjectUsersByProjectIdAndRoleIn(projectId, Collections.singletonList(ProjectParticipantRole.PROJE...
@Test public void getProjectFinanceContacts() throws Exception { Long project1Id = 1L; List<ProjectParticipantRole> projectParticipantRoles = Collections.singletonList(ProjectParticipantRole.PROJECT_FINANCE_CONTACT); List<ProjectUserResource> projectFinanceContacts = Collections.singletonList(newProjectUserResource().w...
PartnerOrganisationController { @GetMapping("/partner/{organisationId}") public RestResult<PartnerOrganisationResource> getPartnerOrganisation(@PathVariable long projectId, @PathVariable long organisationId) { return partnerOrganisationService.getPartnerOrganisation(projectId, organisationId).toGetResponse(); } @GetMa...
@Test public void getProjectPartner() throws Exception { Long projectId = 123L; Long organisationId = 234L; PartnerOrganisationResource partnerOrg = newPartnerOrganisationResource().build(); when(partnerOrganisationService.getPartnerOrganisation(projectId, organisationId)).thenReturn(serviceSuccess(partnerOrg)); mockMv...
PartnerOrganisationController { @PostMapping("/remove-organisation/{organisationId}") public RestResult<Void> removeOrganisation(@PathVariable long projectId, @PathVariable long organisationId) { return partnerOrganisationService.removePartnerOrganisation(id(projectId, organisationId)).toPostResponse(); } @GetMapping(...
@Test public void removeOrganisation() throws Exception { long projectId = 123; long organisationId = 456; ProjectOrganisationCompositeId projectOrganisationCompositeId = id(projectId, organisationId); when(partnerOrganisationService.removePartnerOrganisation(projectOrganisationCompositeId)).thenReturn(serviceSuccess()...
ProjectServiceImpl extends AbstractProjectServiceImpl implements ProjectService { @Override @Transactional public ServiceResult<ProjectResource> createProjectFromApplication(long applicationId) { return getApplication(applicationId).andOnSuccess(application -> { if (FundingDecisionStatus.FUNDED.equals(application.getFu...
@Test public void createProjectFromApplication() { ProjectResource newProjectResource = newProjectResource().build(); PartnerOrganisation savedProjectPartnerOrganisation = newPartnerOrganisation(). withOrganisation(organisation). withLeadOrganisation(true). build(); Project savedProject = newProject(). withId(newProjec...
AgreementPermissionRules extends BasePermissionRules { @PermissionRule(value = "READ", description = "Any assessor user can view the current agreement") public boolean anyAssessorCanViewTheCurrentAgreement(UserResource user) { return SecurityRuleUtil.hasAssessorAuthority(user); } @PermissionRule(value = "READ", descri...
@Test public void anyAssessorCanViewTheCurrentAgreement() { UserResource userWithAssessorRole = getUserWithRole(ASSESSOR); assertTrue(rules.anyAssessorCanViewTheCurrentAgreement(userWithAssessorRole)); } @Test public void anyAssessorCanViewTheCurrentAgreement_notAnAssessor() { UserResource userWithoutAssessorRole = new...
ProjectServiceImpl extends AbstractProjectServiceImpl implements ProjectService { @Override @Transactional (readOnly = true) public ServiceResult<List<ProjectResource>> findByUserId(long userId) { List<ProjectUser> projectUsers = projectUserRepository.findByUserId(userId); return serviceSuccess(projectUsers .stream() ....
@Test public void findByUserId_returnsOnlyDistinctProjects() { Project project = newProject().build(); User user = newUser().build(); List<ProjectUser> projectUserRecords = newProjectUser() .withProject(project) .withRole(PROJECT_PARTNER, PROJECT_FINANCE_CONTACT) .build(2); ProjectResource projectResource = newProjectR...
ProjectServiceImpl extends AbstractProjectServiceImpl implements ProjectService { @Override @Transactional public ServiceResult<ProjectUser> addPartner(long projectId, long userId, long organisationId) { return find(getProject(projectId), getOrganisation(organisationId), getUser(userId)). andOnSuccess((project, organis...
@Test public void addPartner_organisationNotOnProject(){ Organisation organisationNotOnProject = newOrganisation().build(); when(projectRepositoryMock.findById(project.getId())).thenReturn(Optional.of(project)); when(organisationRepositoryMock.findById(o.getId())).thenReturn(Optional.of(o)); when(organisationRepository...
ProjectServiceImpl extends AbstractProjectServiceImpl implements ProjectService { @Override public ServiceResult<Boolean> existsOnApplication(long projectId, long organisationId) { return getProject(projectId).andOnSuccessReturn(p -> p.getApplication().getApplicantProcessRoles().stream() .anyMatch(pr -> pr.getOrganisat...
@Test public void existsOnApplication(){ when(projectRepositoryMock.findById(project.getId())).thenReturn(Optional.ofNullable(project)); ServiceResult<Boolean> shouldSucceed = service.existsOnApplication(project.getId(), organisation.getId()); assertTrue(shouldSucceed.isSuccess()); assertTrue(shouldSucceed.getSuccess()...
ProjectServiceImpl extends AbstractProjectServiceImpl implements ProjectService { @Override @Transactional public ServiceResult<Void> createProjectsFromFundingDecisions(Map<Long, FundingDecision> applicationFundingDecisions) { List<ServiceResult<ProjectResource>> projectCreationResults = applicationFundingDecisions .ke...
@Test public void createProjectsFromFundingDecisions() { ProjectResource newProjectResource = newProjectResource().build(); PartnerOrganisation savedProjectPartnerOrganisation = newPartnerOrganisation(). withOrganisation(organisation). withLeadOrganisation(true). build(); Project savedProject = newProject(). withId(new...
ProjectServiceImpl extends AbstractProjectServiceImpl implements ProjectService { @Override public ServiceResult<OrganisationResource> getLeadOrganisation(long projectId) { return getProject(projectId) .andOnSuccessReturn(p -> p.getApplication().getLeadOrganisationId()) .andOnSuccess(this::getOrganisation) .andOnSucces...
@Test public void getLeadOrganisation() { OrganisationResource expectedOrganisationResource = newOrganisationResource().build(); when(projectRepositoryMock.findById(project.getId())).thenReturn(Optional.of(project)); when(organisationMapperMock.mapToResource(organisation)).thenReturn(expectedOrganisationResource); Orga...
PartnerOrganisationServiceImpl implements PartnerOrganisationService { @Override public ServiceResult<PartnerOrganisationResource> getPartnerOrganisation(Long projectId, Long organisationId) { return find(partnerOrganisationRepository.findOneByProjectIdAndOrganisationId(projectId, organisationId), notFoundError(Partner...
@Test public void getPartnerOrganisation() { when(partnerOrganisationRepository.findOneByProjectIdAndOrganisationId(projectId, organisations.get(0).getId())).thenReturn(partnerOrganisations.get(0)); when(partnerOrganisationRepository.findOneByProjectIdAndOrganisationId(projectId, organisations.get(1).getId())).thenRetu...
PartnerOrganisationServiceImpl implements PartnerOrganisationService { @Override public ServiceResult<List<PartnerOrganisationResource>> getProjectPartnerOrganisations(Long projectId) { return find(partnerOrganisationRepository.findByProjectId(projectId), notFoundError(PartnerOrganisation.class)). andOnSuccessReturn(ls...
@Test public void getProjectPartnerOrganisations() { when(partnerOrganisationRepository.findByProjectId(projectId)).thenReturn(partnerOrganisations); when(partnerOrganisationMapper.mapToResource(partnerOrganisations.get(0))).thenReturn(partnerOrganisationResources.get(0)); when(partnerOrganisationMapper.mapToResource(p...
PartnerOrganisationServiceImpl implements PartnerOrganisationService { @Override @Transactional public ServiceResult<Void> removePartnerOrganisation(ProjectOrganisationCompositeId projectOrganisationCompositeId) { return find(partnerOrganisationRepository.findOneByProjectIdAndOrganisationId(projectOrganisationComposite...
@Test public void removeNonLeadPartnerOrganisation() { pendingPartnerProgress = new PendingPartnerProgress(partnerOrganisations.get(1)); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organisations.get(1).getId()); when(partnerOrganisationRepository.findOne...
ProjectPartnerChangeServiceImpl extends BaseTransactionalService implements ProjectPartnerChangeService { @Override @Transactional public void updateProjectWhenPartnersChange(long projectId) { rejectProjectDocuments(projectId); resetProjectFinanceEligibility(projectId); } @Override @Transactional void updateProjectWhe...
@Test public void updateProjectWhenPartnersChange_EligibilityIsReset() { when(projectDocumentRepository.findAllByProjectId(2L)).thenReturn(Collections.emptyList()); when(partnerOrganisationRepository.findOneByProjectIdAndOrganisationId(2L, 1L)).thenReturn(partnerOrganisation); service.updateProjectWhenPartnersChange(2L...
Project implements ProcessActivity { public List<Organisation> getOrganisations(){ return simpleMap(partnerOrganisations, PartnerOrganisation::getOrganisation); } Project(); Project(Application application, LocalDate targetStartDate, Address address, Long durationInMonths, String name, ZonedDateTime...
@Test public void testGetOrganisations() { Organisation org1 = newOrganisation().build(); Organisation org2 = newOrganisation().build(); List<PartnerOrganisation> partnerOrganisations = newPartnerOrganisation().withOrganisation(org1, org2).build(2); Project project = newProject().withPartnerOrganisations(partnerOrganis...
Project implements ProcessActivity { public List<ProjectUser> getProjectUsers() { return projectUsers; } Project(); Project(Application application, LocalDate targetStartDate, Address address, Long durationInMonths, String name, ZonedDateTime documentsSubmittedDate, ApprovalType otherDocumentsApprov...
@Test public void testGetProjectUsersFilter() { Project project = newProject().withProjectUsers(newProjectUser().withRole(PROJECT_PARTNER).build(1)).build(); Predicate<ProjectUser> shouldRemove = pu -> PROJECT_PARTNER != pu.getRole(); Predicate<ProjectUser> shouldNotRemove = pu -> PROJECT_PARTNER == pu.getRole(); asser...
ProcessRoleController { @GetMapping("{id}/application") public RestResult<ApplicationResource> findByProcessRole(@PathVariable("id") final long id) { return applicationService.findByProcessRole(id).toGetResponse(); } @GetMapping("/{id}") RestResult<ProcessRoleResource> findOne(@PathVariable("id") final long id); @GetM...
@Test public void findByProcessRoleShouldReturnApplicationResourceList() throws Exception { String appName = "app1"; when(applicationServiceMock.findByProcessRole(1L)).thenReturn(serviceSuccess(newApplicationResource().withName(appName).build())); mockMvc.perform(get("/processrole/{id}/application", 1)) .andExpect(stat...
Project implements ProcessActivity { public List<ProjectUser> getProjectUsersWithRole(ProjectParticipantRole... roles){ return getProjectUsers(pu -> Arrays.stream(roles).anyMatch(pu.getRole()::equals)); } Project(); Project(Application application, LocalDate targetStartDate, Address address, Long du...
@Test public void testGetProjectUsersWithRole() { ProjectUser pu1 = newProjectUser().withRole(PROJECT_PARTNER).build(); ProjectUser pu2 = newProjectUser().withRole(PROJECT_FINANCE_CONTACT).build(); Project project = newProject().withProjectUsers(asList(pu1, pu2)).build(); assertNotNull(project.getProjectUsersWithRole(P...
LegacyMonitoringOfficerPermissionRules extends BasePermissionRules { @PermissionRule( value = "ASSIGN_MONITORING_OFFICER", description = "Internal users can assign Monitoring Officers on any Project") public boolean internalUsersCanAssignMonitoringOfficersForAnyProject(ProjectResource project, UserResource user) { retu...
@Test public void internalUsersCanEditMonitoringOfficersOnProjects() { ProjectResource project = newProjectResource() .withProjectState(SETUP) .build(); when(projectProcessRepository.findOneByTargetId(project.getId())).thenReturn(projectProcess); allGlobalRoleUsers.forEach(user -> { if (allInternalUsers.contains(user))...
LegacyMonitoringOfficerController { @GetMapping("/{projectId}/monitoring-officer") public RestResult<LegacyMonitoringOfficerResource> getMonitoringOfficer(@PathVariable("projectId") final Long projectId) { return monitoringOfficerService.getMonitoringOfficer(projectId).toGetResponse(); } @GetMapping("/{projectId}/moni...
@Test public void getMonitoringOfficer() throws Exception { LegacyMonitoringOfficerResource monitoringOfficer = newLegacyMonitoringOfficerResource().build(); when(monitoringOfficerServiceMock.getMonitoringOfficer(123L)).thenReturn(serviceSuccess(monitoringOfficer)); mockMvc.perform(get("/project/{projectId}/monitoring-...
LegacyMonitoringOfficerController { @PutMapping("/{projectId}/monitoring-officer") public RestResult<Void> saveMonitoringOfficer(@PathVariable("projectId") final Long projectId, @RequestBody @Valid final LegacyMonitoringOfficerResource monitoringOfficerResource) { ServiceResult<Boolean> result = monitoringOfficerServic...
@Test public void saveMOWhenErrorWhistSaving() throws Exception { Long projectId = 1L; when(monitoringOfficerServiceMock.saveMonitoringOfficer(projectId, monitoringOfficerResource)). thenReturn(serviceFailure(new Error(PROJECT_SETUP_MONITORING_OFFICER_CANNOT_BE_ASSIGNED_UNTIL_PROJECT_DETAILS_SUBMITTED))); mockMvc.perfo...
LegacyMonitoringOfficerServiceImpl extends AbstractProjectServiceImpl implements LegacyMonitoringOfficerService { @Override @Transactional public ServiceResult<SaveMonitoringOfficerResult> saveMonitoringOfficer(final Long projectId, final LegacyMonitoringOfficerResource monitoringOfficerResource) { return validateMonit...
@Test public void testSaveMOWithDiffProjectIdInURLAndMOResource() { Long projectid = 1L; LegacyMonitoringOfficerResource monitoringOfficerResource = newLegacyMonitoringOfficerResource() .withProject(3L) .withFirstName("abc") .withLastName("xyz") .withEmail("abc.xyz@gmail.com") .withPhoneNumber("078323455") .build(); Se...
RoleProfileStatusController { @GetMapping("/{userId}/role-profile-status") public RestResult<List<RoleProfileStatusResource>> findByUserId(@PathVariable long userId) { return roleProfileStatusService.findByUserId(userId).toGetResponse(); } @GetMapping("/{userId}/role-profile-status/{profileRole}") RestResult<RoleProfi...
@Test public void findByUserId() throws Exception { long userId = 1L; List<RoleProfileStatusResource> roleProfileStatusResources = newRoleProfileStatusResource().withUserId(userId).build(1); when(roleProfileStatusServiceMock.findByUserId(userId)).thenReturn(serviceSuccess(roleProfileStatusResources)); mockMvc.perform(g...
LegacyMonitoringOfficerServiceImpl extends AbstractProjectServiceImpl implements LegacyMonitoringOfficerService { @Override public ServiceResult<LegacyMonitoringOfficerResource> getMonitoringOfficer(Long projectId) { return getExistingMonitoringOfficerForProject(projectId).andOnSuccessReturn(legacyMonitoringOfficerMapp...
@Test public void testGetMonitoringOfficerWhenMODoesNotExistInDB() { Long projectid = 1L; ServiceResult<LegacyMonitoringOfficerResource> result = service.getMonitoringOfficer(projectid); String errorKey = result.getFailure().getErrors().get(0).getErrorKey(); Assert.assertEquals(CommonFailureKeys.GENERAL_NOT_FOUND.name(...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule(value = "VIEW_SPEND_PROFILE_STATUS", description = "Internal admin team (comp admin and project finance) users can get the approved status of a Spend Profile for any Project") public boolean internalAdminTeamCanViewCompetitionStatus(ProjectResour...
@Test public void internalAdminTeamCanViewCompetitionStatus() { allGlobalRoleUsers.forEach(user -> { if (isInternalAdmin(user)) { assertTrue(rules.internalAdminTeamCanViewCompetitionStatus(newProjectResource().build(), user)); } else { assertFalse(rules.internalAdminTeamCanViewCompetitionStatus(newProjectResource().bui...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule(value = "VIEW_SPEND_PROFILE_STATUS", description = "Support users can get the approved status of a Spend Profile for any Project") public boolean supportCanViewCompetitionStatus(ProjectResource project, UserResource user){ return isSupport(user);...
@Test public void supportCanViewCompetitionStatus() { allGlobalRoleUsers.forEach(user -> { if (isSupport(user)) { assertTrue(rules.supportCanViewCompetitionStatus(newProjectResource().build(), user)); } else { assertFalse(rules.supportCanViewCompetitionStatus(newProjectResource().build(), user)); } }); }
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule(value = "VIEW_SPEND_PROFILE_STATUS", description = "Innovation lead users can get the approved status of a Spend Profile for any Project") public boolean assignedInnovationLeadCanViewSPStatus(ProjectResource project, UserResource user){ Applicati...
@Test public void assignedInnovationLeadCanViewProjectStatus() { assertTrue(rules.assignedInnovationLeadCanViewSPStatus(projectResource1, innovationLeadUserResourceOnProject1)); assertFalse(rules.assignedInnovationLeadCanViewSPStatus(projectResource1, innovationLeadUser())); }
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule(value = "VIEW_SPEND_PROFILE_STATUS", description = "Stakeholders can get the approved status of a Spend Profile for any Project") public boolean assignedStakeholderCanViewSPStatus(ProjectResource project, UserResource user){ Application applicati...
@Test public void assignedStakeholderCanViewSPStatus() { when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceOnCompetition.getId())).thenReturn(true); assertTrue(rules.assignedStakeholderCanViewSPStatus(projectResource1, stakeholderUserResourceOnCompetition)); assertFal...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule(value = "COMPLETE_SPEND_PROFILE_REVIEW", description = "Only a Project Manager can complete the project's spend profiles review") public boolean projectManagerCanCompleteSpendProfile(ProjectCompositeId projectCompositeId, UserResource user) { ret...
@Test public void projectManagerCanCompleteSpendProfile() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); setUpUserAsProjectManager(project, user); assertTrue(rules.projectManagerCanCompleteSpendProfile(ProjectCompositeId.id(project.getId()), user)); }
RoleProfileStatusController { @GetMapping("/{userId}/role-profile-status/{profileRole}") public RestResult<RoleProfileStatusResource> findByUserIdAndProfileRole(@PathVariable long userId, @PathVariable final ProfileRole profileRole) { return roleProfileStatusService.findByUserIdAndProfileRole(userId, profileRole).toGet...
@Test public void findByUserIdAndProfileRole() throws Exception { long userId = 1L; ProfileRole profileRole = ProfileRole.ASSESSOR; RoleProfileStatusResource roleProfileStatusResource = newRoleProfileStatusResource().withUserId(userId).build(); when(roleProfileStatusServiceMock.findByUserIdAndProfileRole(userId, profil...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule(value = "MARK_SPEND_PROFILE_INCOMPLETE", description = "Any lead partner can mark partners spend profiles as incomplete") public boolean leadPartnerCanMarkSpendProfileIncomplete(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserR...
@Test public void leadPartnerCanIncompleteAnySpendProfile() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(project.getId(), newOrganisation().build().getId()); set...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_SPEND_PROFILE", description = "Lead partner view Spend Profile data") public boolean leadPartnerCanViewAnySpendProfileData(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserResource user) { return isLeadPartner(pro...
@Test public void leadPartnerCanViewAnySpendProfileData() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(project.getId(), newOrganisation().build().getId()); setup...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_SPEND_PROFILE", description = "Monitoring officer can view Spend Profile data for the projects they are assigned to") public boolean monitoringOfficerCanViewProjectsSpendProfileData(ProjectOrganisationCompositeId projectOrganisatio...
@Test public void monitoringOfficerCanViewAnySpendProfileData() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(project.getId(), newOrganisation().build().getId());...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_SPEND_PROFILE", description = "Partners can view their own Spend Profile data") public boolean partnersCanViewTheirOwnSpendProfileData(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserResource user) { return partn...
@Test public void partnersCanViewTheirOwnSpendProfileData() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); OrganisationResource org = newOrganisationResource().build(); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompos...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_SPEND_PROFILE", description = "Project Finance Users can view their own Spend Profile data") public boolean projectFinanceUserCanViewAnySpendProfileData(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserResource us...
@Test public void projectFinanceUserCanViewAnySpendProfileData() { ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(1L, newOrganisation().build().getId()); allGlobalRoleUsers.forEach(user -> { if (user.equals(projectFinanceUser())) { assertTrue(rules.projectFinanceUserC...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_SPEND_PROFILE_CSV", description = "Partners can view their own Spend Profile data") public boolean partnersCanViewTheirOwnSpendProfileCsv(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserResource user) { return pa...
@Test public void partnersCanViewTheirOwnSpendProfileCsv() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); OrganisationResource org = newOrganisationResource().build(); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationComposi...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_SPEND_PROFILE_CSV", description = "All internal admin users can view Spend Profile data of any applicant") public boolean internalAdminUsersCanSeeSpendProfileCsv(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserRe...
@Test public void internalAdminUsersCanSeeSpendProfileCsv() { ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(1L, newOrganisation().build().getId()); allGlobalRoleUsers.forEach(user -> { if (isInternalAdmin(user)) { assertTrue(rules.internalAdminUsersCanSeeSpendProfile...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_SPEND_PROFILE_CSV", description = "Support users can view Spend Profile data of any applicant") public boolean supportUsersCanSeeSpendProfileCsv(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserResource user) { re...
@Test public void supportUsersCanSeeSpendProfileCsv() { ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(1L, newOrganisation().build().getId()); allGlobalRoleUsers.forEach(user -> { if (isSupport(user)) { assertTrue(rules.supportUsersCanSeeSpendProfileCsv(projectOrganis...
RoleProfileStatusController { @PutMapping("/{userId}/role-profile-status") public RestResult<Void> updateUserStatus(@PathVariable long userId, @RequestBody RoleProfileStatusResource roleProfileStatusResource) { return roleProfileStatusService.updateUserStatus(userId, roleProfileStatusResource).toPutResponse(); } @GetM...
@Test public void updateUserStatus() throws Exception { long userId = 1L; RoleProfileStatusResource roleProfileStatusResource = new RoleProfileStatusResource(); when(roleProfileStatusServiceMock.updateUserStatus(anyLong(), any(RoleProfileStatusResource.class))).thenReturn(serviceSuccess()); mockMvc.perform(put("/user/{...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_SPEND_PROFILE_CSV", description = "Stakeholders can view Spend Profile data for project on competition assigned to them") public boolean stakeholdersCanSeeSpendProfileCsv(ProjectOrganisationCompositeId projectOrganisationCompositeI...
@Test public void stakeholdersCanSeeSpendProfileCsv() { ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectResource1.getId(), newOrganisation().build().getId()); when(stakeholderRepository.existsByCompetitionIdAndUserId(competition.getId(), stakeholderUserResourceO...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "VIEW_SPEND_PROFILE_CSV", description = "Lead partner can view Spend Profile data") public boolean leadPartnerCanViewAnySpendProfileCsv(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserResource user) { return isLeadPart...
@Test public void leadPartnerCanViewAnySpendProfileCsv() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(project.getId(), newOrganisation().build().getId()); setupU...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule( value = "EDIT_SPEND_PROFILE", description = "Partners can edit their own Spend Profile data") public boolean partnersCanEditTheirOwnSpendProfileData(ProjectOrganisationCompositeId projectOrganisationCompositeId, UserResource user) { return partn...
@Test public void partnersCanEditTheirOwnSpendProfileData() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); OrganisationResource org = newOrganisationResource().build(); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompos...
SpendProfilePermissionRules extends BasePermissionRules { @PermissionRule(value = "MARK_SPEND_PROFILE_COMPLETE", description = "Any partner belonging to organisation can mark its spend profile as complete") public boolean partnersCanMarkSpendProfileAsComplete(ProjectOrganisationCompositeId projectOrganisationCompositeI...
@Test public void partnersCanMarkSpendProfileAsComplete() { ProjectResource project = newProjectResource().build(); UserResource user = newUserResource().build(); OrganisationResource org = newOrganisationResource().build(); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationComposit...
SpendProfileController { @PostMapping("/spend-profile/generate") public RestResult<Void> generateSpendProfile(@PathVariable("projectId") final Long projectId) { return spendProfileService.generateSpendProfile(projectId).toPostCreateResponse(); } @PostMapping("/spend-profile/generate") RestResult<Void> generateSpendPro...
@Test public void generateSpendProfile() throws Exception { when(spendProfileService.generateSpendProfile(123L)).thenReturn(serviceSuccess()); mockMvc.perform(post("/project/123/spend-profile/generate")).andExpect(status().isCreated()); verify(spendProfileService).generateSpendProfile(123L); }
SpendProfileController { @DeleteMapping("/spend-profile/reset") public RestResult<Void> deleteSpendProfile(@PathVariable("projectId") final Long projectId) { return spendProfileService.deleteSpendProfile(projectId).toDeleteResponse(); } @PostMapping("/spend-profile/generate") RestResult<Void> generateSpendProfile(@Pat...
@Test public void deleteSpendProfile() throws Exception { long projectId = 123L; when(spendProfileService.deleteSpendProfile(projectId)).thenReturn(serviceSuccess()); mockMvc.perform(delete("/project/{projectId}/spend-profile/reset", projectId)) .andExpect(status().isNoContent()). andDo(document("project/{method-name}"...
SpendProfileController { @PostMapping("/partner-organisation/{organisationId}/spend-profile/complete") public RestResult<Void> markSpendProfileComplete(@PathVariable("projectId") final long projectId, @PathVariable("organisationId") final long organisationId) { ProjectOrganisationCompositeId projectOrganisationComposit...
@Test public void markSpendProfileComplete() throws Exception { final Long projectId = 1L; final Long organisationId = 1L; final SpendProfileTableResource table = new SpendProfileTableResource(); final ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organisa...
SpendProfileController { @PostMapping("/partner-organisation/{organisationId}/spend-profile/incomplete") public RestResult<Void> markSpendProfileIncomplete(@PathVariable("projectId") final Long projectId, @PathVariable("organisationId") final Long organisationId) { ProjectOrganisationCompositeId projectOrganisationComp...
@Test public void markSpendProfileIncomplete() throws Exception { final Long projectId = 1L; final Long organisationId = 2L; final SpendProfileTableResource table = new SpendProfileTableResource(); final ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organi...
SpendProfileController { @GetMapping("/partner-organisation/{organisationId}/spend-profile-table") public RestResult<SpendProfileTableResource> getSpendProfileTable(@PathVariable("projectId") final Long projectId, @PathVariable("organisationId") final Long organisationId) { ProjectOrganisationCompositeId projectOrganis...
@Test public void getSpendProfileTable() throws Exception { final Long projectId = 1L; final Long organisationId = 1L; final ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organisationId); final SpendProfileTableResource expectedTable = new SpendProfileTabl...
SpendProfileController { @GetMapping("/partner-organisation/{organisationId}/spend-profile-csv") public RestResult<SpendProfileCSVResource> getSpendProfileCSV(@PathVariable("projectId") final Long projectId, @PathVariable("organisationId") final Long organisationId) { ProjectOrganisationCompositeId projectOrganisationC...
@Test public void getSpendProfileCsv() throws Exception { final Long projectId = 1L; final Long organisationId = 1L; final ProjectResource projectResource = newProjectResource() .withName("projectName1") .withTargetStartDate(LocalDate.of(2018, 3, 1)) .withDuration(3L) .withId(projectId) .build(); final ProjectOrganisat...
RoleProfileStatusController { @GetMapping("/role-profile-status/{roleProfileState}/{profileRole}") public RestResult<UserPageResource> getByRoleProfileStatus(@PathVariable RoleProfileState roleProfileState, @PathVariable ProfileRole profileRole, @RequestParam(required = false) String filter, @RequestParam(defaultValue ...
@Test public void getByRoleProfileStatus() throws Exception { RoleProfileState roleProfileState = RoleProfileState.ACTIVE; ProfileRole profileRole = ProfileRole.ASSESSOR; String filter = "filter"; UserPageResource userPageResource = new UserPageResource(); when(roleProfileStatusServiceMock.findByRoleProfile(eq(roleProf...
SpendProfileController { @GetMapping("/partner-organisation/{organisationId}/spend-profile") public RestResult<SpendProfileResource> getSpendProfile(@PathVariable("projectId") final Long projectId, @PathVariable("organisationId") final Long organisationId) { ProjectOrganisationCompositeId projectOrganisationCompositeId...
@Test public void getSpendProfile() throws Exception { final Long projectId = 1L; final Long organisationId = 1L; final ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organisationId); final SpendProfileResource spendProfileResource = SpendProfileResourceBui...
SpendProfileController { @PostMapping("/partner-organisation/{organisationId}/spend-profile") public RestResult<Void> saveSpendProfile(@PathVariable("projectId") final long projectId, @PathVariable("organisationId") final long organisationId, @RequestBody SpendProfileTableResource table) { ProjectOrganisationCompositeI...
@Test public void saveSpendProfile() throws Exception { final Long projectId = 1L; final Long organisationId = 1L; final SpendProfileTableResource table = new SpendProfileTableResource(); final ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organisationId);...
SpendProfileController { @PostMapping("/complete-spend-profiles-review") public RestResult<Void> completeSpendProfilesReview(@PathVariable("projectId") final Long projectId) { return spendProfileService.completeSpendProfilesReview(projectId).toPostResponse(); } @PostMapping("/spend-profile/generate") RestResult<Void> ...
@Test public void completeSpendProfilesReview() throws Exception { final Long projectId = 1L; when(spendProfileService.completeSpendProfilesReview(projectId)).thenReturn(serviceSuccess()); mockMvc.perform(post("/project/{projectId}/complete-spend-profiles-review", projectId)) .andExpect(status().isOk()); }
SpendProfileValidationUtil { public Optional<ValidationMessages> validateSpendProfileTableResource(SpendProfileTableResource tableResource) { Optional<ValidationMessages> result = Optional.empty(); BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(tableResource, "spendProfileTable"); ValidationUti...
@Test public void testValidateSpendProfileTableResource() { SpendProfileTableResource tableResource = new SpendProfileTableResource(); when(spendProfileCostValidator.supports(ArgumentMatchers.eq(SpendProfileTableResource.class))).thenReturn(Boolean.TRUE); validationUtil.validateSpendProfileTableResource(tableResource);...
ByProjectFinanceCostCategorySummaryStrategy implements SpendProfileCostCategorySummaryStrategy { @Override public ServiceResult<SpendProfileCostCategorySummaries> getCostCategorySummaries(Long projectId, Long organisationId) { return projectService.getProjectById(projectId).andOnSuccess(project -> organisationService.f...
@Test public void testGenerateSpendProfileForIndustrialOrganisation() { ProjectResource project = newProjectResource(). withDuration(10L). withCompetition(2L). build(); CompetitionResource competition = newCompetitionResource() .withIncludeJesForm(true) .build(); OrganisationResource organisation = newOrganisationResou...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { @Override @Transactional public ServiceResult<Void> generateSpendProfile(Long projectId) { return getProject(projectId) .andOnSuccess(project -> canSpendProfileCanBeGenerated(project) .andOnSuccess(() -> partnerOrganisationService...
@Test public void generateSpendProfile() { GenerateSpendProfileData generateSpendProfileData = new GenerateSpendProfileData().build(); Project project = generateSpendProfileData.getProject(); Organisation organisation1 = generateSpendProfileData.getOrganisation1(); Organisation organisation2 = generateSpendProfileData....
AgreementController { @GetMapping("/find-current") public RestResult<AgreementResource> findCurrent() { return agreementService.getCurrent().toGetResponse(); } @GetMapping("/find-current") RestResult<AgreementResource> findCurrent(); }
@Test public void findCurrent() throws Exception { String agreementText = "agreement text"; when(agreementServiceMock.getCurrent()).thenReturn(serviceSuccess(newAgreementResource().withText(agreementText).build())); mockMvc.perform(get("/agreement/find-current")) .andExpect(status().isOk()) .andExpect(jsonPath("$.text"...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { @Override public ServiceResult<SpendProfileCSVResource> getSpendProfileCSV(ProjectOrganisationCompositeId projectOrganisationCompositeId) { SpendProfileTableResource spendProfileTableResource = getSpendProfileTable(projectOrganisa...
@Test public void generateSpendProfileCSV() { Project project = newProject().withId(projectId).withDuration(3L).withTargetStartDate(LocalDate.of(2018, 3, 1)).build(); ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organisationId); SpendProfile spendProfileI...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { @Override public ServiceResult<ApprovalType> getSpendProfileStatusByProjectId(Long projectId) { return serviceSuccess(getSpendProfileStatusBy(projectId)); } @Override @Transactional ServiceResult<Void> generateSpendProfile(Long p...
@Test public void getSpendProfileStatusByProjectIdApproved() { Project project = newProject().build(); when(projectRepository.findById(projectId)).thenReturn(Optional.of(project)); when(spendProfileWorkflowHandler.getApproval(project)).thenReturn(ApprovalType.APPROVED); ServiceResult<ApprovalType> result = service.getS...
UserController { @PutMapping("/" + URL_RESEND_EMAIL_VERIFICATION_NOTIFICATION + "/{emailAddress}/") public RestResult<Void> resendEmailVerificationNotification(@PathVariable String emailAddress) { return userService.findInactiveByEmail(emailAddress) .andOnSuccessReturn(user -> registrationService.resendUserVerification...
@Test public void resendEmailVerificationNotification() throws Exception { final String emailAddress = "sample@me.com"; final UserResource userResource = newUserResource().build(); when(userServiceMock.findInactiveByEmail(emailAddress)).thenReturn(serviceSuccess(userResource)); when(registrationServiceMock.resendUserVe...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { private ServiceResult<Void> approveSpendProfile(ApprovalType approvalType, Project project) { return getCurrentlyLoggedInUser().andOnSuccess(user -> { if (approvalType.equals(APPROVED)) { if (spendProfileWorkflowHandler.spendProfi...
@Test public void approveSpendProfile() { List<SpendProfile> spendProfileList = getSpendProfilesAndSetWhenSpendProfileRepositoryMock(projectId); Project project = newProject().withId(projectId).withDuration(3L).withTargetStartDate(LocalDate.of(2018, 3, 1)).withSpendProfileSubmittedDate(ZonedDateTime.now()).build(); whe...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { @Override @Transactional public ServiceResult<Void> approveOrRejectSpendProfile(Long projectId, ApprovalType approvalType) { Project project = projectRepository.findById(projectId).orElse(null); if (null != project && spendProfile...
@Test public void rejectSpendProfile() { Long projectId = 4234L; List<SpendProfile> spendProfileList = getSpendProfilesAndSetWhenSpendProfileRepositoryMock(projectId); Project project = newProject().withId(projectId).withDuration(3L).withTargetStartDate(LocalDate.of(2018, 3, 1)).withSpendProfileSubmittedDate(ZonedDateT...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { @Override @Transactional public ServiceResult<Void> deleteSpendProfile(Long projectId) { List<SpendProfile> spendProfiles = spendProfileRepository.findByProjectId(projectId); Project project = getProject(projectId).getSuccess(); p...
@Test public void deleteSpendProfile() { Long userId = 1234L; UserResource loggedInUser = newUserResource().withId(userId).build(); User user = newUser().withId(loggedInUser.getId()).build(); setLoggedInUser(loggedInUser); Long projectId = 4234L; List<SpendProfile> spendProfileList = getSpendProfilesAndSetWhenSpendProf...
UserController { @GetMapping("/find-all/") public RestResult<List<UserResource>> findAll() { return baseUserService.findAll().toGetResponse(); } @GetMapping("/uid/{uid}") RestResult<UserResource> getUserByUid(@PathVariable String uid); @GetMapping("/id/{id}") RestResult<UserResource> getUserById(@PathVariable long id)...
@Test public void userControllerShouldReturnAllUsers() throws Exception { UserResource testUser1 = newUserResource().withId(1L).withFirstName("test").withLastName("User1").withEmail("email1@email.nl").build(); UserResource testUser2 = newUserResource().withId(2L).withFirstName("test").withLastName("User2").withEmail("e...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { @Override @Transactional public ServiceResult<Void> saveSpendProfile(ProjectOrganisationCompositeId projectOrganisationCompositeId, SpendProfileTableResource table) { return validateSpendProfileCosts(table) .andOnSuccess(() -> sav...
@Test public void saveSpendProfileWhenValidationFails() { ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organisationId); SpendProfileTableResource table = new SpendProfileTableResource(); table.setMonthlyCostsPerCategoryMap(Collections.emptyMap()); Validat...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { @Override @Transactional public ServiceResult<Void> markSpendProfileIncomplete(ProjectOrganisationCompositeId projectOrganisationCompositeId) { SpendProfileTableResource table = getSpendProfileTable(projectOrganisationCompositeId)...
@Test public void markSpendProfileIncomplete() { ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organisationId); Project projectInDB = ProjectBuilder.newProject() .withDuration(3L) .withTargetStartDate(LocalDate.of(2018, 3, 1)) .withId(projectId) .build(); ...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { @Override @Transactional public ServiceResult<Void> markSpendProfileComplete(ProjectOrganisationCompositeId projectOrganisationCompositeId) { SpendProfileTableResource table = getSpendProfileTable(projectOrganisationCompositeId).g...
@Test public void markSpendProfileWhenActualTotalsGreaterThanEligibleCosts() { ProjectOrganisationCompositeId projectOrganisationCompositeId = new ProjectOrganisationCompositeId(projectId, organisationId); Project projectInDB = ProjectBuilder.newProject() .withDuration(3L) .withTargetStartDate(LocalDate.of(2018, 3, 1))...
SpendProfileServiceImpl extends BaseTransactionalService implements SpendProfileService { @Override @Transactional public ServiceResult<Void> completeSpendProfilesReview(Long projectId) { return getProject(projectId).andOnSuccess(project -> { if (project.getSpendProfiles().stream().anyMatch(spendProfile -> !spendProfil...
@Test public void completeSpendProfilesReviewSuccess() { Project projectInDb = new Project(); projectInDb.setSpendProfileSubmittedDate(null); SpendProfile spendProfileInDb = new SpendProfile(); spendProfileInDb.setMarkedAsComplete(true); projectInDb.setSpendProfiles(singletonList(spendProfileInDb)); when(projectReposit...
ProjectPartnerInviteServiceImpl extends BaseTransactionalService implements ProjectPartnerInviteService { @Override @Transactional public ServiceResult<Void> invitePartnerOrganisation(long projectId, SendProjectPartnerInviteResource invite) { return find(projectRepository.findById(projectId), notFoundError(Project.clas...
@Test public void invite() { setField(service, "webBaseUrl", "webBaseUrl"); long projectId = 1L; String organisationName = "Org"; String userName = "Someone"; String email = "someone@gmail.com"; Application application = newApplication().build(); Organisation leadOrg = newOrganisation() .withName("Lead org") .build(); ...
ProjectPartnerInviteServiceImpl extends BaseTransactionalService implements ProjectPartnerInviteService { @Override public ServiceResult<List<SentProjectPartnerInviteResource>> getPartnerInvites(long projectId) { return serviceSuccess(projectPartnerInviteRepository.findByProjectId(projectId).stream() .filter(invite -> ...
@Test public void getPartnerInvites() { long projectId = 1L; long inviteId = 2L; long applicationId = 3L; long competitionId = 4L; String email = "Partner@gmail.com"; String userName = "Partner"; String organisationName = "Partners Ltd."; ZonedDateTime sentOn = now(); ProjectPartnerInvite invite = new ProjectPartnerInv...
UserController { @GetMapping("/id/{id}") public RestResult<UserResource> getUserById(@PathVariable long id) { return baseUserService.getUserById(id).toGetResponse(); } @GetMapping("/uid/{uid}") RestResult<UserResource> getUserByUid(@PathVariable String uid); @GetMapping("/id/{id}") RestResult<UserResource> getUserById...
@Test public void userControllerShouldReturnUserById() throws Exception { UserResource testUser1 = newUserResource().withId(1L).withFirstName("test").withLastName("User1").withEmail("email1@email.nl").build(); when(baseUserServiceMock.getUserById(testUser1.getId())).thenReturn(serviceSuccess(testUser1)); mockMvc.perfor...
ProjectPartnerInviteServiceImpl extends BaseTransactionalService implements ProjectPartnerInviteService { @Override @Transactional public ServiceResult<Void> resendInvite(long inviteId) { return find(projectPartnerInviteRepository.findById(inviteId), notFoundError(ProjectPartnerInvite.class, inviteId)) .andOnSuccess(th...
@Test public void resendInvite() { setField(service, "webBaseUrl", "webBaseUrl"); long inviteId = 2L; String userName = "Someone"; String email = "someone@gmail.com"; Application application = newApplication().build(); Organisation leadOrg = newOrganisation() .withName("Lead org") .build(); Project project = newProject...
ProjectPartnerInviteServiceImpl extends BaseTransactionalService implements ProjectPartnerInviteService { @Override @Transactional public ServiceResult<Void> deleteInvite(long inviteId) { return find(projectPartnerInviteRepository.findById(inviteId), notFoundError(ProjectPartnerInvite.class, inviteId)) .andOnSuccessRet...
@Test public void deleteInvite() { long inviteId = 2L; ProjectPartnerInvite invite = new ProjectPartnerInvite(); when(projectPartnerInviteRepository.findById(inviteId)).thenReturn(of(invite)); service.deleteInvite(inviteId); verify(projectPartnerInviteRepository).delete(invite); }
ProjectPartnerInviteServiceImpl extends BaseTransactionalService implements ProjectPartnerInviteService { @Override public ServiceResult<SentProjectPartnerInviteResource> getInviteByHash(String hash) { return find(projectPartnerInviteRepository.getByHash(hash), notFoundError(ProjectPartnerInvite.class, hash)) .andOnSuc...
@Test public void getInviteByHash() { String hash = "hash"; String email = "Partner@gmail.com"; String userName = "Partner"; String organisationName = "Partners Ltd."; long applicationId = 3L; long competitionId = 4L; ZonedDateTime sentOn = now(); ProjectPartnerInvite invite = new ProjectPartnerInvite(); InviteOrganisa...
ProjectPartnerInviteServiceImpl extends BaseTransactionalService implements ProjectPartnerInviteService { @Override @Transactional public ServiceResult<Void> acceptInvite(long inviteId, long organisationId) { return find(projectPartnerInviteRepository.findById(inviteId), notFoundError(ProjectPartnerInvite.class, invite...
@Test public void acceptInvite() { long inviteId = 1L; long organisationId = 2L; Competition competition = newCompetition().withIncludeJesForm(true).build(); Application application = newApplication().withCompetition(competition).build(); Project project = newProject().withApplication(application).build(); ProjectPartn...
ApplicationFundingDecisionController { @PostMapping(value="/{competitionId}") public RestResult<Void> saveFundingDecisionData(@PathVariable("competitionId") final Long competitionId, @RequestBody Map<Long, FundingDecision> applicationFundingDecisions) { return applicationFundingService.saveFundingDecisionData(competiti...
@Test public void testSaveApplicationFundingDecisionData() throws Exception { Long competitionId = 1L; Map<Long, FundingDecision> decision = asMap(1L, FundingDecision.FUNDED, 2L, FundingDecision.UNFUNDED); when(applicationFundingServiceMock.saveFundingDecisionData(competitionId, decision)).thenReturn(serviceSuccess());...
ApplicationNotificationTemplateController { @GetMapping("/successful/{competitionId}") public RestResult<ApplicationNotificationTemplateResource> getSuccessfulNotificationTemplate(@PathVariable("competitionId") long competitionId) { return applicationNotificationTemplateService.getSuccessfulNotificationTemplate(competi...
@Test public void getSuccessfulNotificationTemplate() throws Exception { Long competitionId = 1L; ApplicationNotificationTemplateResource resource = new ApplicationNotificationTemplateResource(); when(applicationNotificationTemplateService.getSuccessfulNotificationTemplate(competitionId)).thenReturn(serviceSuccess(reso...
ApplicationNotificationTemplateController { @GetMapping("/unsuccessful/{competitionId}") public RestResult<ApplicationNotificationTemplateResource> getUnsuccessfulNotificationTemplate(@PathVariable("competitionId") long competitionId) { return applicationNotificationTemplateService.getUnsuccessfulNotificationTemplate(c...
@Test public void getUnsuccessfulNotificationTemplate() throws Exception { Long competitionId = 1L; ApplicationNotificationTemplateResource resource = new ApplicationNotificationTemplateResource(); when(applicationNotificationTemplateService.getUnsuccessfulNotificationTemplate(competitionId)).thenReturn(serviceSuccess(...
ApplicationNotificationTemplateController { @GetMapping("/ineligible/{competitionId}") public RestResult<ApplicationNotificationTemplateResource> getIneligibleNotificationTemplate(@PathVariable("competitionId") long competitionId) { return applicationNotificationTemplateService.getIneligibleNotificationTemplate(competi...
@Test public void getIneligibleNotificationTemplate() throws Exception { long competitionId = 1L; long userId = 2L; ApplicationNotificationTemplateResource resource = new ApplicationNotificationTemplateResource(); when(applicationNotificationTemplateService.getIneligibleNotificationTemplate(competitionId)).thenReturn(s...
FundingDecisionMapper { public FundingDecisionStatus mapToDomain(FundingDecision source){ return FundingDecisionStatus.valueOf(source.name()); } FundingDecision mapToResource(FundingDecisionStatus source); FundingDecisionStatus mapToDomain(FundingDecision source); }
@Test public void testConvertFromResourceToDomain() { for(FundingDecision decision: FundingDecision.values()){ FundingDecisionStatus status = mapper.mapToDomain(decision); assertEquals(decision.name(), status.name()); } }
FundingDecisionMapper { public FundingDecision mapToResource(FundingDecisionStatus source){ return FundingDecision.valueOf(source.name()); } FundingDecision mapToResource(FundingDecisionStatus source); FundingDecisionStatus mapToDomain(FundingDecision source); }
@Test public void testConvertFromDomainToResource() { for(FundingDecisionStatus status: FundingDecisionStatus.values()){ FundingDecision decision = mapper.mapToResource(status); assertEquals(status.name(), decision.name()); } }
UserController { @GetMapping("/" + URL_VERIFY_EMAIL + "/{hash}") public RestResult<Void> verifyEmail(@PathVariable String hash) { final ServiceResult<Token> result = tokenService.getEmailToken(hash); LOG.debug(String.format("UserController verifyHash: %s", hash)); return result.handleSuccessOrFailure( failure -> restFa...
@Test public void verifyEmail() throws Exception { final String hash = "8eda60ad3441ee883cc95417e2abaa036c308dd9eb19468fcc8597fb4cb167c32a7e5daf5e237385"; final Long userId = 1L; final Token token = new Token(VERIFY_EMAIL_ADDRESS, User.class.getName(), userId, hash, now(), null); when(tokenServiceMock.getEmailToken(has...
ApplicationNotificationTemplateServiceImpl extends BaseTransactionalService implements ApplicationNotificationTemplateService { @Override public ServiceResult<ApplicationNotificationTemplateResource> getSuccessfulNotificationTemplate(long competitionId) { return getCompetition(competitionId).andOnSuccess(competition ->...
@Test public void getSuccessfulNotificationTemplate() { ZonedDateTime feedbackDate = ZonedDateTime.now(); Competition competition = newCompetition() .withName("Competition") .withFundingType(GRANT) .withReleaseFeedbackDate(feedbackDate) .build(); Map<String, Object> arguments = new HashMap<>(); arguments.put("competiti...
ApplicationNotificationTemplateServiceImpl extends BaseTransactionalService implements ApplicationNotificationTemplateService { @Override public ServiceResult<ApplicationNotificationTemplateResource> getUnsuccessfulNotificationTemplate(long competitionId) { return getCompetition(competitionId).andOnSuccess(competition ...
@Test public void getUnsuccessfulNotificationTemplate() { ZonedDateTime feedbackDate = ZonedDateTime.now(); Competition competition = newCompetition() .withName("Competition") .withFundingType(GRANT) .withReleaseFeedbackDate(feedbackDate) .build(); Map<String, Object> arguments = new HashMap<>(); arguments.put("competi...
ApplicationNotificationTemplateServiceImpl extends BaseTransactionalService implements ApplicationNotificationTemplateService { @Override public ServiceResult<ApplicationNotificationTemplateResource> getIneligibleNotificationTemplate(long competitionId) { return renderTemplate(competitionId, "ineligible_application.htm...
@Test public void getIneligibleNotificationTemplate() { Competition competition = newCompetition().withName("Competition").build(); Map<String, Object> arguments = new HashMap<>(); arguments.put("competitionName", competition.getName()); when(competitionRepository.findById(competitionId)).thenReturn(Optional.of(competi...
ApplicationFundingServiceImpl extends BaseTransactionalService implements ApplicationFundingService { @Override @Transactional public ServiceResult<Void> notifyApplicantsOfFundingDecisions(FundingNotificationResource fundingNotificationResource) { List<Application> applications = getFundingApplications(fundingNotificat...
@Test public void testNotifyLeadApplicantsOfFundingDecisions() { CompetitionAssessmentConfig competitionAssessmentConfig = new CompetitionAssessmentConfig(); Competition competition = newCompetition() .withCompetitionAssessmentConfig(competitionAssessmentConfig) .build(); Application application1 = newApplication().wit...
ApplicationFundingServiceImpl extends BaseTransactionalService implements ApplicationFundingService { @Override @Transactional public ServiceResult<Void> saveFundingDecisionData(Long competitionId, Map<Long, FundingDecision> applicationFundingDecisions) { if (applicationFundingDecisions.isEmpty()) { return serviceFailu...
@Test public void testSaveFundingDecisionData() { Application application1 = newApplication().withId(1L).withCompetition(competition).withFundingDecision(FundingDecisionStatus.FUNDED).withApplicationState(ApplicationState.OPENED).build(); Application application2 = newApplication().withId(2L).withCompetition(competitio...
UserController { @GetMapping("/find-by-email/{email}/") public RestResult<UserResource> findByEmail(@PathVariable String email) { return userService.findByEmail(email).toGetResponse(); } @GetMapping("/uid/{uid}") RestResult<UserResource> getUserByUid(@PathVariable String uid); @GetMapping("/id/{id}") RestResult<UserRe...
@Test public void userControllerShouldReturnListOfSingleUserWhenFoundByEmail() throws Exception { User user = new User(); user.setEmail("testemail@email.email"); user.setFirstName("testFirstName"); user.setLastName("testLastName"); user.setPhoneNumber("testPhoneNumber"); user.setFirstName("testFirstName"); user.setLast...
RestSilEmailEndpoint implements SilEmailEndpoint { @Override public ServiceResult<SilEmailMessage> sendEmail(SilEmailMessage message) { return handlingErrors(() -> { final Either<ResponseEntity<Void>, ResponseEntity<Void>> response = adaptor.restPostWithEntity(silRestServiceUrl + silSendmailPath, message, Void.class, V...
@Test public void testSendEmail() { SilEmailAddress from = new SilEmailAddress("Sender", "sender@example.com"); List<SilEmailAddress> to = singletonList(new SilEmailAddress("Recipient", "recipient@example.com")); SilEmailBody plainTextBody = new SilEmailBody("text/plain", "Some plain text"); SilEmailBody htmlBody = new...
AffiliationController { @GetMapping("/id/{userId}/get-user-affiliations") public RestResult<AffiliationListResource> getUserAffiliations(@PathVariable("userId") long userId) { return affiliationService.getUserAffiliations(userId).toGetResponse(); } @GetMapping("/id/{userId}/get-user-affiliations") RestResult<Affiliati...
@Test public void getUserAffiliations() throws Exception { Long userId = 1L; List<AffiliationResource> affiliations = newAffiliationResource().build(2); AffiliationListResource affiliationListResource = newAffiliationListResource() .withAffiliationList(affiliations) .build(); when(affiliationServiceMock.getUserAffiliat...
AffiliationController { @PutMapping("/id/{userId}/update-user-affiliations") public RestResult<Void> updateUserAffiliations(@PathVariable("userId") long userId, @Valid @RequestBody AffiliationListResource affiliations) { return affiliationService.updateUserAffiliations(userId, affiliations).toPutResponse(); } @GetMapp...
@Test public void updateUserAffiliations() throws Exception { Long userId = 1L; List<AffiliationResource> affiliations = newAffiliationResource().build(2); AffiliationListResource affiliationListResource = newAffiliationListResource() .withAffiliationList(affiliations) .build(); when(affiliationServiceMock.updateUserAf...
AffiliationServiceImpl extends BaseTransactionalService implements AffiliationService { @Override public ServiceResult<AffiliationListResource> getUserAffiliations(long userId) { return find(userRepository.findById(userId), notFoundError(User.class, userId)).andOnSuccess(user -> serviceSuccess(new AffiliationListResour...
@Test public void getUserAffiliations() throws Exception { Long userId = 1L; List<Affiliation> affiliations = newAffiliation().build(2); List<AffiliationResource> affiliationResources = newAffiliationResource().build(2); when(affiliationMapperMock.mapToResource(affiliations.get(0))).thenReturn(affiliationResources.get(...