src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
EuGrantTransferController { @GetMapping(value = "/grant-agreement-details/{applicationId}", produces = "application/json") public RestResult<FileEntryResource> findGrantAgreement(@PathVariable("applicationId") long applicationId) { return euGrantTransferService.findGrantAgreement(applicationId).toGetResponse(); } @Get...
@Test public void findGrantAgreement() throws Exception { final long applicationId = 22L; FileEntryResource fileEntryResource = new FileEntryResource(1L, "name", "application/pdf", 1234); when(euGrantTransferService.findGrantAgreement(applicationId)).thenReturn(serviceSuccess(fileEntryResource)); mockMvc.perform(get("/...
EuGrantTransferController { @GetMapping(value = "{applicationId}", produces = "application/json") public RestResult<EuGrantTransferResource> getGrantTransferByApplicationId(@PathVariable("applicationId") long applicationId) { return euGrantTransferService.getGrantTransferByApplicationId(applicationId).toGetResponse(); ...
@Test public void getGrantTransferByApplicationId() throws Exception { final long applicationId = 22L; EuGrantTransferResource grantTransferResource = newEuGrantTransferResource().build(); when(euGrantTransferService.getGrantTransferByApplicationId(applicationId)).thenReturn(serviceSuccess(grantTransferResource)); mock...
EuGrantTransferServiceImpl implements EuGrantTransferService { @Override public ServiceResult<FileEntryResource> findGrantAgreement(long applicationId) { return findGrantTransferByApplicationId(applicationId).andOnSuccess(grantTransfer -> ofNullable(grantTransfer.getGrantAgreement()) .map(FileEntry::getId) .map(fileEnt...
@Test public void findGrantAgreement() { long applicationId = 1L; FileEntry fileEntry = newFileEntry().build(); EuGrantTransfer grantTransfer = newEuGrantTransfer() .withGrantAgreement(fileEntry) .build(); FileEntryResource fileEntryResource = newFileEntryResource().build(); when(euGrantTransferRepository.findByApplica...
EuGrantTransferServiceImpl implements EuGrantTransferService { @Override public ServiceResult<FileAndContents> downloadGrantAgreement(long applicationId) { return findGrantTransferByApplicationId(applicationId).andOnSuccess(grantTransfer -> fileEntryService.findOne(grantTransfer.getGrantAgreement().getId()) .andOnSucce...
@Test public void downloadGrantAgreement() { final long applicationId = 1L; final long fileId = 2L; final FileEntry fileEntry = new FileEntry(fileId, "somefile.pdf", MediaType.APPLICATION_PDF, 1111L); EuGrantTransfer grantTransfer = newEuGrantTransfer() .withGrantAgreement(fileEntry) .build(); FileEntryResource fileEnt...
EuGrantTransferServiceImpl implements EuGrantTransferService { @Override @Transactional public ServiceResult<Void> deleteGrantAgreement(long applicationId) { return findGrantTransferByApplicationId(applicationId).andOnSuccess(grantTransfer -> { long fileId = grantTransfer.getGrantAgreement().getId(); return fileService...
@Test public void deleteGrantAgreement() { final long applicationId = 1L; final long fileId = 101L; final FileEntry fileEntry = new FileEntry(fileId, "somefile.pdf", MediaType.APPLICATION_PDF, 1111L); EuGrantTransfer grantTransfer = newEuGrantTransfer() .withGrantAgreement(fileEntry) .build(); when(euGrantTransferRepos...
EuGrantTransferServiceImpl implements EuGrantTransferService { @Override @Transactional public ServiceResult<Void> uploadGrantAgreement(String contentType, String contentLength, String originalFilename, long applicationId, HttpServletRequest request) { return findGrantTransferByApplicationIdCreateIfNotExists(applicatio...
@Test public void uploadGrantAgreement() { FileControllerUtils fileControllerUtils = mock(FileControllerUtils.class); Long maxFileSize = 2L; List<String> validMediaTypes = asList("PDF"); setField(service, "fileControllerUtils", fileControllerUtils); setField(service, "maxFileSize", maxFileSize); setField(service, "vali...
EuGrantTransferServiceImpl implements EuGrantTransferService { @Override public ServiceResult<EuGrantTransferResource> getGrantTransferByApplicationId(long applicationId) { return findGrantTransferByApplicationId(applicationId).andOnSuccessReturn(mapper::mapToResource); } @Override @Transactional ServiceResult<Void> u...
@Test public void getGrantTransferByApplicationId() { long applicationId = 1L; EuGrantTransfer grantTransfer = newEuGrantTransfer() .build(); EuGrantTransferResource grantTransferResource = newEuGrantTransferResource().build(); when(euGrantTransferRepository.findByApplicationId(applicationId)).thenReturn(grantTransfer)...
EuGrantTransferServiceImpl implements EuGrantTransferService { @Override @Transactional public ServiceResult<Void> updateGrantTransferByApplicationId(EuGrantTransferResource euGrantTransferResource, long applicationId) { return findGrantTransferByApplicationIdCreateIfNotExists(applicationId).andOnSuccessReturnVoid(doma...
@Test public void updateGrantTransferByApplicationId() { LocalDate start = LocalDate.of(2021, 4, 5); setField(service, "horizon2020StartDate", start); long applicationId = 1L; EuActionTypeResource euActionTypeResource = new EuActionTypeResource(); euActionTypeResource.setId(2L); EuGrantTransferResource grantTransferRes...
ApplicantController { @GetMapping("/{userId}/{applicationId}/question/{questionId}") public RestResult<ApplicantQuestionResource> getQuestion(@PathVariable("userId") final Long userId, @PathVariable("applicationId") final Long applicationId, @PathVariable("questionId") final Long questionId) { return applicantService.g...
@Test public void getQuestion() throws Exception { when(applicationService.getQuestion(USER_ID, QUESTION_ID, APPLICATION_ID)).thenReturn(serviceSuccess(applicantQuestionResource().build())); mockMvc.perform(get("/applicant/{user}/{application}/question/{question}", USER_ID, APPLICATION_ID, QUESTION_ID) .header("IFS_AUT...
ApplicantController { @GetMapping("/{userId}/{applicationId}/section/{sectionId}") public RestResult<ApplicantSectionResource> getSection(@PathVariable("userId") final Long userId, @PathVariable("applicationId") final Long applicationId, @PathVariable("sectionId") final Long sectionId) { return applicantService.getSect...
@Test public void getSection() throws Exception { when(applicationService.getSection(USER_ID, SECTION_ID, APPLICATION_ID)).thenReturn(serviceSuccess(applicantSectionResource().build())); mockMvc.perform(get("/applicant/{user}/{application}/section/{section}", USER_ID, APPLICATION_ID, QUESTION_ID) .header("IFS_AUTH_TOKE...
ApplicantController { @GetMapping("/{userId}/applications/dashboard" ) public RestResult<ApplicantDashboardResource> getApplicantDashboard(@PathVariable("userId") final long userId) { return applicationDashboardService.getApplicantDashboard(userId).toGetResponse(); } ApplicantController(); @Autowired ApplicantControll...
@Test public void getApplicantDashboard() throws Exception { long euGrantTransferId = 1L; long inProgressId = 2L; long inSetupId = 3L; long previousId = 4L; DashboardEuGrantTransferRowResource euGrantTransfer = new DashboardApplicationForEuGrantTransferResourceBuilder().withApplicationId(euGrantTransferId).build(); Das...
CrmServiceImpl implements CrmService { @Override public ServiceResult<Void> syncCrmContact(long userId) { return userService.getUserById(userId).andOnSuccess(user -> { syncExternalUser(user); syncMonitoringOfficer(user); return serviceSuccess(); }); } @Override ServiceResult<Void> syncCrmContact(long userId); }
@Test public void syncExternalCrmContact() { long userId = 1L; UserResource user = newUserResource().withRoleGlobal(APPLICANT).build(); List<OrganisationResource> organisations = newOrganisationResource().withCompaniesHouseNumber("Something", "Else").build(2); when(baseUserService.getUserById(userId)).thenReturn(servic...
AuthenticationRequestWrapper extends HttpServletRequestWrapper { @Override public ServletInputStream getInputStream() throws IOException { ByteArrayInputStream inputStream = new ByteArrayInputStream(body.getBytes()); return new ServletInputStream() { @Override public boolean isFinished() { return inputStream.available(...
@Test public void getInputStream() throws Exception { ServletInputStream first = authenticationRequestWrapper.getInputStream(); assertEquals("First call to getInputStream should match request content", content, IOUtils.toString(first, "UTF-8")); ServletInputStream second = authenticationRequestWrapper.getInputStream();...
AuthenticationRequestWrapper extends HttpServletRequestWrapper { @Override public BufferedReader getReader() throws IOException { return new BufferedReader(new InputStreamReader(this.getInputStream())); } AuthenticationRequestWrapper(HttpServletRequest request); @Override ServletInputStream getInputStream(); @Override ...
@Test public void getReader() throws Exception { Reader first = authenticationRequestWrapper.getReader(); assertEquals("First call to getInputStream should match request content", content, IOUtils.toString(first)); Reader second = authenticationRequestWrapper.getReader(); assertEquals("Subsequent calls to getInputStrea...
RegistrationServiceImpl extends BaseTransactionalService implements RegistrationService { @Override @Transactional @UserUpdate public ServiceResult<UserResource> activateUser(long userId) { return getUser(userId).andOnSuccess(this::activateUser) .andOnSuccessReturn(userMapper::mapToResource); } @Override @Transactiona...
@Test public void activateUser_success() { setUpUsersForEditInternalUserSuccess(); when(userRepositoryMock.findById(userToEdit.getId())).thenReturn(Optional.of(userInDB)); when(idpServiceMock.activateUser(userToEdit.getUid())).thenReturn(ServiceResult.serviceSuccess("")); userInDB.setStatus(UserStatus.ACTIVE); when(use...
TokenAuthenticationService { public AuthenticationToken getAuthentication(HttpServletRequest request) { if (isHashValidForRequest(request)) { return new AuthenticationToken(); } return null; } @Autowired TokenAuthenticationService(@Value("${ifs.finance-totals.authSecretKey}") String secretKey, ...
@Test public void getAuthentication() throws Exception { String token = "f6d99caceac489fd2d4ba8106d15e64bd7455fd83305f13a7faa32fb3b02fa28"; MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); httpServletRequest.addHeader("X-AUTH-TOKEN", token); httpServletRequest.setContent("input".getBytes()); as...
CostTotalController { @PostMapping("/cost-total") public RestResult<Void> addCostTotal(@NotNull @RequestBody FinanceCostTotalResource financeCostTotalResource) { return costTotalService.saveCostTotal(financeCostTotalResource).toPostCreateResponse(); } @Autowired CostTotalController(CostTotalService costTotalService); ...
@Test public void addCostTotal() throws Exception { FinanceCostTotalResource financeCostTotalResource = new FinanceCostTotalResource( FinanceType.APPLICATION, FinanceRowType.LABOUR, new BigDecimal("999999999.999999"), 1L ); Consumer<FinanceCostTotalResource> matchesExpectedResource = (resource) -> { assertThat(resource...
CostTotalController { @PostMapping("/cost-totals") public RestResult<Void> addCostTotals(@NotNull @RequestBody List<FinanceCostTotalResource> financeCostTotalResources) { LOG.debug("Initiating addCostTotals for financeIds: {}", financeCostTotalResources.stream().map(financeCostTotalResource -> String.valueOf(financeCos...
@Test public void addCostTotals() throws Exception { List<FinanceCostTotalResource> financeCostTotalResources = newFinanceCostTotalResource() .withFinanceType(FinanceType.APPLICATION) .withFinanceRowType(FinanceRowType.LABOUR, FinanceRowType.MATERIALS) .withFinanceId(1L, 2L) .withTotal(new BigDecimal("999.999999"), new...
HashBasedMacTokenHandler { public String calculateHash(String key, String input) throws InvalidKeyException { Mac mac; try { mac = Mac.getInstance(ALGORITHM); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Failed to initialise MAC object: " + e.getMessage(), e); } mac.init(getKey(key)); return ...
@Test public void calculateHash() throws Exception { assertEquals("f6d99caceac489fd2d4ba8106d15e64bd7455fd83305f13a7faa32fb3b02fa28", hashBasedMacTokenHandler.calculateHash("supersecretkey", "input")); } @Test(expected = IllegalArgumentException.class) public void calculateHash_nullKey() throws Exception { hashBasedMac...
AlertPermissionRules { @PermissionRule(value = "CREATE", description = "System maintentenance users can create Alerts") public boolean systemMaintenanceUserCanCreateAlerts(final AlertResource alertResource, final UserResource user) { return isSystemMaintenanceUser(user); } @PermissionRule(value = "CREATE", description...
@Test public void systemMaintenanceUserCanCreateAlerts() throws Exception { assertTrue(rules.systemMaintenanceUserCanCreateAlerts(alertResource, systemMaintenanceUser())); } @Test public void systemMaintenanceUserCanCreateAlerts_anonymous() throws Exception { assertFalse(rules.systemMaintenanceUserCanCreateAlerts(alert...
AlertPermissionRules { @PermissionRule(value = "DELETE", description = "System maintentenance users can delete Alerts") public boolean systemMaintenanceUserCanDeleteAlerts(final AlertResource alertResource, final UserResource user) { return isSystemMaintenanceUser(user); } @PermissionRule(value = "CREATE", description...
@Test public void systemMaintenanceUserCanDeleteAlerts() throws Exception { assertTrue(rules.systemMaintenanceUserCanDeleteAlerts(alertResource, systemMaintenanceUser())); } @Test public void systemMaintenanceUserCanDeleteAlerts_anonymous() throws Exception { assertFalse(rules.systemMaintenanceUserCanDeleteAlerts(alert...
AlertController { @GetMapping("/find-all-visible") public RestResult<List<AlertResource>> findAllVisible() { return alertService.findAllVisible().toGetResponse(); } @GetMapping("/find-all-visible") RestResult<List<AlertResource>> findAllVisible(); @GetMapping("/find-all-visible/{type}") RestResult<List<AlertResource>>...
@Test public void test_findAllVisible() throws Exception { final AlertResource expected1 = AlertResourceBuilder.newAlertResource() .withId(8888L) .build(); final AlertResource expected2 = AlertResourceBuilder.newAlertResource() .withId(9999L) .build(); final List<AlertResource> expected = new ArrayList<>(asList(expecte...
AlertController { @GetMapping("/find-all-visible/{type}") public RestResult<List<AlertResource>> findAllVisibleByType(@PathVariable("type") AlertType type) { return alertService.findAllVisibleByType(type).toGetResponse(); } @GetMapping("/find-all-visible") RestResult<List<AlertResource>> findAllVisible(); @GetMapping(...
@Test public void test_findAllVisibleByType() throws Exception { final AlertResource expected1 = AlertResourceBuilder.newAlertResource() .withId(8888L) .build(); final AlertResource expected2 = AlertResourceBuilder.newAlertResource() .withId(9999L) .build(); final List<AlertResource> expected = new ArrayList<>(asList(e...
AlertController { @GetMapping("/{id}") public RestResult<AlertResource> findById(@PathVariable("id") Long id) { return alertService.findById(id).toGetResponse(); } @GetMapping("/find-all-visible") RestResult<List<AlertResource>> findAllVisible(); @GetMapping("/find-all-visible/{type}") RestResult<List<AlertResource>> ...
@Test public void test_getById() throws Exception { final AlertResource expected = AlertResourceBuilder.newAlertResource() .withId(9999L) .build(); when(alertServiceMock.findById(9999L)).thenReturn(serviceSuccess(expected)); mockMvc.perform(get("/alert/{id}", 9999L)) .andExpect(status().isOk()) .andExpect(content().str...
AlertController { @PostMapping("/") public RestResult<AlertResource> create(@RequestBody AlertResource alertResource) { return alertService.create(alertResource).toPostCreateResponse(); } @GetMapping("/find-all-visible") RestResult<List<AlertResource>> findAllVisible(); @GetMapping("/find-all-visible/{type}") RestResu...
@Test public void test_create() throws Exception { final AlertResource alertResource = AlertResourceBuilder.newAlertResource() .build(); final AlertResource expected = AlertResourceBuilder.newAlertResource() .withId(9999L) .build(); when(alertServiceMock.create(alertResource)).thenReturn(serviceSuccess(expected)); mock...
AlertController { @DeleteMapping("/{id}") public RestResult<Void> delete(@PathVariable("id") Long id) { return alertService.delete(id).toDeleteResponse(); } @GetMapping("/find-all-visible") RestResult<List<AlertResource>> findAllVisible(); @GetMapping("/find-all-visible/{type}") RestResult<List<AlertResource>> findAll...
@Test public void test_delete() throws Exception { when(alertServiceMock.delete(9999L)).thenReturn(serviceSuccess()); mockMvc.perform(delete("/alert/{id}", 9999L)) .andExpect(status().isNoContent()) .andExpect(content().string(isEmptyString())) .andDo(document("alert/delete", pathParameters( parameterWithName("id").des...
AlertServiceImpl extends RootTransactionalService implements AlertService { @Override public ServiceResult<List<AlertResource>> findAllVisible() { return serviceSuccess(simpleMap(alertRepository.findAllVisible(now()), alertMapper::mapToResource)); } @Override ServiceResult<List<AlertResource>> findAllVisible(); @Overr...
@Test public void findAllVisible() throws Exception { final Alert alert1 = new Alert(); final Alert alert2 = new Alert(); final List<Alert> alerts = new ArrayList<>(asList(alert1, alert2)); final AlertResource expected1 = AlertResourceBuilder.newAlertResource() .build(); final AlertResource expected2 = AlertResourceBui...
EmailNotificationSender implements NotificationSender { @Override public ServiceResult<Notification> sendNotification(Notification notification) { return renderTemplates(notification).andOnSuccess(templates -> { List<ServiceResult<List<EmailAddress>>> results = simpleMap(templates, (target, content) -> sendEmailWithCon...
@Test public void testSendNotification() { when(notificationTemplateRendererMock.renderTemplate(sender, recipient1, EMAIL_NOTIFICATION_TEMPLATES_PATH + "dummy_message_key_subject.txt", notification.getGlobalArguments())).thenReturn(serviceSuccess("My subject")); when(notificationTemplateRendererMock.renderTemplate(send...
AlertServiceImpl extends RootTransactionalService implements AlertService { @Override public ServiceResult<List<AlertResource>> findAllVisibleByType(AlertType type) { return serviceSuccess(simpleMap(alertRepository.findAllVisibleByType(type, now()), alertMapper::mapToResource)); } @Override ServiceResult<List<AlertRes...
@Test public void findAllVisibleByType() throws Exception { final Alert alert1 = new Alert(); final Alert alert2 = new Alert(); final List<Alert> alerts = new ArrayList<>(asList(alert1, alert2)); final AlertResource expected1 = AlertResourceBuilder.newAlertResource() .build(); final AlertResource expected2 = AlertResou...
AlertServiceImpl extends RootTransactionalService implements AlertService { @Override public ServiceResult<AlertResource> findById(Long id) { return find(alertRepository.findById(id), notFoundError(Alert.class, id)).andOnSuccessReturn(alertMapper::mapToResource); } @Override ServiceResult<List<AlertResource>> findAllV...
@Test public void findById() throws Exception { final AlertResource expected = AlertResourceBuilder.newAlertResource() .build(); final Alert alert = new Alert(); when(alertRepositoryMock.findById(9999L)).thenReturn(Optional.of(alert)); when(alertMapperMock.mapToResource(same(alert))).thenReturn(expected); assertSame(ex...
AlertServiceImpl extends RootTransactionalService implements AlertService { @Override @Transactional public ServiceResult<AlertResource> create(AlertResource alertResource) { Alert saved = alertRepository.save(alertMapper.mapToDomain(alertResource)); return serviceSuccess(alertMapper.mapToResource(saved)); } @Override...
@Test public void create() throws Exception { final AlertResource alertResource = AlertResourceBuilder.newAlertResource() .build(); final AlertResource expected = AlertResourceBuilder.newAlertResource() .build(); final Alert alert = new Alert(); when(alertMapperMock.mapToDomain(same(alertResource))).thenReturn(alert); ...
AlertServiceImpl extends RootTransactionalService implements AlertService { @Override @Transactional public ServiceResult<Void> delete(Long id) { alertRepository.deleteById(id); return serviceSuccess(); } @Override ServiceResult<List<AlertResource>> findAllVisible(); @Override ServiceResult<List<AlertResource>> findAl...
@Test public void delete() throws Exception { assertTrue(alertService.delete(9999L).isSuccess()); verify(alertRepositoryMock, only()).deleteById(9999L); }
AlertServiceImpl extends RootTransactionalService implements AlertService { @Override @Transactional public ServiceResult<Void> deleteAllByType(AlertType type) { alertRepository.deleteByType(type); return serviceSuccess(); } @Override ServiceResult<List<AlertResource>> findAllVisible(); @Override ServiceResult<List<Al...
@Test public void deleteAllByType() throws Exception { assertTrue(alertService.delete(9999L).isSuccess()); }
PasswordValidator implements Validator<String, InvalidPasswordException> { @Override public void validate(final String password) throws InvalidPasswordException { final String passwordLowerCase = password.toLowerCase(); if(passwordPolicy.getBlacklist().stream().anyMatch(passwordLowerCase::contains)) { throw new Invalid...
@Test public void shouldAcceptValidPasswords() throws InvalidPasswordException { validator.validate("valid-password"); } @Test public void shouldRejectDuplicateEmails() { try { validator.validate("invalid-password"); assertThat("Service failed to throw expected exception.", false); } catch (final InvalidPasswordExcepti...
EmailValidator implements Validator<String, DuplicateEmailException> { @Override public void validate(final String email) throws DuplicateEmailException { final Optional<Identity> byEmail = findIdentityService.findByEmail(email); if (byEmail.isPresent()) { throw new DuplicateEmailException(); } } EmailValidator(final F...
@Test public void shouldAcceptValidEmails() throws DuplicateEmailException { when(findIdentityService.findByEmail(eq("valid@email.com"))).thenReturn(Optional.empty()); validator.validate("valid@email.com"); verify(findIdentityService).findByEmail(eq("valid@email.com")); verifyNoMoreInteractions(findIdentityService); } ...
AgreementRestServiceImpl extends BaseRestService implements AgreementRestService { @Override public RestResult<AgreementResource> getCurrentAgreement() { return getWithRestResult(agreementRestURL + "/find-current", AgreementResource.class); } @Override RestResult<AgreementResource> getCurrentAgreement(); }
@Test public void getCurrentContract() { AgreementResource agreementResource = new AgreementResource(); setupGetWithRestResultExpectations(agreementUrl + "/find-current", AgreementResource.class, agreementResource, OK); RestResult<AgreementResource> result = service.getCurrentAgreement(); assertEquals(agreementResource...
KnowledgeBaseRestServiceImpl extends BaseRestService implements KnowledgeBaseRestService { @Override public RestResult<List<String>> getKnowledgeBases() { return getWithRestResultAnonymous(ORGANISATION_BASE_URL, stringsListType()); } @Override RestResult<List<String>> getKnowledgeBases(); @Override RestResult<Knowledg...
@Test public void getKnowledgeBases() { String expected = "KnowledgeBase 1"; setupGetWithRestResultAnonymousExpectations(ORGANISATION_BASE_URL, stringsListType(), Collections.singletonList(expected), OK); RestResult<List<String>> result = service.getKnowledgeBases(); assertEquals(expected, result.getSuccess().get(0)); ...
KnowledgeBaseRestServiceImpl extends BaseRestService implements KnowledgeBaseRestService { @Override public RestResult<KnowledgeBaseResource> getKnowledgeBaseByName(String knowledgeBaseName) { return getWithRestResultAnonymous(ORGANISATION_BASE_URL + "/find-by-name/" + knowledgeBaseName, KnowledgeBaseResource.class); }...
@Test public void getKnowledgeBaseByName() { String expected = "KnowledgeBase 1"; KnowledgeBaseResource knowledgeBaseResource = new KnowledgeBaseResource(); knowledgeBaseResource.setName(expected); setupGetWithRestResultAnonymousExpectations(ORGANISATION_BASE_URL + "/find-by-name/" + expected, KnowledgeBaseResource.cla...
FormInputRestServiceImpl extends BaseRestService implements FormInputRestService { @Override public RestResult<List<FormInputResource>> getByQuestionIdAndScope(Long questionId, FormInputScope scope) { return getWithRestResult(formInputRestURL + "/find-by-question-id/" + questionId + "/scope/" + scope, formInputResource...
@Test public void testGetByQuestionIdAndScope() throws Exception { List<FormInputResource> expected = Stream.of(1, 2, 3).map(i -> new FormInputResource()).collect(Collectors.toList()); Long questionId = 1L; FormInputScope scope = FormInputScope.APPLICATION; setupGetWithRestResultExpectations(String.format("%s/find-by-q...
FormInputRestServiceImpl extends BaseRestService implements FormInputRestService { @Override public RestResult<List<FormInputResource>> getByCompetitionIdAndScope(Long competitionId, FormInputScope scope) { return getWithRestResult(formInputRestURL + "/find-by-competition-id/" + competitionId + "/scope/" + scope, formI...
@Test public void testGetByCompetitionIdAndScope() throws Exception { List<FormInputResource> expected = Stream.of(1, 2, 3).map(i -> new FormInputResource()).collect(Collectors.toList()); Long competitionId = 1L; FormInputScope scope = FormInputScope.APPLICATION; setupGetWithRestResultExpectations(String.format("%s/fin...
FormInputRestServiceImpl extends BaseRestService implements FormInputRestService { @Override public RestResult<Void> delete(Long formInputId) { return deleteWithRestResult(formInputRestURL + "/" + formInputId, Void.class) ; } @Override RestResult<FormInputResource> getById(Long formInputId); @Override RestResult<List<...
@Test public void testDelete() throws Exception { Long formInputId = 1L; ResponseEntity<Void> result = setupDeleteWithRestResultExpectations(formInputRestUrl + "/" + formInputId); assertEquals(NO_CONTENT, result.getStatusCode()); }
GoogleAnalyticsDataLayerRestServiceImpl extends BaseRestService implements GoogleAnalyticsDataLayerRestService { @Override public RestResult<String> getCompetitionNameForApplication(long applicationId) { return getWithRestResult(format("%s/application/%d/competition-name", ANALYTICS_BASE_URL, applicationId), String.cla...
@Test public void getCompetitionNameForApplication() { long applicationId = 5L; String expected = "competition name"; setupGetWithRestResultExpectations( format("%s/%s/%d/competition-name", restUrl, "application", applicationId), String.class, expected ); String actual = service.getCompetitionNameForApplication(applica...
GoogleAnalyticsDataLayerRestServiceImpl extends BaseRestService implements GoogleAnalyticsDataLayerRestService { @Override public RestResult<String> getCompetitionName(long competitionId) { return getWithRestResultAnonymous(format("%s/competition/%d/competition-name", ANALYTICS_BASE_URL, competitionId), String.class); ...
@Test public void getCompetitionName() { long competitionId = 7L; String expected = "competition name"; setupGetWithRestResultAnonymousExpectations( format("%s/%s/%d/competition-name", restUrl, "competition", competitionId), String.class, expected ); String actual = service.getCompetitionName(competitionId).getSuccess(...
GoogleAnalyticsDataLayerRestServiceImpl extends BaseRestService implements GoogleAnalyticsDataLayerRestService { @Override public RestResult<String> getCompetitionNameForProject(long projectId) { return getWithRestResult(format("%s/project/%d/competition-name", ANALYTICS_BASE_URL, projectId), String.class); } @Overrid...
@Test public void getCompetitionNameForProject() { long projectId = 11L; String expected = "competition name"; setupGetWithRestResultExpectations( format("%s/%s/%d/competition-name", restUrl, "project", projectId), String.class, expected ); String actual = service.getCompetitionNameForProject(projectId).getSuccess(); a...
GoogleAnalyticsDataLayerRestServiceImpl extends BaseRestService implements GoogleAnalyticsDataLayerRestService { @Override public RestResult<String> getCompetitionNameForAssessment(long assessmentId) { return getWithRestResult(format("%s/assessment/%d/competition-name", ANALYTICS_BASE_URL, assessmentId), String.class )...
@Test public void getCompetitionNameForAssessment() { long assessmentId = 13L; String expected = "competition name"; setupGetWithRestResultExpectations( format("%s/%s/%d/competition-name", restUrl, "assessment", assessmentId), String.class, expected ); String actual = service.getCompetitionNameForAssessment(assessmentI...
GoogleAnalyticsDataLayerRestServiceImpl extends BaseRestService implements GoogleAnalyticsDataLayerRestService { @Override public RestResult<List<Role>> getRolesByApplicationId(long applicationId) { return getWithRestResult(format("%s/application/%d/user-roles", ANALYTICS_BASE_URL, applicationId), roleListType() ); } ...
@Test public void getApplicationRolesById() { long applicationId = 123L; List<Role> expectedRoles = singletonList(Role.COLLABORATOR); setupGetWithRestResultExpectations( format("%s/%s/%d/user-roles", restUrl, "application", applicationId), roleListType(), expectedRoles ); List<Role> roles = service.getRolesByApplicatio...
RegistrationServiceImpl extends BaseTransactionalService implements RegistrationService { @Override @Transactional public ServiceResult<User> activatePendingUser(User user, String password, String hash) { if(monitoringOfficerInviteRepository.existsByHash(hash)) { return activateUser(user) .andOnSuccess(activatedUser ->...
@Test public void activatePendingUser() { User user = newUser().withUid("uid").build(); when(monitoringOfficerInviteRepositoryMock.existsByHash("hash")).thenReturn(true); when(idpServiceMock.activateUser(anyString())).thenReturn(serviceSuccess("uid")); when(userRepositoryMock.save(any(User.class))).thenReturn(user); wh...
GoogleAnalyticsDataLayerRestServiceImpl extends BaseRestService implements GoogleAnalyticsDataLayerRestService { @Override public RestResult<List<Role>> getRolesByProjectId(long projectId) { return getWithRestResult(format("%s/project/%d/user-roles", ANALYTICS_BASE_URL, projectId), roleListType()); } @Override RestRes...
@Test public void getProjectRolesById() { long projectId = 999L; List<Role> expectedRoles = asList(Role.PARTNER, Role.PROJECT_MANAGER); setupGetWithRestResultExpectations( format("%s/%s/%d/user-roles", restUrl, "project", projectId), roleListType(), expectedRoles ); List<Role> roles = service.getRolesByProjectId(projec...
GoogleAnalyticsDataLayerRestServiceImpl extends BaseRestService implements GoogleAnalyticsDataLayerRestService { @Override public RestResult<Long> getApplicationIdForProject(long projectId) { return getWithRestResult(format("%s/project/%d/application-id", ANALYTICS_BASE_URL, projectId), Long.class); } @Override RestRe...
@Test public void getApplicationIdForProject() { long projectId = 987L; long applicationId = 654L; setupGetWithRestResultExpectations( format("%s/%s/%d/application-id", restUrl, "project", projectId), Long.class, applicationId ); long expectedApplicationId = service.getApplicationIdForProject(projectId).getSuccess(); a...
SectionStatusRestServiceImpl extends BaseRestService implements SectionStatusRestService { @Override public RestResult<ValidationMessages> markAsComplete(long sectionId, long applicationId, long markedAsCompleteById) { return postWithRestResult(sectionRestURL + "/mark-as-complete/" + sectionId + "/" + applicationId + "...
@Test public void markAsComplete() { long sectionId = 123L; long applicationId = 234L; long markedAsCompleteById = 345L; String expectedUrl = sectionRestUrl + "/mark-as-complete/" + sectionId + "/" + applicationId + "/" + markedAsCompleteById; ValidationMessages messages = new ValidationMessages(); setupPostWithRestRes...
SectionStatusRestServiceImpl extends BaseRestService implements SectionStatusRestService { @Override public RestResult<Void> markAsNotRequired(long sectionId, long applicationId, long markedAsCompleteById) { return postWithRestResult(sectionRestURL + "/mark-as-not-required/" + sectionId + "/" + applicationId + "/" + ma...
@Test public void markAsNotRequired() { long sectionId = 123L; long applicationId = 234L; long markedAsCompleteById = 345L; String expectedUrl = sectionRestUrl + "/mark-as-not-required/" + sectionId + "/" + applicationId + "/" + markedAsCompleteById; setupPostWithRestResultExpectations(expectedUrl, HttpStatus.OK); Rest...
SectionStatusRestServiceImpl extends BaseRestService implements SectionStatusRestService { @Override public RestResult<Void> markAsInComplete(long sectionId, long applicationId, long markedAsInCompleteById) { return postWithRestResult(sectionRestURL + "/mark-as-in-complete/" + sectionId + "/" + applicationId + "/" + ma...
@Test public void markAsInComplete() { long sectionId = 123L; long applicationId = 234L; long markedAsCompleteById = 345L; String expectedUrl = sectionRestUrl + "/mark-as-in-complete/" + sectionId + "/" + applicationId + "/" + markedAsCompleteById; setupPostWithRestResultExpectations(expectedUrl, HttpStatus.OK); RestRe...
SectionStatusRestServiceImpl extends BaseRestService implements SectionStatusRestService { @Override public RestResult<Map<Long, Set<Long>>> getCompletedSectionsByOrganisation(long applicationId) { return getWithRestResult(sectionRestURL + "/get-completed-sections-by-organisation/" + applicationId, mapOfLongToLongsSetT...
@Test public void getCompletedSectionsByOrganisation() { long applicationId = 123L; String expectedUrl = sectionRestUrl + "/get-completed-sections-by-organisation/" + applicationId; Map<Long, Set<Long>> expectedResult = new HashMap<>(); setupGetWithRestResultExpectations(expectedUrl, mapOfLongToLongsSetType(), expected...
SectionStatusRestServiceImpl extends BaseRestService implements SectionStatusRestService { @Override public RestResult<List<Long>> getCompletedSectionIds(long applicationId, long organisationId) { return getWithRestResult(sectionRestURL + "/get-completed-sections/" + applicationId + "/" + organisationId, longsListType(...
@Test public void getCompletedSectionIds() { String expectedUrl = sectionRestUrl + "/get-completed-sections/123/456"; List<Long> returnedResponse = asList(1L, 2L, 3L); setupGetWithRestResultExpectations(expectedUrl, longsListType(), returnedResponse); List<Long> response = service.getCompletedSectionIds(123L, 456L).get...
ApplicationNotificationTemplateRestServiceImpl extends BaseRestService implements ApplicationNotificationTemplateRestService { @Override public RestResult<ApplicationNotificationTemplateResource> getSuccessfulNotificationTemplate(long competitionId) { return getWithRestResult(String.format("%s/%s/%s", baseUrl, "success...
@Test public void getSuccessfulNotificationTemplate() { Long competitionId = 123L; String expectedUrl = baseUrl + "/successful/" + competitionId; ApplicationNotificationTemplateResource applicationNotificationTemplateResource = new ApplicationNotificationTemplateResource(); setupGetWithRestResultExpectations(expectedUr...
ApplicationNotificationTemplateRestServiceImpl extends BaseRestService implements ApplicationNotificationTemplateRestService { @Override public RestResult<ApplicationNotificationTemplateResource> getUnsuccessfulNotificationTemplate(long competitionId) { return getWithRestResult(String.format("%s/%s/%s", baseUrl, "unsuc...
@Test public void getUnsuccessfulNotificationTemplate() { Long competitionId = 123L; String expectedUrl = baseUrl + "/unsuccessful/" + competitionId; ApplicationNotificationTemplateResource applicationNotificationTemplateResource = new ApplicationNotificationTemplateResource(); setupGetWithRestResultExpectations(expect...
ApplicationNotificationTemplateRestServiceImpl extends BaseRestService implements ApplicationNotificationTemplateRestService { @Override public RestResult<ApplicationNotificationTemplateResource> getIneligibleNotificationTemplate(long competitionId) { return getWithRestResult(String.format("%s/%s/%s", baseUrl, "ineligi...
@Test public void getIneligibleNotificationTemplate() { long competitionId = 1L; String expectedUrl = baseUrl + "/ineligible/" + competitionId; ApplicationNotificationTemplateResource applicationNotificationTemplateResource = new ApplicationNotificationTemplateResource(); setupGetWithRestResultExpectations(expectedUrl,...
RegistrationNotificationService { ServiceResult<Void> sendUserVerificationEmail(final UserResource user, final Optional<Long> competitionId, final Optional<Long> organisationId) { final Token token = createEmailVerificationToken(user, competitionId, organisationId); final Notification notification = getEmailVerificatio...
@Test public void testSendUserVerificationEmailNoCompetitionId() { final UserResource userResource = newUserResource() .withId(1L) .withFirstName("Sample") .withLastName("User") .withEmail("sample@me.com") .build(); final String hash = "1e627a59879066b44781ca584a23be742d3197dff291245150e62f3d4d3d303e1a87d34fc8a3a2e0"; ...
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<SectionResource> getById(Long sectionId) { return getWithRestResult(sectionRestURL + "/" + sectionId, SectionResource.class); } @Override RestResult<SectionResource> getById(Long sectionId); @Override RestResult<...
@Test public void getById() { long sectionId = 123L; String expectedUrl = sectionRestUrl + "/" + sectionId; SectionResource sectionResource = newSectionResource().build(); setupGetWithRestResultExpectations(expectedUrl, SectionResource.class, sectionResource); RestResult<SectionResource> result = service.getById(sectio...
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<List<SectionResource>> getByCompetition(final Long competitionId) { return getWithRestResult(sectionRestURL + "/get-by-competition/" + competitionId, sectionResourceListType()); } @Override RestResult<SectionReso...
@Test public void getByCompetition() { long competitionId = 123L; String expectedUrl = sectionRestUrl + "/get-by-competition/" + competitionId; List<SectionResource> sectionResources = newSectionResource().build(2); setupGetWithRestResultExpectations(expectedUrl, sectionResourceListType(), sectionResources); RestResult...
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<SectionResource> getSectionByQuestionId(Long questionId) { return getWithRestResult(sectionRestURL + "/get-section-by-question-id/" + questionId, SectionResource.class); } @Override RestResult<SectionResource> ge...
@Test public void getSectionByQuestionId() { long questionId = 1L; String expectedUrl = sectionRestUrl + "/get-section-by-question-id/" + questionId; SectionResource sectionResource = newSectionResource().build(); setupGetWithRestResultExpectations(expectedUrl, SectionResource.class, sectionResource); RestResult<Sectio...
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<Set<Long>> getQuestionsForSectionAndSubsections(Long sectionId) { return getWithRestResult(sectionRestURL + "/get-questions-for-section-and-subsections/" + sectionId, longsSetType()); } @Override RestResult<Secti...
@Test public void getQuestionForSectionAndSubsections() { long sectionId = 1L; String expectedUrl = sectionRestUrl + "/get-questions-for-section-and-subsections/" + sectionId; Set<Long> questions = new HashSet<>(); setupGetWithRestResultExpectations(expectedUrl, longsSetType(), questions); RestResult<Set<Long>> result ...
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<List<SectionResource>> getSectionsByCompetitionIdAndType(Long competitionId, SectionType type) { return getWithRestResult(sectionRestURL + "/get-sections-by-competition-id-and-type/" + competitionId + "/" + type.n...
@Test public void getSectionsForCompetitionByType() { String expectedUrl = sectionRestUrl + "/get-sections-by-competition-id-and-type/123/FINANCE"; List<SectionResource> returnedResponse = singletonList(new SectionResource()); setupGetWithRestResultExpectations(expectedUrl, sectionResourceListType(), returnedResponse);...
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<List<SectionResource>> getByCompetitionIdVisibleForAssessment(Long competitionId) { return getWithRestResult(sectionRestURL + "/get-by-competition-id-visible-for-assessment/" + competitionId, sectionResourceListTy...
@Test public void getByCompetitionIdVisibleForAssessment() throws Exception { List<SectionResource> expected = newSectionResource().build(2); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/get-by-competition-id-visible-for-assessment/%s", sectionRestUrl, competitionId), sectionResourceListType()...
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<List<SectionResource>> getChildSectionsByParentId(long parentId) { return getWithRestResult(sectionRestURL + "/get-child-sections/" + parentId, sectionResourceListType()); } @Override RestResult<SectionResource> ...
@Test public void getChildSectionsByParentId() { long parentId = 12L; String expectedUrl = sectionRestUrl + "/get-child-sections/" + parentId; SectionResource parentSectionResource = newSectionResource().withId(parentId).build(); List<SectionResource> childSectionResources = newSectionResource().withParentSection(paren...
ApplicationAssessmentSummaryRestServiceImpl extends BaseRestService implements ApplicationAssessmentSummaryRestService { @Override public RestResult<ApplicationAvailableAssessorPageResource> getAvailableAssessors(long applicationId, Integer pageIndex, Integer pageSize, String assessorNameFilter, Sort sort) { String uri...
@Test public void getAvailableAssessors() { ApplicationAvailableAssessorPageResource expected = new ApplicationAvailableAssessorPageResource(); Long applicationId = 1L; int page = 2; int size = 3; String assessorNameFilter = "Name"; Sort sort = Sort.ASSESSOR; setupGetWithRestResultExpectations(format("%s/%s/available-a...
ApplicationAssessmentSummaryRestServiceImpl extends BaseRestService implements ApplicationAssessmentSummaryRestService { @Override public RestResult<List<ApplicationAssessorResource>> getAssignedAssessors(long applicationId) { return getWithRestResult(format("%s/%s/assigned-assessors", applicationAssessmentSummaryRestU...
@Test public void getAssignedAssessors() { List<ApplicationAssessorResource> expected = newApplicationAssessorResource().build(2); Long applicationId = 1L; setupGetWithRestResultExpectations( format("%s/%s/assigned-assessors", applicationAssessmentSummaryRestUrl, applicationId), ParameterizedTypeReferences.applicationA...
ApplicationAssessmentSummaryRestServiceImpl extends BaseRestService implements ApplicationAssessmentSummaryRestService { @Override public RestResult<ApplicationAssessmentSummaryResource> getApplicationAssessmentSummary(long applicationId) { return getWithRestResult(format("%s/%s", applicationAssessmentSummaryRestURL, a...
@Test public void getApplicationAssessmentSummary() { ApplicationAssessmentSummaryResource expected = newApplicationAssessmentSummaryResource().build(); Long applicationId = 1L; setupGetWithRestResultExpectations( format("%s/%s", applicationAssessmentSummaryRestUrl, applicationId), ApplicationAssessmentSummaryResource....
ApplicationAssessmentSummaryRestServiceImpl extends BaseRestService implements ApplicationAssessmentSummaryRestService { @Override public RestResult<List<Long>> getAvailableAssessorsIds(long applicationId, String assessorName) { String uriWithParams = buildUri(applicationAssessmentSummaryRestURL + "/{applicationId}/ava...
@Test public void getAvailableAssessorIds() { List<Long> expected = asList(1L, 2L); long applicationId = 1L; String assessorNameFilter = "Name"; setupGetWithRestResultExpectations(format("%s/%s/available-assessors-ids?assessorNameFilter=%s", applicationAssessmentSummaryRestUrl, applicationId, assessorNameFilter), longs...
AssessorCompetitionSummaryRestServiceImpl extends BaseRestService implements AssessorCompetitionSummaryRestService { @Override public RestResult<AssessorCompetitionSummaryResource> getAssessorSummary(long assessorId, long competitionId) { return getWithRestResult(format(baseUrl + "/summary", assessorId, competitionId),...
@Test public void getAssessorSummary() throws Exception { long assessorId = 1L; long competitionId = 2L; AssessorCompetitionSummaryResource expected = newAssessorCompetitionSummaryResource() .withCompetitionId(competitionId) .withCompetitionName("Test Competition") .build(); setupGetWithRestResultExpectations(format("/...
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponses(long assessmentId) { return getWithRestResult(format("%s/assessment/%s", assessorFormInputResponseRestU...
@Test public void getAllAssessorFormInputResponses() { List<AssessorFormInputResponseResource> expected = Stream.of(1, 2, 3).map(i -> new AssessorFormInputResponseResource()).collect(Collectors.toList()); long assessmentId = 1L; setupGetWithRestResultExpectations(format("%s/assessment/%s", assessorFormInputResponseRest...
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponsesByAssessmentAndQuestion(long assessmentId, long questionId) { return getWithRestResult(format("%s/assess...
@Test public void getAllAssessorFormInputResponsesByAssessmentAndQuestion() { List<AssessorFormInputResponseResource> expected = Stream.of(1, 2, 3).map(i -> new AssessorFormInputResponseResource()).collect(Collectors.toList()); long assessmentId = 1L; long questionId = 2L; setupGetWithRestResultExpectations(format("%s/...
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<Void> updateFormInputResponse(long assessmentId, long formInputId, String value) { return updateFormInputResponses(new AssessorFormInputResponsesResource( new AssessorFormInputR...
@Test public void updateFormInputResponse() { long assessmentId = 1L; long formInputId = 2L; String value = "Response"; AssessorFormInputResponsesResource responses = new AssessorFormInputResponsesResource( newAssessorFormInputResponseResource() .with(id(null)) .withAssessment(assessmentId) .withFormInput(formInputId) ...
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<Void> updateFormInputResponses(AssessorFormInputResponsesResource assessorFormInputResponseResources) { return putWithRestResult(format("%s", assessorFormInputResponseRestUrl), ...
@Test public void updateFormInputResponses() { AssessorFormInputResponsesResource responses = new AssessorFormInputResponsesResource( newAssessorFormInputResponseResource() .with(id(null)) .withAssessment(1L) .withFormInput(2L, 3L) .withValue("Response 1", "Response 2") .build(2)); setupPutWithRestResultExpectations(fo...
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<ApplicationAssessmentAggregateResource> getApplicationAssessmentAggregate(long applicationId) { return getWithRestResult(format("%s/application/%s/scores", assessorFormInputResp...
@Test public void getApplicationAssessmentAggregate() { long applicationId = 7; Map<Long, BigDecimal> expectedScores = new HashMap<>(); expectedScores.put(17L, new BigDecimal(20)); ApplicationAssessmentAggregateResource expected = new ApplicationAssessmentAggregateResource(true, 13, 11, expectedScores, BigDecimal.value...
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<AssessmentFeedbackAggregateResource> getAssessmentAggregateFeedback(long applicationId, long questionId) { return getWithRestResult(format("%s/application/%s/question/%s/feedbac...
@Test public void getAssessmentAggregateFeedback() { long applicationId = 1L; long questionId = 2L; AssessmentFeedbackAggregateResource expected = newAssessmentFeedbackAggregateResource().build(); setupGetWithRestResultExpectations(format("%s/application/%s/question/%s/feedback", assessorFormInputResponseRestUrl, appli...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<AssessorInvitesToSendResource> getAllInvitesToSend(long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "get-all-invites-to-send", competitionId), Asse...
@Test public void getAllInvitesToSend() { long competitionId = 1L; AssessorInvitesToSendResource expected = newAssessorInvitesToSendResource() .withRecipients(asList("James", "John")) .build(); setupGetWithRestResultExpectations(format("%s/%s/%s", restUrl, "get-all-invites-to-send", competitionId), AssessorInvitesToSen...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<AssessorInvitesToSendResource> getAllInvitesToResend(long competitionId, List<Long> inviteIds) { String baseUrl = format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "get-all-invites-to-resend", co...
@Test public void getAllInvitesToResend() { long competitionId = 1L; List<Long> inviteIds = asList(1L, 2L); AssessorInvitesToSendResource expected = newAssessorInvitesToSendResource() .withRecipients(asList("James", "John")) .build(); setupGetWithRestResultExpectations(format("%s/%s/%s%s", restUrl, "get-all-invites-to-...
RegistrationNotificationService { ServiceResult<Void> resendUserVerificationEmail(final UserResource user) { final Token token = refreshEmailVerificationToken(user); final Notification notification = getEmailVerificationNotification(user, token); return notificationService.sendNotificationWithFlush(notification, EMAIL)...
@Test public void testResendUserVerificationEmail() { final UserResource userResource = newUserResource() .withId(1L) .withFirstName("Sample") .withLastName("User") .withEmail("sample@me.com") .build(); final String hash = "1e627a59879066b44781ca584a23be742d3197dff291245150e62f3d4d3d303e1a87d34fc8a3a2e0"; ReflectionTes...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<AssessorInvitesToSendResource> getInviteToSend(long inviteId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "get-invite-to-send", inviteId), AssessorInvitesToSendRe...
@Test public void getInviteToSend() { long inviteId = 1L; AssessorInvitesToSendResource expected = newAssessorInvitesToSendResource().build(); setupGetWithRestResultExpectations(format("%s/%s/%s", restUrl, "get-invite-to-send", inviteId), AssessorInvitesToSendResource.class, expected); AssessorInvitesToSendResource act...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<CompetitionInviteResource> getInvite(String inviteHash) { return getWithRestResultAnonymous(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "get-invite", inviteHash), CompetitionInviteResource....
@Test public void getInvite() { CompetitionInviteResource expected = new CompetitionInviteResource(); expected.setCompetitionName("my competition"); setupGetWithRestResultAnonymousExpectations(format("%s/%s/%s", restUrl, "get-invite", "hash"), CompetitionInviteResource.class, expected); CompetitionInviteResource actual...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<CompetitionInviteResource> openInvite(String inviteHash) { return postWithRestResultAnonymous(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "open-invite", inviteHash), CompetitionInviteResour...
@Test public void openInvite() { CompetitionInviteResource expected = new CompetitionInviteResource(); expected.setCompetitionName("my competition"); setupPostWithRestResultAnonymousExpectations(format("%s/%s/%s", restUrl, "open-invite", "hash"), CompetitionInviteResource.class, null, expected, OK); CompetitionInviteRe...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Void> acceptInvite(String inviteHash) { return postWithRestResult(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "accept-invite", inviteHash), Void.class); } @Override RestResult<AssessorInvi...
@Test public void acceptInvite() { setupPostWithRestResultExpectations(format("%s/%s/%s", restUrl, "accept-invite", "hash"), OK); RestResult<Void> restResult = service.acceptInvite("hash"); assertTrue(restResult.isSuccess()); }
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Void> rejectInvite(String inviteHash, CompetitionRejectionResource rejectionReason) { return postWithRestResultAnonymous(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "reject-invite", inviteH...
@Test public void rejectInvite() { RejectionReasonResource rejectionReasonResource = new RejectionReasonResource(); rejectionReasonResource.setId(1L); CompetitionRejectionResource rejectionResource = new CompetitionRejectionResource(rejectionReasonResource, "too busy"); setupPostWithRestResultAnonymousExpectations(form...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Boolean> checkExistingUser(String inviteHash) { return getWithRestResultAnonymous(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "check-existing-user", inviteHash), Boolean.class); } @Overrid...
@Test public void checkExistingUser() { setupGetWithRestResultAnonymousExpectations(format("%s/%s/%s", restUrl, "check-existing-user", "hash"), Boolean.class, TRUE); assertTrue(service.checkExistingUser("hash").getSuccess()); }
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<AvailableAssessorPageResource> getAvailableAssessors(long competitionId, int page, String assessorNameFilter) { String baseUrl = format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "get-available-a...
@Test public void getAvailableAssessors() { long competitionId = 1L; int page = 1; String assessorNameFilter = "name"; List<AvailableAssessorResource> assessorItems = newAvailableAssessorResource() .withName("Test") .build(2); AvailableAssessorPageResource expected = newAvailableAssessorPageResource() .withContent(asse...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<List<Long>> getAvailableAssessorIds(long competitionId, String assessorNameFilter) { String baseUrl = format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "get-available-assessors", competitionId); ...
@Test public void getAvailableAssessors_all() { long competitionId = 1L; String assessorNameFilter = "name"; List<Long> assessorItems = asList(1L, 2L); setupGetWithRestResultExpectations( format("%s/%s/%s?all&assessorNameFilter=name", restUrl, "get-available-assessors", competitionId), ParameterizedTypeReferences.longs...
RoleProfileStatusServiceImpl implements RoleProfileStatusService { @Override public ServiceResult<List<RoleProfileStatusResource>> findByUserId(long userId) { return find(roleProfileStatusRepository.findByUserId(userId), notFoundError(RoleProfileStatus.class, userId)) .andOnSuccessReturn(rp -> rp.stream() .map(roleProf...
@Test public void findByUserId() { long userId = 1l; User user = newUser().withId(userId).build(); List<RoleProfileStatus> roleProfileStatus = newRoleProfileStatus().withUser(user).build(1); RoleProfileStatusResource roleProfileStatusResource = newRoleProfileStatusResource().withUserId(userId).build(); when(roleProfile...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<AssessorCreatedInvitePageResource> getCreatedInvites(long competitionId, int page) { String baseUrl = format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "get-created-invites", competitionId); UriC...
@Test public void getCreatedInvites() { long competitionId = 1L; int page = 1; AssessorCreatedInvitePageResource expected = newAssessorCreatedInvitePageResource() .withContent(newAssessorCreatedInviteResource().build(2)) .build(); setupGetWithRestResultExpectations(format("%s/%s/%s?page=1", restUrl, "get-created-invite...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<AssessorInviteOverviewPageResource> getInvitationOverview(long competitionId, int page, List<ParticipantStatusResource> participantStatuses, Optional<Boolean> compliant, Optional<String> assess...
@Test public void getInvitationOverview() { long competitionId = 1L; int page = 1; List<ParticipantStatusResource> participantStatus = Collections.singletonList(ACCEPTED); Optional<Boolean> compliant = of(TRUE); Optional<String> assessorName = of("name"); AssessorInviteOverviewPageResource expected = newAssessorInviteO...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<List<Long>> getAssessorsNotAcceptedInviteIds(long competitionId, List<ParticipantStatusResource> participantStatuses, Optional<Boolean> compliant, Optional<String> assessorName) { String baseUr...
@Test public void getAssessorsNotAcceptedInviteIds() { long competitionId = 1L; List<Long> expected = asList(1L, 2L); List<ParticipantStatusResource> statuses = Arrays.asList(PENDING, REJECTED); String expectedUrl = format("%s/%s/%s?statuses=%s", restUrl, "get-assessors-not-accepted-invite-ids", competitionId, "PENDING...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<CompetitionInviteStatisticsResource> getInviteStatistics(long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "get-invite-statistics", competitionId), ...
@Test public void getInviteStatistics() { long competitionId = 1L; CompetitionInviteStatisticsResource expected = newCompetitionInviteStatisticsResource().build(); setupGetWithRestResultExpectations(format("%s/%s/%s", restUrl, "get-invite-statistics", competitionId), CompetitionInviteStatisticsResource.class, expected)...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<CompetitionInviteResource> inviteUser(ExistingUserStagedInviteResource existingUserStagedInvite) { return postWithRestResult(format("%s/%s", COMPETITION_INVITE_REST_URL, "invite-user"), existin...
@Test public void inviteUser() { ExistingUserStagedInviteResource existingUserStagesInviteResource = new ExistingUserStagedInviteResource(2L, 1L); CompetitionInviteResource expected = newCompetitionInviteResource().build(); setupPostWithRestResultExpectations(format("%s/%s", restUrl, "invite-user"), CompetitionInviteRe...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Void> inviteNewUsers(NewUserStagedInviteListResource newUserStagedInvites, long competitionId) { return postWithRestResult(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "invite-new-users", co...
@Test public void inviteNewUsers() { long competitionId = 1L; NewUserStagedInviteListResource newUserStagedInviteListResource = newNewUserStagedInviteListResource() .withInvites( newNewUserStagedInviteResource() .withName("Tester 1", "Tester 2") .withEmail("test1@test.com", "test2@test.com") .withInnovationAreaId(1L) ....
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Void> inviteUsers(ExistingUserStagedInviteListResource existingUserStagedInvites) { return postWithRestResult(format("%s/%s", COMPETITION_INVITE_REST_URL, "invite-users"), existingUserStagedInv...
@Test public void inviteUsers() { long competitionId = 1L; ExistingUserStagedInviteListResource existingUserStagedInviteListResource = newExistingUserStagedInviteListResource() .withInvites( newExistingUserStagedInviteResource() .withUserId(1L, 2L) .withCompetitionId(competitionId) .build(2) ) .build(); setupPostWithRe...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Void> deleteInvite(String email, long competitionId) { return deleteWithRestResult(format("%s/%s?competitionId=%s&email=%s", COMPETITION_INVITE_REST_URL, "delete-invite", competitionId, email),...
@Test public void deleteInvite() { String email = "firstname.lastname@example.com"; long competitionId = 1L; setupDeleteWithRestResultExpectations(format("%s/%s?competitionId=%s&email=%s", restUrl, "delete-invite", competitionId, email)); RestResult<Void> resultResult = service.deleteInvite(email, competitionId); asser...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Void> deleteAllInvites(long competitionId) { return deleteWithRestResult(format("%s/%s?competitionId=%s", COMPETITION_INVITE_REST_URL, "delete-all-invites", competitionId), Void.class); } @Ove...
@Test public void deleteAllInvites() { long competitionId = 1L; setupDeleteWithRestResultExpectations(format("%s/%s?competitionId=%s", restUrl, "delete-all-invites", competitionId)); RestResult<Void> resultResult = service.deleteAllInvites(competitionId); assertTrue(resultResult.isSuccess()); }
RoleProfileStatusServiceImpl implements RoleProfileStatusService { @Override public ServiceResult<RoleProfileStatusResource> findByUserIdAndProfileRole(long userId, ProfileRole profileRole) { return find(roleProfileStatusRepository.findByUserIdAndProfileRole(userId, profileRole), notFoundError(RoleProfileStatus.class, ...
@Test public void findByUserIdAndProfileRole() { long userId = 1l; ProfileRole profileRole = ProfileRole.ASSESSOR; User user = newUser().withId(userId).build(); RoleProfileStatus roleProfileStatus = newRoleProfileStatus().withUser(user).build(); RoleProfileStatusResource roleProfileStatusResource = newRoleProfileStatus...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Void> sendAllInvites(long competitionId, AssessorInviteSendResource assessorInviteSendResource) { return postWithRestResult(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "send-all-invites", c...
@Test public void sendAllInvites() { long competitionId = 1L; AssessorInviteSendResource assessorInviteSendResource = newAssessorInviteSendResource() .withSubject("subject") .withContent("content") .build(); setupPostWithRestResultExpectations(format("%s/%s/%s", restUrl, "send-all-invites", competitionId), assessorInvi...
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Void> resendInvite(long inviteId, AssessorInviteSendResource assessorInviteSendResource) { return postWithRestResult(format("%s/%s/%s", COMPETITION_INVITE_REST_URL, "resend-invite", inviteId), ...
@Test public void resendInvite() { long inviteId = 5L; AssessorInviteSendResource assessorInviteSendResource = newAssessorInviteSendResource() .withSubject("subject") .withContent("content") .build(); setupPostWithRestResultExpectations(format("%s/%s/%s", restUrl, "resend-invite", inviteId), assessorInviteSendResource,...