src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
CompetitionInviteRestServiceImpl extends BaseRestService implements CompetitionInviteRestService { @Override public RestResult<Void> resendInvites(List<Long> inviteIds, AssessorInviteSendResource assessorInviteSendResource) { String baseUrl = format("%s/%s", COMPETITION_INVITE_REST_URL, "resend-invites"); UriComponentsBuilder builder = UriComponentsBuilder.fromPath(baseUrl) .queryParam("inviteIds", simpleJoiner(inviteIds, ",")); return postWithRestResult(builder.toUriString(), assessorInviteSendResource, Void.class); } @Override RestResult<AssessorInvitesToSendResource> getAllInvitesToSend(long competitionId); @Override RestResult<AssessorInvitesToSendResource> getInviteToSend(long inviteId); @Override RestResult<AssessorInvitesToSendResource> getAllInvitesToResend(long competitionId, List<Long> inviteIds); @Override RestResult<CompetitionInviteResource> getInvite(String inviteHash); @Override RestResult<CompetitionInviteResource> openInvite(String inviteHash); @Override RestResult<Void> acceptInvite(String inviteHash); @Override RestResult<Void> rejectInvite(String inviteHash, CompetitionRejectionResource rejectionReason); @Override RestResult<Boolean> checkExistingUser(String inviteHash); @Override RestResult<AvailableAssessorPageResource> getAvailableAssessors(long competitionId, int page, String assessorNameFilter); @Override RestResult<List<Long>> getAvailableAssessorIds(long competitionId, String assessorNameFilter); @Override RestResult<List<Long>> getAssessorsNotAcceptedInviteIds(long competitionId, List<ParticipantStatusResource> participantStatuses, Optional<Boolean> compliant, Optional<String> assessorName); @Override RestResult<AssessorCreatedInvitePageResource> getCreatedInvites(long competitionId, int page); @Override RestResult<AssessorInviteOverviewPageResource> getInvitationOverview(long competitionId, int page, List<ParticipantStatusResource> participantStatuses, Optional<Boolean> compliant, Optional<String> assessorName); @Override RestResult<CompetitionInviteStatisticsResource> getInviteStatistics(long competitionId); @Override RestResult<CompetitionInviteResource> inviteUser(ExistingUserStagedInviteResource existingUserStagedInvite); @Override RestResult<Void> inviteUsers(ExistingUserStagedInviteListResource existingUserStagedInvites); @Override RestResult<Void> inviteNewUsers(NewUserStagedInviteListResource newUserStagedInvites, long competitionId); @Override RestResult<Void> deleteInvite(String email, long competitionId); @Override RestResult<Void> deleteAllInvites(long competitionId); @Override RestResult<Void> sendAllInvites(long competitionId, AssessorInviteSendResource assessorInviteSendResource); @Override RestResult<Void> resendInvite(long inviteId, AssessorInviteSendResource assessorInviteSendResource); @Override RestResult<Void> resendInvites(List<Long> inviteIds, AssessorInviteSendResource assessorInviteSendResource); }
@Test public void resendInvites() { List<Long> inviteIds = asList(1L, 2L); AssessorInviteSendResource assessorInviteSendResource = newAssessorInviteSendResource() .withSubject("subject") .withContent("content") .build(); setupPostWithRestResultExpectations(format("%s/%s%s", restUrl, "resend-invites", "?inviteIds=1,2"), assessorInviteSendResource, OK); assertTrue(service.resendInvites(inviteIds, assessorInviteSendResource).isSuccess()); }
CompetitionKeyAssessmentStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyAssessmentStatisticsRestService { @Override public RestResult<CompetitionReadyToOpenKeyAssessmentStatisticsResource> getReadyToOpenKeyStatisticsByCompetition( long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_ASSESSMENT_KEY_STATISTICS_REST_URL, competitionId, "ready-to-open"), CompetitionReadyToOpenKeyAssessmentStatisticsResource.class); } @Override RestResult<CompetitionReadyToOpenKeyAssessmentStatisticsResource> getReadyToOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionOpenKeyAssessmentStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyAssessmentStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionInAssessmentKeyAssessmentStatisticsResource> getInAssessmentKeyStatisticsByCompetition(long competitionId); }
@Test public void getReadyToOpenKeyStatisticsByCompetition() { CompetitionReadyToOpenKeyAssessmentStatisticsResource expected = newCompetitionReadyToOpenKeyAssessmentStatisticsResource().build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/ready-to-open", COMPETITION_ASSESSMENT_KEY_STATISTICS_REST_URL, competitionId), CompetitionReadyToOpenKeyAssessmentStatisticsResource.class, expected); assertSame(expected, service.getReadyToOpenKeyStatisticsByCompetition(competitionId).getSuccess()); }
CompetitionKeyAssessmentStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyAssessmentStatisticsRestService { @Override public RestResult<CompetitionOpenKeyAssessmentStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_ASSESSMENT_KEY_STATISTICS_REST_URL, competitionId, "open"), CompetitionOpenKeyAssessmentStatisticsResource.class); } @Override RestResult<CompetitionReadyToOpenKeyAssessmentStatisticsResource> getReadyToOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionOpenKeyAssessmentStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyAssessmentStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionInAssessmentKeyAssessmentStatisticsResource> getInAssessmentKeyStatisticsByCompetition(long competitionId); }
@Test public void getOpenKeyStatisticsByCompetition() { CompetitionOpenKeyAssessmentStatisticsResource expected = newCompetitionOpenKeyAssessmentStatisticsResource() .build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/open", COMPETITION_ASSESSMENT_KEY_STATISTICS_REST_URL, competitionId), CompetitionOpenKeyAssessmentStatisticsResource.class, expected); assertSame(expected, service.getOpenKeyStatisticsByCompetition(competitionId).getSuccess()); }
CompetitionKeyAssessmentStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyAssessmentStatisticsRestService { @Override public RestResult<CompetitionClosedKeyAssessmentStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_ASSESSMENT_KEY_STATISTICS_REST_URL, competitionId, "closed"), CompetitionClosedKeyAssessmentStatisticsResource.class); } @Override RestResult<CompetitionReadyToOpenKeyAssessmentStatisticsResource> getReadyToOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionOpenKeyAssessmentStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyAssessmentStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionInAssessmentKeyAssessmentStatisticsResource> getInAssessmentKeyStatisticsByCompetition(long competitionId); }
@Test public void getClosedKeyStatisticsByCompetition() { CompetitionClosedKeyAssessmentStatisticsResource expected = newCompetitionClosedKeyAssessmentStatisticsResource().build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/closed", COMPETITION_ASSESSMENT_KEY_STATISTICS_REST_URL, competitionId), CompetitionClosedKeyAssessmentStatisticsResource.class, expected); assertSame(expected, service.getClosedKeyStatisticsByCompetition(competitionId).getSuccess()); }
CompetitionKeyAssessmentStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyAssessmentStatisticsRestService { @Override public RestResult<CompetitionInAssessmentKeyAssessmentStatisticsResource> getInAssessmentKeyStatisticsByCompetition(long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_ASSESSMENT_KEY_STATISTICS_REST_URL, competitionId, "in-assessment"), CompetitionInAssessmentKeyAssessmentStatisticsResource.class); } @Override RestResult<CompetitionReadyToOpenKeyAssessmentStatisticsResource> getReadyToOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionOpenKeyAssessmentStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyAssessmentStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionInAssessmentKeyAssessmentStatisticsResource> getInAssessmentKeyStatisticsByCompetition(long competitionId); }
@Test public void getInAssessmentKeyStatisticsByCompetition() { CompetitionInAssessmentKeyAssessmentStatisticsResource expected = newCompetitionInAssessmentKeyAssessmentStatisticsResource().build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/in-assessment", COMPETITION_ASSESSMENT_KEY_STATISTICS_REST_URL, competitionId), CompetitionInAssessmentKeyAssessmentStatisticsResource.class, expected); assertSame(expected, service.getInAssessmentKeyStatisticsByCompetition(competitionId).getSuccess()); }
AssessorRestServiceImpl extends BaseRestService implements AssessorRestService { @Override public RestResult<Void> createAssessorByInviteHash(String hash, UserRegistrationResource userRegistrationResource) { return postWithRestResultAnonymous(format("%s/register/%s", assessorRestUrl, hash), userRegistrationResource, Void.class); } @Override RestResult<Void> createAssessorByInviteHash(String hash, UserRegistrationResource userRegistrationResource); @Override RestResult<AssessorProfileResource> getAssessorProfile(Long assessorId); @Override RestResult<Boolean> hasApplicationsAssigned(long assessorId); @Override RestResult<Void> notifyAssessors(long competitionId); }
@Test public void createAssessorByInviteHash() { String hash = "testhash"; UserRegistrationResource userRegistrationResource = new UserRegistrationResource(); setupPostWithRestResultAnonymousExpectations(format("%s/register/%s", assessorRestUrl, hash), Void.class, userRegistrationResource, null, OK); RestResult<Void> response = service.createAssessorByInviteHash(hash, userRegistrationResource); assertTrue(response.isSuccess()); }
AssessorRestServiceImpl extends BaseRestService implements AssessorRestService { @Override public RestResult<Void> notifyAssessors(long competitionId) { return putWithRestResult(String.format("%s/notify-assessors/competition/%s", assessorRestUrl, competitionId), Void.class); } @Override RestResult<Void> createAssessorByInviteHash(String hash, UserRegistrationResource userRegistrationResource); @Override RestResult<AssessorProfileResource> getAssessorProfile(Long assessorId); @Override RestResult<Boolean> hasApplicationsAssigned(long assessorId); @Override RestResult<Void> notifyAssessors(long competitionId); }
@Test public void notifyAssessors() { long competitionId = 1L; setupPutWithRestResultExpectations(format("%s/notify-assessors/competition/%s", assessorRestUrl, competitionId), HttpStatus.OK); RestResult<Void> result = service.notifyAssessors(competitionId); assertTrue(result.isSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<AssessmentResource> getById(final long id) { return getWithRestResult(format("%s/%s", assessmentRestURL, id), AssessmentResource.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void getById() { AssessmentResource expected = newAssessmentResource().build(); Long assessmentId = 1L; setupGetWithRestResultExpectations(format("%s/%s", assessmentRestURL, assessmentId), AssessmentResource.class, expected); assertSame(expected, service.getById(assessmentId).getSuccess()); }
RoleProfileStatusServiceImpl implements RoleProfileStatusService { @Override @Transactional public ServiceResult<Void> updateUserStatus(long userId, RoleProfileStatusResource roleProfileStatusResource) { return getUser(userId).andOnSuccessReturnVoid(user -> updateRoleProfileStatus(user, roleProfileStatusResource)); } @Override @Transactional ServiceResult<Void> updateUserStatus(long userId, RoleProfileStatusResource roleProfileStatusResource); @Override ServiceResult<List<RoleProfileStatusResource>> findByUserId(long userId); @Override ServiceResult<RoleProfileStatusResource> findByUserIdAndProfileRole(long userId, ProfileRole profileRole); @Override @Transactional ServiceResult<UserPageResource> findByRoleProfile(RoleProfileState state, ProfileRole profileRole, String filter, Pageable pageable); }
@Test public void updateUserStatus() { long userId = 1l; User user = newUser().withId(userId).build(); RoleProfileStatus roleProfileStatus = newRoleProfileStatus().withUser(user).build(); RoleProfileStatusResource roleProfileStatusResource = newRoleProfileStatusResource() .withUserId(userId) .withRoleProfileState(RoleProfileState.UNAVAILABLE) .withProfileRole(ProfileRole.ASSESSOR) .withDescription("Description") .build(); when(userRepositoryMock.findById(userId)).thenReturn(Optional.of(user)); when(roleProfileStatusMapper.mapToResource(roleProfileStatus)).thenReturn(roleProfileStatusResource); when(roleProfileStatusRepositoryMock.findByUserIdAndProfileRole(userId, ProfileRole.ASSESSOR)).thenReturn(Optional.of(roleProfileStatus)); ServiceResult<Void> result = service.updateUserStatus(userId, roleProfileStatusResource); assertTrue(result.isSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<AssessmentResource> getAssignableById(long id) { return getWithRestResult(format("%s/%s/assign", assessmentRestURL, id), AssessmentResource.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void getAssignableById() { AssessmentResource expected = newAssessmentResource().build(); Long assessmentId = 1L; setupGetWithRestResultExpectations(format("%s/%s/assign", assessmentRestURL, assessmentId), AssessmentResource.class, expected); assertSame(expected, service.getAssignableById(assessmentId).getSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<AssessmentResource> getRejectableById(long id) { return getWithRestResult(format("%s/%s/rejectable", assessmentRestURL, id), AssessmentResource.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void getRejectableById() { AssessmentResource expected = newAssessmentResource().build(); Long assessmentId = 1L; setupGetWithRestResultExpectations(format("%s/%s/rejectable", assessmentRestURL, assessmentId), AssessmentResource.class, expected); assertSame(expected, service.getRejectableById(assessmentId).getSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId) { return getWithRestResult(format("%s/user/%s/competition/%s", assessmentRestURL, userId, competitionId), ParameterizedTypeReferences.assessmentResourceListType()); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void getByUserAndCompetition() { List<AssessmentResource> expected = newAssessmentResource().build(2); Long userId = 1L; Long competitionId = 2L; setupGetWithRestResultExpectations(format("%s/user/%s/competition/%s", assessmentRestURL, userId, competitionId), assessmentResourceListType(), expected); assertSame(expected, service.getByUserAndCompetition(userId, competitionId).getSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { public RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId) { return getWithRestResult(format("%s/user/%s/application/%s", assessmentRestURL, userId, applicationId), ParameterizedTypeReferences.assessmentResourceListType()); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void getByUserAndApplication() { List<AssessmentResource> expected = newAssessmentResource().build(2); Long userId = 1L; Long applicationId = 2L; setupGetWithRestResultExpectations(format("%s/user/%s/application/%s", assessmentRestURL, userId, applicationId), assessmentResourceListType(), expected); assertSame(expected, service.getByUserAndApplication(userId, applicationId).getSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId) { return getWithRestResult(format("%s/state/%s/competition/%s/count", assessmentRestURL, state.getStateName(), competitionId), Long.TYPE); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void countByStateAndCompetition() { Long expected = 2L; AssessmentState state = AssessmentState.CREATED; Long competitionId = 2L; setupGetWithRestResultExpectations(format("%s/state/%s/competition/%s/count", assessmentRestURL, state, competitionId), Long.TYPE, expected); assertSame(expected, service.countByStateAndCompetition(state, competitionId).getSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<AssessmentTotalScoreResource> getTotalScore(long id) { return getWithRestResult(format("%s/%s/score", assessmentRestURL, id), AssessmentTotalScoreResource.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void getTotalScore() { AssessmentTotalScoreResource expected = newAssessmentTotalScoreResource().build(); Long assessmentId = 1L; setupGetWithRestResultExpectations(format("%s/%s/score", assessmentRestURL, assessmentId), AssessmentTotalScoreResource.class, expected); assertSame(expected, service.getTotalScore(assessmentId).getSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision) { return putWithRestResult(format("%s/%s/recommend", assessmentRestURL, id), assessmentFundingDecision, Void.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void recommend() { Long assessmentId = 1L; AssessmentFundingDecisionOutcomeResource assessmentFundingDecisionOutcomeResource = newAssessmentFundingDecisionOutcomeResource().build(); setupPutWithRestResultExpectations(format("%s/%s/recommend", assessmentRestURL, assessmentId), assessmentFundingDecisionOutcomeResource, OK); RestResult<Void> response = service.recommend(assessmentId, assessmentFundingDecisionOutcomeResource); assertTrue(response.isSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId) { return getWithRestResult(format("%s/application/%s/feedback", assessmentRestURL, applicationId), ApplicationAssessmentFeedbackResource.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void getApplicationFeedback() { long applicationId = 1L; ApplicationAssessmentFeedbackResource expectedResource = newApplicationAssessmentFeedbackResource().build(); setupGetWithRestResultExpectations( format("%s/application/%s/feedback", assessmentRestURL, applicationId), ApplicationAssessmentFeedbackResource.class, expectedResource, OK ); RestResult<ApplicationAssessmentFeedbackResource> response = service.getApplicationFeedback(applicationId); assertTrue(response.isSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource) { return putWithRestResult(format("%s/%s/reject-invitation", assessmentRestURL, id), assessmentRejectOutcomeResource, Void.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void rejectInvitation() { Long assessmentId = 1L; AssessmentRejectOutcomeResource assessmentRejectOutcomeResource = newAssessmentRejectOutcomeResource().build(); setupPutWithRestResultExpectations(format("%s/%s/reject-invitation", assessmentRestURL, assessmentId), assessmentRejectOutcomeResource, OK); RestResult<Void> response = service.rejectInvitation(assessmentId, assessmentRejectOutcomeResource); assertTrue(response.isSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<Void> acceptInvitation(long id) { return putWithRestResult(format("%s/%s/accept-invitation", assessmentRestURL, id), Void.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void accept() { Long assessmentId = 1L; setupPutWithRestResultExpectations(format("%s/%s/accept-invitation", assessmentRestURL, assessmentId), null, OK); RestResult<Void> response = service.acceptInvitation(assessmentId); assertTrue(response.isSuccess()); }
RoleProfileStatusServiceImpl implements RoleProfileStatusService { @Override @Transactional public ServiceResult<UserPageResource> findByRoleProfile(RoleProfileState state, ProfileRole profileRole, String filter, Pageable pageable) { return userPageResource( roleProfileStatusRepository.findByRoleProfileStateAndProfileRoleAndUserEmailContainingAndUserStatus(state, profileRole, filter, UserStatus.ACTIVE, pageable) .map(RoleProfileStatus::getUser) ); } @Override @Transactional ServiceResult<Void> updateUserStatus(long userId, RoleProfileStatusResource roleProfileStatusResource); @Override ServiceResult<List<RoleProfileStatusResource>> findByUserId(long userId); @Override ServiceResult<RoleProfileStatusResource> findByUserIdAndProfileRole(long userId, ProfileRole profileRole); @Override @Transactional ServiceResult<UserPageResource> findByRoleProfile(RoleProfileState state, ProfileRole profileRole, String filter, Pageable pageable); }
@Test public void findByRoleProfile() { RoleProfileState roleProfileState = RoleProfileState.ACTIVE; ProfileRole profileRole = ProfileRole.ASSESSOR; String filter = ""; Pageable pageable = PageRequest.of(0, 5); int numberOfUsers = 2; User[] expectedUsers = newUser().buildArray(numberOfUsers, User.class); UserResource[] expectedUserResources = newUserResource().buildArray(expectedUsers.length, UserResource.class); List<RoleProfileStatus> expectedProfileStatuses = newRoleProfileStatus().withUser(expectedUsers).build(expectedUsers.length); Page<RoleProfileStatus> expectedPage = new PageImpl<>(expectedProfileStatuses, pageable, expectedUsers.length); when(roleProfileStatusRepositoryMock.findByRoleProfileStateAndProfileRoleAndUserEmailContainingAndUserStatus( roleProfileState, profileRole, filter, UserStatus.ACTIVE, pageable) ) .thenReturn(expectedPage); for (int i = 0; i < expectedUsers.length; i++) { when(userMapperMock.mapToResource(expectedUsers[i])).thenReturn(expectedUserResources[i]); } UserPageResource userPageResource = service.findByRoleProfile(roleProfileState, profileRole, filter, pageable).getSuccess(); assertEquals(asList(expectedUserResources), userPageResource.getContent()); assertEquals(numberOfUsers, userPageResource.getTotalElements()); assertEquals(pageable.getPageNumber(), userPageResource.getNumber()); assertEquals(pageable.getPageSize(), userPageResource.getSize()); InOrder inOrder = inOrder(roleProfileStatusRepositoryMock, userMapperMock); inOrder.verify(roleProfileStatusRepositoryMock).findByRoleProfileStateAndProfileRoleAndUserEmailContainingAndUserStatus( roleProfileState, profileRole, filter, UserStatus.ACTIVE, pageable); stream(expectedUsers).forEachOrdered(u -> inOrder.verify(userMapperMock).mapToResource(u)); inOrder.verifyNoMoreInteractions(); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions) { return putWithRestResult(format("%s/submit-assessments", assessmentRestURL), assessmentSubmissions, Void.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void submitAssessments() { AssessmentSubmissionsResource assessmentSubmissions = newAssessmentSubmissionsResource().build(); setupPutWithRestResultExpectations(format("%s/submit-assessments", assessmentRestURL), assessmentSubmissions, OK); RestResult<Void> response = service.submitAssessments(assessmentSubmissions); assertTrue(response.isSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<Void> withdrawAssessment(long id) { return putWithRestResult(format("%s/%s/withdraw", assessmentRestURL, id), Void.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void withdrawAssessment() { Long assessmentId = 1L; setupPutWithRestResultExpectations(format("%s/%s/withdraw", assessmentRestURL, assessmentId), null, OK); RestResult<Void> response = service.withdrawAssessment(assessmentId); assertTrue(response.isSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource) { return postWithRestResult(format("%s", assessmentRestURL), assessmentCreateResource, AssessmentResource.class); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void createAssessment() { AssessmentCreateResource resource = new AssessmentCreateResource(1L, 2L); AssessmentResource assessment = new AssessmentResource(); setupPostWithRestResultExpectations(assessmentRestURL, AssessmentResource.class, resource, assessment, OK); RestResult<AssessmentResource> response = service.createAssessment(resource); assertTrue(response.isSuccess()); assertEquals(assessment, response.getSuccess()); }
AssessmentRestServiceImpl extends BaseRestService implements AssessmentRestService { @Override public RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource) { return postWithRestResult(format("%s/bulk", assessmentRestURL), assessmentCreateResource, new ParameterizedTypeReference<List<AssessmentResource>>() {}); } @Override RestResult<AssessmentResource> getById(final long id); @Override RestResult<AssessmentResource> getAssignableById(long id); @Override RestResult<AssessmentResource> getRejectableById(long id); @Override RestResult<List<AssessmentResource>> getByUserAndCompetition(long userId, long competitionId); RestResult<List<AssessmentResource>> getByUserAndApplication(long userId, long applicationId); @Override RestResult<Long> countByStateAndCompetition(AssessmentState state, long competitionId); @Override RestResult<AssessmentTotalScoreResource> getTotalScore(long id); @Override RestResult<Void> recommend(long id, AssessmentFundingDecisionOutcomeResource assessmentFundingDecision); @Override RestResult<ApplicationAssessmentFeedbackResource> getApplicationFeedback(long applicationId); @Override RestResult<Void> rejectInvitation(long id, AssessmentRejectOutcomeResource assessmentRejectOutcomeResource); @Override RestResult<Void> withdrawAssessment(long id); @Override RestResult<Void> acceptInvitation(long id); @Override RestResult<Void> submitAssessments(AssessmentSubmissionsResource assessmentSubmissions); @Override RestResult<AssessmentResource> createAssessment(AssessmentCreateResource assessmentCreateResource); @Override RestResult<List<AssessmentResource>> createAssessments(List<AssessmentCreateResource> assessmentCreateResource); }
@Test public void createAssessments() { List<AssessmentCreateResource> resource = singletonList(new AssessmentCreateResource(1L, 2L)); List<AssessmentResource> assessment = singletonList(new AssessmentResource()); setupPostWithRestResultExpectations(format("%s/bulk", assessmentRestURL), new ParameterizedTypeReference<List<AssessmentResource>>() {}, resource, assessment, OK); RestResult<List<AssessmentResource>> response = service.createAssessments(resource); assertTrue(response.isSuccess()); assertEquals(assessment, response.getSuccess()); }
AssessorCompetitionDashboardRestServiceImpl extends BaseRestService implements AssessorCompetitionDashboardRestService { @Override public RestResult<AssessorCompetitionDashboardResource> getAssessorCompetitionDashboard(long competitionId, long userId) { return getWithRestResult(format(baseUrl + "/dashboard", userId, competitionId), AssessorCompetitionDashboardResource.class); } @Override RestResult<AssessorCompetitionDashboardResource> getAssessorCompetitionDashboard(long competitionId, long userId); }
@Test public void getAssessorCompetitionDashboard() { long userId = 1L; long competitionId = 2L; String baseUrl = "/assessment/user/%d/competition/%d"; AssessorCompetitionDashboardResource expected = newAssessorCompetitionDashboardResource() .withCompetitionId(competitionId) .build(); setupGetWithRestResultExpectations(format(baseUrl + "/dashboard", userId, competitionId), AssessorCompetitionDashboardResource.class, expected); AssessorCompetitionDashboardResource actual = service.getAssessorCompetitionDashboard(competitionId, userId).getSuccess(); assertEquals(expected, actual); }
CompetitionSetupPostAwardServiceRestServiceImpl extends BaseRestService implements CompetitionSetupPostAwardServiceRestService { @Override public RestResult<Void> setPostAwardService(long competitionId, PostAwardService postAwardService) { return postWithRestResult(format("%s/%d/%s/%s", COMPETITIONS_POST_AWARD_REST_URL, competitionId, POST_AWARD_SERVICE, postAwardService.name())); } @Override RestResult<CompetitionPostAwardServiceResource> getPostAwardService(long competitionId); @Override RestResult<Void> setPostAwardService(long competitionId, PostAwardService postAwardService); }
@Test public void setPostAwardService() { Long competitionId = 4L; PostAwardService postAwardService = PostAwardService.CONNECT; setupPostWithRestResultExpectations(format("%s/%d/%s/%s", COMPETITIONS_POST_AWARD_REST_URL, competitionId, "post-award-service", "CONNECT"), HttpStatus.OK); RestResult<Void> result = service.setPostAwardService(competitionId, postAwardService); assertTrue(result.isSuccess()); }
CompetitionSetupPostAwardServiceRestServiceImpl extends BaseRestService implements CompetitionSetupPostAwardServiceRestService { @Override public RestResult<CompetitionPostAwardServiceResource> getPostAwardService(long competitionId) { return getWithRestResult(format("%s/%d/%s", COMPETITIONS_POST_AWARD_REST_URL, competitionId, POST_AWARD_SERVICE), CompetitionPostAwardServiceResource.class); } @Override RestResult<CompetitionPostAwardServiceResource> getPostAwardService(long competitionId); @Override RestResult<Void> setPostAwardService(long competitionId, PostAwardService postAwardService); }
@Test public void getPostAwardService() { Long competitionId = 4L; CompetitionPostAwardServiceResource competitionPostAwardService = new CompetitionPostAwardServiceResource(); competitionPostAwardService.setCompetitionId(competitionId); competitionPostAwardService.setPostAwardService(PostAwardService.CONNECT); setupGetWithRestResultExpectations(format("%s/%d/%s", COMPETITIONS_POST_AWARD_REST_URL, competitionId, "post-award-service"), CompetitionPostAwardServiceResource.class, competitionPostAwardService); RestResult<CompetitionPostAwardServiceResource> result = service.getPostAwardService(competitionId); assertTrue(result.isSuccess()); assertEquals(competitionPostAwardService, result.getSuccess()); }
CompetitionKeyApplicationStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyApplicationStatisticsRestService { @Override public RestResult<CompetitionOpenKeyApplicationStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "open"), CompetitionOpenKeyApplicationStatisticsResource.class); } @Override RestResult<CompetitionOpenKeyApplicationStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyApplicationStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionFundedKeyApplicationStatisticsResource> getFundedKeyStatisticsByCompetition( long competitionId); @Override RestResult<ReviewKeyStatisticsResource> getReviewKeyStatisticsByCompetition(long competitionId); @Override RestResult<ReviewInviteStatisticsResource> getReviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewAssignmentKeyStatisticsResource> getInterviewAssignmentStatisticsByCompetition( long competitionId); @Override RestResult<InterviewInviteStatisticsResource> getInterviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewStatisticsResource> getInterviewStatisticsByCompetition(long competitionId); }
@Test public void getOpenKeyStatisticsByCompetition() { CompetitionOpenKeyApplicationStatisticsResource expected = newCompetitionOpenKeyApplicationStatisticsResource() .build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/open", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId), CompetitionOpenKeyApplicationStatisticsResource.class, expected); assertSame(expected, service.getOpenKeyStatisticsByCompetition(competitionId).getSuccess()); }
CompetitionKeyApplicationStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyApplicationStatisticsRestService { @Override public RestResult<CompetitionClosedKeyApplicationStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "closed"), CompetitionClosedKeyApplicationStatisticsResource.class); } @Override RestResult<CompetitionOpenKeyApplicationStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyApplicationStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionFundedKeyApplicationStatisticsResource> getFundedKeyStatisticsByCompetition( long competitionId); @Override RestResult<ReviewKeyStatisticsResource> getReviewKeyStatisticsByCompetition(long competitionId); @Override RestResult<ReviewInviteStatisticsResource> getReviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewAssignmentKeyStatisticsResource> getInterviewAssignmentStatisticsByCompetition( long competitionId); @Override RestResult<InterviewInviteStatisticsResource> getInterviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewStatisticsResource> getInterviewStatisticsByCompetition(long competitionId); }
@Test public void getClosedKeyStatisticsByCompetition() { CompetitionClosedKeyApplicationStatisticsResource expected = newCompetitionClosedKeyApplicationStatisticsResource().build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/closed", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId), CompetitionClosedKeyApplicationStatisticsResource.class, expected); assertSame(expected, service.getClosedKeyStatisticsByCompetition(competitionId).getSuccess()); }
CompetitionKeyApplicationStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyApplicationStatisticsRestService { @Override public RestResult<CompetitionFundedKeyApplicationStatisticsResource> getFundedKeyStatisticsByCompetition( long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "funded"), CompetitionFundedKeyApplicationStatisticsResource.class); } @Override RestResult<CompetitionOpenKeyApplicationStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyApplicationStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionFundedKeyApplicationStatisticsResource> getFundedKeyStatisticsByCompetition( long competitionId); @Override RestResult<ReviewKeyStatisticsResource> getReviewKeyStatisticsByCompetition(long competitionId); @Override RestResult<ReviewInviteStatisticsResource> getReviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewAssignmentKeyStatisticsResource> getInterviewAssignmentStatisticsByCompetition( long competitionId); @Override RestResult<InterviewInviteStatisticsResource> getInterviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewStatisticsResource> getInterviewStatisticsByCompetition(long competitionId); }
@Test public void getFundedKeyStatisticsByCompetition() { CompetitionFundedKeyApplicationStatisticsResource expected = newCompetitionFundedKeyApplicationStatisticsResource().build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/funded", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId) , CompetitionFundedKeyApplicationStatisticsResource.class, expected); assertSame(expected, service.getFundedKeyStatisticsByCompetition(competitionId).getSuccess()); }
AgreementServiceImpl extends BaseTransactionalService implements AgreementService { @Override public ServiceResult<AgreementResource> getCurrent() { return find(repository.findByCurrentTrue(), notFoundError(Agreement.class)).andOnSuccessReturn(mapper::mapToResource); } @Override ServiceResult<AgreementResource> getCurrent(); }
@Test public void getCurrent() throws Exception { Agreement agreement = newAgreement().build(); AgreementResource agreementResource = newAgreementResource().build(); when(agreementRepositoryMock.findByCurrentTrue()).thenReturn(agreement); when(agreementMapperMock.mapToResource(same(agreement))).thenReturn(agreementResource); ServiceResult<AgreementResource> result = agreementService.getCurrent(); assertTrue(result.isSuccess()); assertEquals(agreementResource, result.getSuccess()); verify(agreementRepositoryMock, only()).findByCurrentTrue(); verify(agreementMapperMock, only()).mapToResource(same(agreement)); } @Test public void getCurrent_notFound() throws Exception { Agreement agreement = newAgreement().build(); AgreementResource agreementResource = newAgreementResource().build(); when(agreementRepositoryMock.findByCurrentTrue()).thenReturn(null); when(agreementMapperMock.mapToResource(same(agreement))).thenReturn(agreementResource); ServiceResult<AgreementResource> result = agreementService.getCurrent(); assertTrue(result.isFailure()); assertTrue(result.getFailure().is(notFoundError(Agreement.class))); verify(agreementRepositoryMock, only()).findByCurrentTrue(); verifyZeroInteractions(agreementMapperMock); }
FileFunctions { public static final String pathElementsToPathString(List<String> pathElements) { if (pathElements == null || pathElements.isEmpty()) { return ""; } return pathElements.stream().reduce("", (pathSoFar, nextPathSegment) -> pathSoFar + (!pathSoFar.isEmpty() ? separator : "") + nextPathSegment); } private FileFunctions(); static final String pathElementsToPathString(List<String> pathElements); static final List<String> pathStringToPathElements(final String pathString); static final String pathElementsToAbsolutePathString(List<String> pathElements, String absolutePathPrefix); static final List<String> pathElementsToAbsolutePathElements(List<String> pathElements, String absolutePathPrefix); static final File pathElementsToFile(List<String> pathElements); static final Path pathElementsToPath(List<String> pathElements); }
@Test public void testPathElementsToPathString() { assertEquals("path" + separator + "to" + separator + "file", FileFunctions.pathElementsToPathString(asList("path", "to", "file"))); } @Test public void testPathElementsToPathStringWithLeadingSeparator() { assertEquals(separator + "path" + separator + "to" + separator + "file", FileFunctions.pathElementsToPathString(asList(separator + "path", "to", "file"))); } @Test public void testPathElementsToPathStringWithEmptyStringList() { assertEquals("", FileFunctions.pathElementsToPathString(asList())); } @Test public void testPathElementsToPathStringWithNullStringList() { assertEquals("", FileFunctions.pathElementsToPathString(null)); } @Test public void testPathElementsToPathStringWithNullStringElements() { assertEquals("path" + separator + "null" + separator + "file", FileFunctions.pathElementsToPathString(asList("path", null, "file"))); }
CompetitionKeyApplicationStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyApplicationStatisticsRestService { @Override public RestResult<ReviewKeyStatisticsResource> getReviewKeyStatisticsByCompetition(long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "review"), ReviewKeyStatisticsResource.class); } @Override RestResult<CompetitionOpenKeyApplicationStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyApplicationStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionFundedKeyApplicationStatisticsResource> getFundedKeyStatisticsByCompetition( long competitionId); @Override RestResult<ReviewKeyStatisticsResource> getReviewKeyStatisticsByCompetition(long competitionId); @Override RestResult<ReviewInviteStatisticsResource> getReviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewAssignmentKeyStatisticsResource> getInterviewAssignmentStatisticsByCompetition( long competitionId); @Override RestResult<InterviewInviteStatisticsResource> getInterviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewStatisticsResource> getInterviewStatisticsByCompetition(long competitionId); }
@Test public void getReviewKeyStatisticsByCompetition() { ReviewKeyStatisticsResource expected = newReviewKeyStatisticsResource().build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "review"), ReviewKeyStatisticsResource.class, expected); assertSame(expected, service.getReviewKeyStatisticsByCompetition(competitionId).getSuccess()); }
CompetitionKeyApplicationStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyApplicationStatisticsRestService { @Override public RestResult<ReviewInviteStatisticsResource> getReviewInviteStatisticsByCompetition(long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "review-invites"), ReviewInviteStatisticsResource.class); } @Override RestResult<CompetitionOpenKeyApplicationStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyApplicationStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionFundedKeyApplicationStatisticsResource> getFundedKeyStatisticsByCompetition( long competitionId); @Override RestResult<ReviewKeyStatisticsResource> getReviewKeyStatisticsByCompetition(long competitionId); @Override RestResult<ReviewInviteStatisticsResource> getReviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewAssignmentKeyStatisticsResource> getInterviewAssignmentStatisticsByCompetition( long competitionId); @Override RestResult<InterviewInviteStatisticsResource> getInterviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewStatisticsResource> getInterviewStatisticsByCompetition(long competitionId); }
@Test public void getReviewInviteStatisticsByCompetition() { ReviewInviteStatisticsResource expected = newReviewInviteStatisticsResource().build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "review-invites"), ReviewInviteStatisticsResource.class, expected); assertSame(expected, service.getReviewInviteStatisticsByCompetition(competitionId).getSuccess()); }
CompetitionKeyApplicationStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyApplicationStatisticsRestService { @Override public RestResult<InterviewAssignmentKeyStatisticsResource> getInterviewAssignmentStatisticsByCompetition( long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "interview-assignment"), InterviewAssignmentKeyStatisticsResource.class); } @Override RestResult<CompetitionOpenKeyApplicationStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyApplicationStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionFundedKeyApplicationStatisticsResource> getFundedKeyStatisticsByCompetition( long competitionId); @Override RestResult<ReviewKeyStatisticsResource> getReviewKeyStatisticsByCompetition(long competitionId); @Override RestResult<ReviewInviteStatisticsResource> getReviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewAssignmentKeyStatisticsResource> getInterviewAssignmentStatisticsByCompetition( long competitionId); @Override RestResult<InterviewInviteStatisticsResource> getInterviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewStatisticsResource> getInterviewStatisticsByCompetition(long competitionId); }
@Test public void getInterviewAssignmentStatisticsByCompetition() { long competitionId = 1L; InterviewAssignmentKeyStatisticsResource expected = newInterviewAssignmentKeyStatisticsResource().build(); setupGetWithRestResultExpectations(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "interview-assignment"), InterviewAssignmentKeyStatisticsResource.class, expected); InterviewAssignmentKeyStatisticsResource actual = service.getInterviewAssignmentStatisticsByCompetition (competitionId).getSuccess(); assertEquals(expected, actual); }
CompetitionKeyApplicationStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyApplicationStatisticsRestService { @Override public RestResult<InterviewInviteStatisticsResource> getInterviewInviteStatisticsByCompetition(long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "interview-invites"), InterviewInviteStatisticsResource.class); } @Override RestResult<CompetitionOpenKeyApplicationStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyApplicationStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionFundedKeyApplicationStatisticsResource> getFundedKeyStatisticsByCompetition( long competitionId); @Override RestResult<ReviewKeyStatisticsResource> getReviewKeyStatisticsByCompetition(long competitionId); @Override RestResult<ReviewInviteStatisticsResource> getReviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewAssignmentKeyStatisticsResource> getInterviewAssignmentStatisticsByCompetition( long competitionId); @Override RestResult<InterviewInviteStatisticsResource> getInterviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewStatisticsResource> getInterviewStatisticsByCompetition(long competitionId); }
@Test public void getInterviewInviteStatisticsByCompetition() { InterviewInviteStatisticsResource expected = newInterviewInviteStatisticsResource().build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "interview-invites"), InterviewInviteStatisticsResource.class, expected); assertSame(expected, service.getInterviewInviteStatisticsByCompetition(competitionId).getSuccess()); }
CompetitionKeyApplicationStatisticsRestServiceImpl extends BaseRestService implements CompetitionKeyApplicationStatisticsRestService { @Override public RestResult<InterviewStatisticsResource> getInterviewStatisticsByCompetition(long competitionId) { return getWithRestResult(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "interview"), InterviewStatisticsResource.class); } @Override RestResult<CompetitionOpenKeyApplicationStatisticsResource> getOpenKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionClosedKeyApplicationStatisticsResource> getClosedKeyStatisticsByCompetition( long competitionId); @Override RestResult<CompetitionFundedKeyApplicationStatisticsResource> getFundedKeyStatisticsByCompetition( long competitionId); @Override RestResult<ReviewKeyStatisticsResource> getReviewKeyStatisticsByCompetition(long competitionId); @Override RestResult<ReviewInviteStatisticsResource> getReviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewAssignmentKeyStatisticsResource> getInterviewAssignmentStatisticsByCompetition( long competitionId); @Override RestResult<InterviewInviteStatisticsResource> getInterviewInviteStatisticsByCompetition(long competitionId); @Override RestResult<InterviewStatisticsResource> getInterviewStatisticsByCompetition(long competitionId); }
@Test public void getInterviewStatisticsByCompetition() { InterviewStatisticsResource expected = newInterviewStatisticsResource().build(); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/%s/%s", COMPETITION_APPLICATION_KEY_STATISTICS_REST_URL, competitionId, "interview"), InterviewStatisticsResource.class, expected); assertSame(expected, service.getInterviewStatisticsByCompetition(competitionId).getSuccess()); }
CompetitionOrganisationConfigRestServiceImpl extends BaseRestService implements CompetitionOrganisationConfigRestService { @Override public RestResult<CompetitionOrganisationConfigResource> findByCompetitionId(long competitionId) { return getWithRestResultAnonymous(competitionOrganisationConfigUrl + "/find-by-competition-id/" + competitionId, CompetitionOrganisationConfigResource.class); } @Override RestResult<CompetitionOrganisationConfigResource> findByCompetitionId(long competitionId); @Override RestResult<CompetitionOrganisationConfigResource> update(long competitionId, CompetitionOrganisationConfigResource competitionOrganisationConfigResource); }
@Test public void findOrganisationConfigByCompetitionId() { CompetitionOrganisationConfigResource returnedResponse = new CompetitionOrganisationConfigResource(true, true); setupGetWithRestResultAnonymousExpectations(format("%s/find-by-competition-id/%d", COMPETITION_ORGANISATION_CONFIG_BASE_URL, 123), CompetitionOrganisationConfigResource.class, returnedResponse); CompetitionOrganisationConfigResource responses = service.findByCompetitionId(123).getSuccess(); assertNotNull(responses); assertEquals(returnedResponse, responses); }
CompetitionOrganisationConfigRestServiceImpl extends BaseRestService implements CompetitionOrganisationConfigRestService { @Override public RestResult<CompetitionOrganisationConfigResource> update(long competitionId, CompetitionOrganisationConfigResource competitionOrganisationConfigResource) { return putWithRestResult(competitionOrganisationConfigUrl + "/update/" + competitionId, competitionOrganisationConfigResource, CompetitionOrganisationConfigResource.class); } @Override RestResult<CompetitionOrganisationConfigResource> findByCompetitionId(long competitionId); @Override RestResult<CompetitionOrganisationConfigResource> update(long competitionId, CompetitionOrganisationConfigResource competitionOrganisationConfigResource); }
@Test public void updateOrganisationalEligibility() { long competitionId = 100L; CompetitionOrganisationConfigResource resource = newCompetitionOrganisationConfigResource() .build(); CompetitionOrganisationConfigResource expected = newCompetitionOrganisationConfigResource() .withInternationalOrganisationsAllowed(true) .withInternationalLeadOrganisationAllowed(true) .build(); setupPutWithRestResultExpectations(COMPETITION_ORGANISATION_CONFIG_BASE_URL + "/update/" + competitionId, CompetitionOrganisationConfigResource.class, resource, expected); CompetitionOrganisationConfigResource actual = service.update(competitionId, resource).getSuccess(); assertEquals(expected, actual); }
CompetitionSetupStakeholderRestServiceImpl extends BaseRestService implements CompetitionSetupStakeholderRestService { @Override public RestResult<Void> inviteStakeholder(InviteUserResource inviteUserResource, long competitionId) { return postWithRestResult(format("%s/%s/stakeholder/invite", competitionSetupStakeholderRestURL, competitionId), inviteUserResource, Void.class); } @Override RestResult<Void> inviteStakeholder(InviteUserResource inviteUserResource, long competitionId); @Override RestResult<List<UserResource>> findStakeholders(long competitionId); @Override RestResult<StakeholderInviteResource> getStakeholderInvite(String inviteHash); @Override RestResult<Void> createStakeholder(String inviteHash, StakeholderRegistrationResource stakeholderRegistrationResource); @Override RestResult<Void> addStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<Void> removeStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<List<UserResource>> findPendingStakeholderInvites(long competitionId); }
@Test public void inviteStakeholder() { long competitionId = 1L; InviteUserResource inviteUserResource = new InviteUserResource(); String url = competitionSetupStakeholderRestURL + competitionId + "/stakeholder/invite"; setupPostWithRestResultExpectations(url, inviteUserResource, HttpStatus.OK); RestResult<Void> result = service.inviteStakeholder(inviteUserResource, competitionId); assertTrue(result.isSuccess()); setupPostWithRestResultVerifications(url, Void.class, inviteUserResource); }
CompetitionSetupStakeholderRestServiceImpl extends BaseRestService implements CompetitionSetupStakeholderRestService { @Override public RestResult<List<UserResource>> findStakeholders(long competitionId) { return getWithRestResult(format("%s/%s/stakeholder/find-all", competitionSetupStakeholderRestURL , competitionId), userListType()); } @Override RestResult<Void> inviteStakeholder(InviteUserResource inviteUserResource, long competitionId); @Override RestResult<List<UserResource>> findStakeholders(long competitionId); @Override RestResult<StakeholderInviteResource> getStakeholderInvite(String inviteHash); @Override RestResult<Void> createStakeholder(String inviteHash, StakeholderRegistrationResource stakeholderRegistrationResource); @Override RestResult<Void> addStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<Void> removeStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<List<UserResource>> findPendingStakeholderInvites(long competitionId); }
@Test public void findStakeholders() { long competitionId = 1L; List<UserResource> responseBody = newUserResource().build(2); String url = competitionSetupStakeholderRestURL + competitionId + "/stakeholder/find-all"; setupGetWithRestResultExpectations(url, userListType(), responseBody); List<UserResource> response = service.findStakeholders(competitionId).getSuccess(); assertEquals(responseBody, response); }
CompetitionSetupStakeholderRestServiceImpl extends BaseRestService implements CompetitionSetupStakeholderRestService { @Override public RestResult<StakeholderInviteResource> getStakeholderInvite(String inviteHash) { return getWithRestResultAnonymous(format("%s/get-stakeholder-invite/%s", competitionSetupStakeholderRestURL, inviteHash), StakeholderInviteResource.class); } @Override RestResult<Void> inviteStakeholder(InviteUserResource inviteUserResource, long competitionId); @Override RestResult<List<UserResource>> findStakeholders(long competitionId); @Override RestResult<StakeholderInviteResource> getStakeholderInvite(String inviteHash); @Override RestResult<Void> createStakeholder(String inviteHash, StakeholderRegistrationResource stakeholderRegistrationResource); @Override RestResult<Void> addStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<Void> removeStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<List<UserResource>> findPendingStakeholderInvites(long competitionId); }
@Test public void getInvite() { String hash = "hash1234"; StakeholderInviteResource invite = newStakeholderInviteResource().build(); String url = competitionSetupStakeholderRestURL + "get-stakeholder-invite/" + hash; setupGetWithRestResultAnonymousExpectations(url, StakeholderInviteResource.class, invite); StakeholderInviteResource response = service.getStakeholderInvite(hash).getSuccess(); assertEquals(invite, response); }
CompetitionSetupStakeholderRestServiceImpl extends BaseRestService implements CompetitionSetupStakeholderRestService { @Override public RestResult<Void> createStakeholder(String inviteHash, StakeholderRegistrationResource stakeholderRegistrationResource) { String url = format("%s/stakeholder/create/%s", competitionSetupStakeholderRestURL, inviteHash); return postWithRestResultAnonymous(url, stakeholderRegistrationResource, Void.class); } @Override RestResult<Void> inviteStakeholder(InviteUserResource inviteUserResource, long competitionId); @Override RestResult<List<UserResource>> findStakeholders(long competitionId); @Override RestResult<StakeholderInviteResource> getStakeholderInvite(String inviteHash); @Override RestResult<Void> createStakeholder(String inviteHash, StakeholderRegistrationResource stakeholderRegistrationResource); @Override RestResult<Void> addStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<Void> removeStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<List<UserResource>> findPendingStakeholderInvites(long competitionId); }
@Test public void createStakeholder() { String hash = "hash1234"; StakeholderRegistrationResource resource = newStakeholderRegistrationResource().build(); String url = competitionSetupStakeholderRestURL + "stakeholder/create/" + hash; setupPostWithRestResultAnonymousExpectations(url, Void.class, resource, null, HttpStatus.OK); RestResult<Void> result = service.createStakeholder(hash, resource); assertTrue(result.isSuccess()); }
CompetitionSetupStakeholderRestServiceImpl extends BaseRestService implements CompetitionSetupStakeholderRestService { @Override public RestResult<Void> addStakeholder(long competitionId, long stakeholderUserId) { return postWithRestResult(format("%s/%s/stakeholder/%s/add", competitionSetupStakeholderRestURL, competitionId, stakeholderUserId), Void.class); } @Override RestResult<Void> inviteStakeholder(InviteUserResource inviteUserResource, long competitionId); @Override RestResult<List<UserResource>> findStakeholders(long competitionId); @Override RestResult<StakeholderInviteResource> getStakeholderInvite(String inviteHash); @Override RestResult<Void> createStakeholder(String inviteHash, StakeholderRegistrationResource stakeholderRegistrationResource); @Override RestResult<Void> addStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<Void> removeStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<List<UserResource>> findPendingStakeholderInvites(long competitionId); }
@Test public void addStakeholder() { long competitionId = 1L; long stakeholderUserId = 2L; String url = competitionSetupStakeholderRestURL + competitionId + "/stakeholder/" + stakeholderUserId + "/add"; setupPostWithRestResultExpectations(url, HttpStatus.OK); RestResult<Void> result = service.addStakeholder(competitionId, stakeholderUserId); assertTrue(result.isSuccess()); setupPostWithRestResultVerifications(url, Void.class); }
CompetitionSetupStakeholderRestServiceImpl extends BaseRestService implements CompetitionSetupStakeholderRestService { @Override public RestResult<Void> removeStakeholder(long competitionId, long stakeholderUserId) { return postWithRestResult(format("%s/%s/stakeholder/%s/remove",competitionSetupStakeholderRestURL, competitionId, stakeholderUserId), Void.class); } @Override RestResult<Void> inviteStakeholder(InviteUserResource inviteUserResource, long competitionId); @Override RestResult<List<UserResource>> findStakeholders(long competitionId); @Override RestResult<StakeholderInviteResource> getStakeholderInvite(String inviteHash); @Override RestResult<Void> createStakeholder(String inviteHash, StakeholderRegistrationResource stakeholderRegistrationResource); @Override RestResult<Void> addStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<Void> removeStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<List<UserResource>> findPendingStakeholderInvites(long competitionId); }
@Test public void removeStakeholder() { long competitionId = 1L; long stakeholderUserId = 2L; String url = competitionSetupStakeholderRestURL + competitionId + "/stakeholder/" + stakeholderUserId + "/remove"; setupPostWithRestResultExpectations(url, HttpStatus.OK); RestResult<Void> result = service.removeStakeholder(competitionId, stakeholderUserId); assertTrue(result.isSuccess()); setupPostWithRestResultVerifications(url, Void.class); }
CompetitionSetupStakeholderRestServiceImpl extends BaseRestService implements CompetitionSetupStakeholderRestService { @Override public RestResult<List<UserResource>> findPendingStakeholderInvites(long competitionId) { return getWithRestResult(format("%s/%s/stakeholder/pending-invites", competitionSetupStakeholderRestURL, competitionId), userListType()); } @Override RestResult<Void> inviteStakeholder(InviteUserResource inviteUserResource, long competitionId); @Override RestResult<List<UserResource>> findStakeholders(long competitionId); @Override RestResult<StakeholderInviteResource> getStakeholderInvite(String inviteHash); @Override RestResult<Void> createStakeholder(String inviteHash, StakeholderRegistrationResource stakeholderRegistrationResource); @Override RestResult<Void> addStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<Void> removeStakeholder(long competitionId, long stakeholderUserId); @Override RestResult<List<UserResource>> findPendingStakeholderInvites(long competitionId); }
@Test public void findPendingStakeholderInvites() { long competitionId = 1L; List<UserResource> responseBody = newUserResource().build(2); String url = competitionSetupStakeholderRestURL + competitionId + "/stakeholder/pending-invites"; setupGetWithRestResultExpectations(url, userListType(), responseBody); List<UserResource> response = service.findPendingStakeholderInvites(competitionId).getSuccess(); assertEquals(responseBody, response); }
AlertRestServiceImpl extends BaseRestService implements AlertRestService { @Override @HystrixCommand(fallbackMethod = "findAllVisibleFallback") public RestResult<List<AlertResource>> findAllVisible() { return getWithRestResultAnonymous(alertRestURL + "/find-all-visible", ParameterizedTypeReferences.alertResourceListType()); } @Value("${ifs.alert.service.rest.baseURL}") @Override void setServiceUrl(String serviceUrl); @Override @HystrixCommand(fallbackMethod = "findAllVisibleFallback") RestResult<List<AlertResource>> findAllVisible(); RestResult<List<AlertResource>> findAllVisibleFallback(Throwable e); @Override @HystrixCommand(fallbackMethod = "findAllVisibleByTypeFallback") RestResult<List<AlertResource>> findAllVisibleByType(AlertType type); RestResult<List<AlertResource>> findAllVisibleByTypeFallback(AlertType type, Throwable e); @Override RestResult<AlertResource> getAlertById(final Long id); @Override RestResult<AlertResource> create(final AlertResource alertResource); @Override RestResult<Void> delete(final Long id); @Override RestResult<Void> deleteAllByType(final AlertType type); }
@Test public void findAllVisible() throws Exception { final AlertResource expected1 = new AlertResource(); expected1.setId(8888L); final AlertResource expected2 = new AlertResource(); expected2.setId(9999L); final List<AlertResource> expected = asList(expected1, expected2); setupGetWithRestResultAnonymousExpectations(alertRestURL + "/find-all-visible", alertResourceListType(), expected, OK); final List<AlertResource> response = service.findAllVisible().getSuccess(); assertSame(expected, response); }
AlertRestServiceImpl extends BaseRestService implements AlertRestService { public RestResult<List<AlertResource>> findAllVisibleFallback(Throwable e) { LOG.info("Calling Alerts Fallback:",e); return RestResult.restSuccess(Collections.emptyList()); } @Value("${ifs.alert.service.rest.baseURL}") @Override void setServiceUrl(String serviceUrl); @Override @HystrixCommand(fallbackMethod = "findAllVisibleFallback") RestResult<List<AlertResource>> findAllVisible(); RestResult<List<AlertResource>> findAllVisibleFallback(Throwable e); @Override @HystrixCommand(fallbackMethod = "findAllVisibleByTypeFallback") RestResult<List<AlertResource>> findAllVisibleByType(AlertType type); RestResult<List<AlertResource>> findAllVisibleByTypeFallback(AlertType type, Throwable e); @Override RestResult<AlertResource> getAlertById(final Long id); @Override RestResult<AlertResource> create(final AlertResource alertResource); @Override RestResult<Void> delete(final Long id); @Override RestResult<Void> deleteAllByType(final AlertType type); }
@Test public void findAllVisibleFallback() { assertTrue(service.findAllVisibleFallback(new Throwable()).getSuccess().isEmpty()); }
AlertRestServiceImpl extends BaseRestService implements AlertRestService { @Override @HystrixCommand(fallbackMethod = "findAllVisibleByTypeFallback") public RestResult<List<AlertResource>> findAllVisibleByType(AlertType type) { return getWithRestResultAnonymous(alertRestURL + "/find-all-visible/" + type.name(), ParameterizedTypeReferences.alertResourceListType()); } @Value("${ifs.alert.service.rest.baseURL}") @Override void setServiceUrl(String serviceUrl); @Override @HystrixCommand(fallbackMethod = "findAllVisibleFallback") RestResult<List<AlertResource>> findAllVisible(); RestResult<List<AlertResource>> findAllVisibleFallback(Throwable e); @Override @HystrixCommand(fallbackMethod = "findAllVisibleByTypeFallback") RestResult<List<AlertResource>> findAllVisibleByType(AlertType type); RestResult<List<AlertResource>> findAllVisibleByTypeFallback(AlertType type, Throwable e); @Override RestResult<AlertResource> getAlertById(final Long id); @Override RestResult<AlertResource> create(final AlertResource alertResource); @Override RestResult<Void> delete(final Long id); @Override RestResult<Void> deleteAllByType(final AlertType type); }
@Test public void findAllVisibleByType() throws Exception { final AlertResource expected1 = new AlertResource(); expected1.setId(8888L); final AlertResource expected2 = new AlertResource(); expected2.setId(9999L); final List<AlertResource> expected = asList(expected1, expected2); setupGetWithRestResultAnonymousExpectations(alertRestURL + "/find-all-visible/MAINTENANCE", alertResourceListType(), expected, OK); final List<AlertResource> response = service.findAllVisibleByType(AlertType.MAINTENANCE).getSuccess(); assertSame(expected, response); }
AlertRestServiceImpl extends BaseRestService implements AlertRestService { @Override public RestResult<AlertResource> getAlertById(final Long id) { return getWithRestResult(alertRestURL + "/" + id, AlertResource.class); } @Value("${ifs.alert.service.rest.baseURL}") @Override void setServiceUrl(String serviceUrl); @Override @HystrixCommand(fallbackMethod = "findAllVisibleFallback") RestResult<List<AlertResource>> findAllVisible(); RestResult<List<AlertResource>> findAllVisibleFallback(Throwable e); @Override @HystrixCommand(fallbackMethod = "findAllVisibleByTypeFallback") RestResult<List<AlertResource>> findAllVisibleByType(AlertType type); RestResult<List<AlertResource>> findAllVisibleByTypeFallback(AlertType type, Throwable e); @Override RestResult<AlertResource> getAlertById(final Long id); @Override RestResult<AlertResource> create(final AlertResource alertResource); @Override RestResult<Void> delete(final Long id); @Override RestResult<Void> deleteAllByType(final AlertType type); }
@Test public void getAlertById() throws Exception { final AlertResource expected = new AlertResource(); expected.setId(9999L); setupGetWithRestResultExpectations(alertRestURL + "/9999", AlertResource.class, expected, OK); final AlertResource response = service.getAlertById(9999L).getSuccess(); Assert.assertEquals(expected, response); }
AlertRestServiceImpl extends BaseRestService implements AlertRestService { @Override public RestResult<AlertResource> create(final AlertResource alertResource) { return postWithRestResult(alertRestURL + "/", alertResource, AlertResource.class); } @Value("${ifs.alert.service.rest.baseURL}") @Override void setServiceUrl(String serviceUrl); @Override @HystrixCommand(fallbackMethod = "findAllVisibleFallback") RestResult<List<AlertResource>> findAllVisible(); RestResult<List<AlertResource>> findAllVisibleFallback(Throwable e); @Override @HystrixCommand(fallbackMethod = "findAllVisibleByTypeFallback") RestResult<List<AlertResource>> findAllVisibleByType(AlertType type); RestResult<List<AlertResource>> findAllVisibleByTypeFallback(AlertType type, Throwable e); @Override RestResult<AlertResource> getAlertById(final Long id); @Override RestResult<AlertResource> create(final AlertResource alertResource); @Override RestResult<Void> delete(final Long id); @Override RestResult<Void> deleteAllByType(final AlertType type); }
@Test public void create() throws Exception { final AlertResource alertResource = sampleAlert(); setupPostWithRestResultExpectations(alertRestURL + "/", AlertResource.class, alertResource, alertResource, CREATED); final AlertResource created = service.create(alertResource).getSuccess(); setupPostWithRestResultVerifications(alertRestURL + "/", AlertResource.class, alertResource); Assert.assertEquals("Sample message", created.getMessage()); }
AlertRestServiceImpl extends BaseRestService implements AlertRestService { @Override public RestResult<Void> delete(final Long id) { return deleteWithRestResult(alertRestURL + "/" + id); } @Value("${ifs.alert.service.rest.baseURL}") @Override void setServiceUrl(String serviceUrl); @Override @HystrixCommand(fallbackMethod = "findAllVisibleFallback") RestResult<List<AlertResource>> findAllVisible(); RestResult<List<AlertResource>> findAllVisibleFallback(Throwable e); @Override @HystrixCommand(fallbackMethod = "findAllVisibleByTypeFallback") RestResult<List<AlertResource>> findAllVisibleByType(AlertType type); RestResult<List<AlertResource>> findAllVisibleByTypeFallback(AlertType type, Throwable e); @Override RestResult<AlertResource> getAlertById(final Long id); @Override RestResult<AlertResource> create(final AlertResource alertResource); @Override RestResult<Void> delete(final Long id); @Override RestResult<Void> deleteAllByType(final AlertType type); }
@Test public void delete() throws Exception { setupDeleteWithRestResultExpectations(alertRestURL + "/9999"); service.delete(9999L); setupDeleteWithRestResultVerifications(alertRestURL + "/9999"); }
UserSurveyServiceImpl implements UserSurveyService { @Override public ServiceResult<Void> sendApplicantDiversitySurvey(User user) { return notificationService.sendNotificationWithFlush(surveyNotification(user, DIVERSITY_SURVEY_APPLICANT), EMAIL); } @Override ServiceResult<Void> sendApplicantDiversitySurvey(User user); @Override ServiceResult<Void> sendAssessorDiversitySurvey(User user); }
@Test public void sendApplicantDiversitySurvey() throws Exception { User user = newUser() .withFirstName("Tom") .withLastName("Baldwin") .withEmailAddress("[email protected]") .build(); when(notificationServiceMock.sendNotificationWithFlush(expectedNotification(user, DIVERSITY_SURVEY_APPLICANT), eq(NotificationMedium.EMAIL))).thenReturn(serviceSuccess()); service.sendApplicantDiversitySurvey(user).getSuccess(); InOrder inOrder = inOrder(notificationServiceMock); inOrder.verify(notificationServiceMock).sendNotificationWithFlush(expectedNotification(user, DIVERSITY_SURVEY_APPLICANT), eq(NotificationMedium.EMAIL)); inOrder.verifyNoMoreInteractions(); }
AlertRestServiceImpl extends BaseRestService implements AlertRestService { @Override public RestResult<Void> deleteAllByType(final AlertType type) { return deleteWithRestResult(alertRestURL + "/delete/" + type.name()); } @Value("${ifs.alert.service.rest.baseURL}") @Override void setServiceUrl(String serviceUrl); @Override @HystrixCommand(fallbackMethod = "findAllVisibleFallback") RestResult<List<AlertResource>> findAllVisible(); RestResult<List<AlertResource>> findAllVisibleFallback(Throwable e); @Override @HystrixCommand(fallbackMethod = "findAllVisibleByTypeFallback") RestResult<List<AlertResource>> findAllVisibleByType(AlertType type); RestResult<List<AlertResource>> findAllVisibleByTypeFallback(AlertType type, Throwable e); @Override RestResult<AlertResource> getAlertById(final Long id); @Override RestResult<AlertResource> create(final AlertResource alertResource); @Override RestResult<Void> delete(final Long id); @Override RestResult<Void> deleteAllByType(final AlertType type); }
@Test public void deleteAllByType() throws Exception { setupDeleteWithRestResultExpectations(alertRestURL + "/delete/MAINTENANCE"); service.deleteAllByType(AlertType.MAINTENANCE); setupDeleteWithRestResultVerifications(alertRestURL + "/delete/MAINTENANCE"); }
ProfileRestServiceImpl extends BaseRestService implements ProfileRestService { @Override public RestResult<ProfileSkillsResource> getProfileSkills(Long userId) { return getWithRestResult(format("%s/id/%s/get-profile-skills", profileRestURL, userId), ProfileSkillsResource.class); } @Override RestResult<ProfileSkillsResource> getProfileSkills(Long userId); @Override RestResult<Void> updateProfileSkills(Long userId, ProfileSkillsEditResource profileSkillsEditResource); @Override RestResult<ProfileAgreementResource> getProfileAgreement(Long userId); @Override RestResult<Void> updateProfileAgreement(Long userId); @Override RestResult<UserProfileResource> getUserProfile(Long userId); @Override RestResult<Void> updateUserProfile(Long userId, UserProfileResource userProfile); @Override RestResult<UserProfileStatusResource> getUserProfileStatus(Long userId); }
@Test public void getProfileSkills() { Long userId = 1L; ProfileSkillsResource expected = newProfileSkillsResource().build(); setupGetWithRestResultExpectations(format("%s/id/%s/get-profile-skills", profileUrl, userId), ProfileSkillsResource.class, expected, OK); ProfileSkillsResource response = service.getProfileSkills(userId).getSuccess(); assertEquals(expected, response); }
ProfileRestServiceImpl extends BaseRestService implements ProfileRestService { @Override public RestResult<Void> updateProfileSkills(Long userId, ProfileSkillsEditResource profileSkillsEditResource) { return putWithRestResult(format("%s/id/%s/update-profile-skills", profileRestURL, userId), profileSkillsEditResource, Void.class); } @Override RestResult<ProfileSkillsResource> getProfileSkills(Long userId); @Override RestResult<Void> updateProfileSkills(Long userId, ProfileSkillsEditResource profileSkillsEditResource); @Override RestResult<ProfileAgreementResource> getProfileAgreement(Long userId); @Override RestResult<Void> updateProfileAgreement(Long userId); @Override RestResult<UserProfileResource> getUserProfile(Long userId); @Override RestResult<Void> updateUserProfile(Long userId, UserProfileResource userProfile); @Override RestResult<UserProfileStatusResource> getUserProfileStatus(Long userId); }
@Test public void updateProfileSkills() { Long userId = 1L; ProfileSkillsEditResource profileSkillsEditResource = newProfileSkillsEditResource().build(); setupPutWithRestResultExpectations(format("%s/id/%s/update-profile-skills", profileUrl, userId), profileSkillsEditResource, OK); RestResult<Void> response = service.updateProfileSkills(userId, profileSkillsEditResource); assertTrue(response.isSuccess()); }
ProfileRestServiceImpl extends BaseRestService implements ProfileRestService { @Override public RestResult<ProfileAgreementResource> getProfileAgreement(Long userId) { return getWithRestResult(format("%s/id/%s/get-profile-agreement", profileRestURL, userId), ProfileAgreementResource.class); } @Override RestResult<ProfileSkillsResource> getProfileSkills(Long userId); @Override RestResult<Void> updateProfileSkills(Long userId, ProfileSkillsEditResource profileSkillsEditResource); @Override RestResult<ProfileAgreementResource> getProfileAgreement(Long userId); @Override RestResult<Void> updateProfileAgreement(Long userId); @Override RestResult<UserProfileResource> getUserProfile(Long userId); @Override RestResult<Void> updateUserProfile(Long userId, UserProfileResource userProfile); @Override RestResult<UserProfileStatusResource> getUserProfileStatus(Long userId); }
@Test public void getProfileAgreement() { Long userId = 1L; ProfileAgreementResource expected = newProfileAgreementResource().build(); setupGetWithRestResultExpectations(format("%s/id/%s/get-profile-agreement", profileUrl, userId), ProfileAgreementResource.class, expected, OK); ProfileAgreementResource response = service.getProfileAgreement(userId).getSuccess(); assertEquals(expected, response); }
ProfileRestServiceImpl extends BaseRestService implements ProfileRestService { @Override public RestResult<Void> updateProfileAgreement(Long userId) { return putWithRestResult(format("%s/id/%s/update-profile-agreement", profileRestURL, userId), Void.class); } @Override RestResult<ProfileSkillsResource> getProfileSkills(Long userId); @Override RestResult<Void> updateProfileSkills(Long userId, ProfileSkillsEditResource profileSkillsEditResource); @Override RestResult<ProfileAgreementResource> getProfileAgreement(Long userId); @Override RestResult<Void> updateProfileAgreement(Long userId); @Override RestResult<UserProfileResource> getUserProfile(Long userId); @Override RestResult<Void> updateUserProfile(Long userId, UserProfileResource userProfile); @Override RestResult<UserProfileStatusResource> getUserProfileStatus(Long userId); }
@Test public void updateProfileAgreement() { Long userId = 1L; setupPutWithRestResultExpectations(format("%s/id/%s/update-profile-agreement", profileUrl, userId), null, OK); RestResult<Void> response = service.updateProfileAgreement(userId); assertTrue(response.isSuccess()); }
ProfileRestServiceImpl extends BaseRestService implements ProfileRestService { @Override public RestResult<UserProfileResource> getUserProfile(Long userId) { return getWithRestResult(format("%s/id/%s/get-user-profile", profileRestURL, userId), UserProfileResource.class); } @Override RestResult<ProfileSkillsResource> getProfileSkills(Long userId); @Override RestResult<Void> updateProfileSkills(Long userId, ProfileSkillsEditResource profileSkillsEditResource); @Override RestResult<ProfileAgreementResource> getProfileAgreement(Long userId); @Override RestResult<Void> updateProfileAgreement(Long userId); @Override RestResult<UserProfileResource> getUserProfile(Long userId); @Override RestResult<Void> updateUserProfile(Long userId, UserProfileResource userProfile); @Override RestResult<UserProfileStatusResource> getUserProfileStatus(Long userId); }
@Test public void getProfileAddress() { Long userId = 1L; UserProfileResource expected = newUserProfileResource().build(); setupGetWithRestResultExpectations(format("%s/id/%s/get-user-profile", profileUrl, userId), UserProfileResource.class, expected, OK); UserProfileResource response = service.getUserProfile(userId).getSuccess(); assertEquals(expected, response); }
ProfileRestServiceImpl extends BaseRestService implements ProfileRestService { @Override public RestResult<Void> updateUserProfile(Long userId, UserProfileResource userProfile) { return putWithRestResult(format("%s/id/%s/update-user-profile", profileRestURL, userId), userProfile, Void.class); } @Override RestResult<ProfileSkillsResource> getProfileSkills(Long userId); @Override RestResult<Void> updateProfileSkills(Long userId, ProfileSkillsEditResource profileSkillsEditResource); @Override RestResult<ProfileAgreementResource> getProfileAgreement(Long userId); @Override RestResult<Void> updateProfileAgreement(Long userId); @Override RestResult<UserProfileResource> getUserProfile(Long userId); @Override RestResult<Void> updateUserProfile(Long userId, UserProfileResource userProfile); @Override RestResult<UserProfileStatusResource> getUserProfileStatus(Long userId); }
@Test public void updateProfileAddress() { Long userId = 1L; UserProfileResource profileDetails = newUserProfileResource().build(); setupPutWithRestResultExpectations(format("%s/id/%s/update-user-profile", profileUrl, userId), profileDetails, OK); RestResult<Void> response = service.updateUserProfile(userId, profileDetails); assertTrue(response.isSuccess()); }
ProfileRestServiceImpl extends BaseRestService implements ProfileRestService { @Override public RestResult<UserProfileStatusResource> getUserProfileStatus(Long userId) { return getWithRestResult(format("%s/id/%s/profile-status", profileRestURL, userId), UserProfileStatusResource.class); } @Override RestResult<ProfileSkillsResource> getProfileSkills(Long userId); @Override RestResult<Void> updateProfileSkills(Long userId, ProfileSkillsEditResource profileSkillsEditResource); @Override RestResult<ProfileAgreementResource> getProfileAgreement(Long userId); @Override RestResult<Void> updateProfileAgreement(Long userId); @Override RestResult<UserProfileResource> getUserProfile(Long userId); @Override RestResult<Void> updateUserProfile(Long userId, UserProfileResource userProfile); @Override RestResult<UserProfileStatusResource> getUserProfileStatus(Long userId); }
@Test public void getProfileStatus() { Long userId = 1L; UserProfileStatusResource expected = newUserProfileStatusResource().build(); setupGetWithRestResultExpectations(format("%s/id/%s/profile-status", profileUrl, userId), UserProfileStatusResource.class, expected, OK); UserProfileStatusResource response = service.getUserProfileStatus(userId).getSuccess(); assertEquals(expected, response); }
FileTypeRestServiceImpl extends BaseRestService implements FileTypeRestService { @Override public RestResult<FileTypeResource> findOne(long id) { return getWithRestResult(fileTypeRestURL + "/" + id, FileTypeResource.class); } @Override RestResult<FileTypeResource> findOne(long id); @Override RestResult<FileTypeResource> findByName(String name); }
@Test public void findOne() { long fileTypeId = 1L; FileTypeResource responseBody = new FileTypeResource(); setupGetWithRestResultExpectations(String.format("%s/%s", fileTypeRestURL, fileTypeId), FileTypeResource.class, responseBody); FileTypeResource response = service.findOne(fileTypeId).getSuccess(); assertNotNull(response); assertEquals(responseBody, response); setupGetWithRestResultVerifications(String.format("%s/%s", fileTypeRestURL, fileTypeId), null, FileTypeResource.class); }
FileTypeRestServiceImpl extends BaseRestService implements FileTypeRestService { @Override public RestResult<FileTypeResource> findByName(String name) { return getWithRestResult(fileTypeRestURL + "/find-by-name/" + name, FileTypeResource.class); } @Override RestResult<FileTypeResource> findOne(long id); @Override RestResult<FileTypeResource> findByName(String name); }
@Test public void findByName() { String name = "name"; FileTypeResource responseBody = new FileTypeResource(); setupGetWithRestResultExpectations(String.format("%s/find-by-name/%s", fileTypeRestURL, name), FileTypeResource.class, responseBody); FileTypeResource response = service.findByName(name).getSuccess(); assertNotNull(response); assertEquals(responseBody, response); setupGetWithRestResultVerifications(String.format("%s/find-by-name/%s", fileTypeRestURL, name), null, FileTypeResource.class); }
UserSurveyServiceImpl implements UserSurveyService { @Override public ServiceResult<Void> sendAssessorDiversitySurvey(User user) { return notificationService.sendNotificationWithFlush(surveyNotification(user, DIVERSITY_SURVEY_ASSESSOR), EMAIL); } @Override ServiceResult<Void> sendApplicantDiversitySurvey(User user); @Override ServiceResult<Void> sendAssessorDiversitySurvey(User user); }
@Test public void sendAssessorDiversitySurvey() throws Exception { User user = newUser() .withFirstName("Tom") .withLastName("Baldwin") .withEmailAddress("[email protected]") .build(); when(notificationServiceMock.sendNotificationWithFlush(expectedNotification(user, DIVERSITY_SURVEY_ASSESSOR), eq(NotificationMedium.EMAIL))).thenReturn(serviceSuccess()); service.sendAssessorDiversitySurvey(user).getSuccess(); InOrder inOrder = inOrder(notificationServiceMock); inOrder.verify(notificationServiceMock).sendNotificationWithFlush(expectedNotification(user, DIVERSITY_SURVEY_ASSESSOR), eq(NotificationMedium.EMAIL)); inOrder.verifyNoMoreInteractions(); }
FinanceReviewerRestServiceImpl extends BaseRestService implements FinanceReviewerRestService { @Override public RestResult<List<SimpleUserResource>> findFinanceUsers() { return getWithRestResult(format("%s/%s", FINANCE_REVIEWER_REST_URL, "find-all"), simpleUserListType()); } @Override RestResult<List<SimpleUserResource>> findFinanceUsers(); @Override RestResult<Void> assignFinanceReviewerToProject(long userId, long projectId); @Override RestResult<SimpleUserResource> findFinanceReviewerForProject(long projectId); }
@Test public void findFinanceUsers() { List<SimpleUserResource> expected = newSimpleUserResource().build(1); setupGetWithRestResultExpectations("/finance-reviewer/find-all", simpleUserListType(), expected, OK); RestResult<List<SimpleUserResource>> result = service.findFinanceUsers(); assertTrue(result.isSuccess()); assertEquals(result.getSuccess(), expected); }
FinanceReviewerRestServiceImpl extends BaseRestService implements FinanceReviewerRestService { @Override public RestResult<Void> assignFinanceReviewerToProject(long userId, long projectId) { return postWithRestResult(format("%s/%d/%s/%d", FINANCE_REVIEWER_REST_URL, userId, "assign", projectId)); } @Override RestResult<List<SimpleUserResource>> findFinanceUsers(); @Override RestResult<Void> assignFinanceReviewerToProject(long userId, long projectId); @Override RestResult<SimpleUserResource> findFinanceReviewerForProject(long projectId); }
@Test public void assignFinanceReviewerToProject() { long userId = 1L; long projectId = 2L; setupPostWithRestResultExpectations(String.format("/finance-reviewer/%d/assign/%d", userId, projectId), OK); RestResult<Void> result = service.assignFinanceReviewerToProject(userId, projectId); assertTrue(result.isSuccess()); }
FinanceReviewerRestServiceImpl extends BaseRestService implements FinanceReviewerRestService { @Override public RestResult<SimpleUserResource> findFinanceReviewerForProject(long projectId) { return getWithRestResult(String.format("%s?projectId=%d", FINANCE_REVIEWER_REST_URL, projectId), SimpleUserResource.class); } @Override RestResult<List<SimpleUserResource>> findFinanceUsers(); @Override RestResult<Void> assignFinanceReviewerToProject(long userId, long projectId); @Override RestResult<SimpleUserResource> findFinanceReviewerForProject(long projectId); }
@Test public void findFinanceReviewerForProject() { long projectId = 2L; SimpleUserResource expected = newSimpleUserResource().build(); setupGetWithRestResultExpectations("/finance-reviewer?projectId=" + projectId, SimpleUserResource.class, expected, OK); RestResult<SimpleUserResource> result = service.findFinanceReviewerForProject(projectId); assertTrue(result.isSuccess()); assertEquals(result.getSuccess(), expected); }
StatusRestServiceImpl extends BaseRestService implements StatusRestService { @Override public RestResult<ProjectStatusPageResource> getCompetitionStatus(Long competitionId, String applicationSearchString, int page) { return getWithRestResult(COMPETITION_URL + "/" + competitionId + "?applicationSearchString=" + applicationSearchString + "&page=" + page, ProjectStatusPageResource.class); } @Override RestResult<ProjectStatusPageResource> getCompetitionStatus(Long competitionId, String applicationSearchString, int page); @Override RestResult<List<ProjectStatusResource>> getPreviousCompetitionStatus(Long competitionId); @Override RestResult<ProjectTeamStatusResource> getProjectTeamStatus(Long projectId, Optional<Long> filterByUserId); @Override RestResult<ProjectStatusResource> getProjectStatus(Long projectId); }
@Test public void getCompetitionStatus() { Long competitionId = 1L; String applicationSearchString = "12"; ProjectStatusPageResource returnedResponse = new ProjectStatusPageResource(); setupGetWithRestResultExpectations(competitionURL + "/" + competitionId + "?applicationSearchString=" + applicationSearchString + "&page=1", ProjectStatusPageResource.class, returnedResponse); RestResult<ProjectStatusPageResource> result = service.getCompetitionStatus(competitionId, applicationSearchString, 1); assertTrue(result.isSuccess()); assertEquals(returnedResponse, result.getSuccess()); }
StatusRestServiceImpl extends BaseRestService implements StatusRestService { @Override public RestResult<List<ProjectStatusResource>> getPreviousCompetitionStatus(Long competitionId) { return getWithRestResult(PREVIOUS_COMPETITION_URL + "/" + competitionId, projectStatusResourceListType()); } @Override RestResult<ProjectStatusPageResource> getCompetitionStatus(Long competitionId, String applicationSearchString, int page); @Override RestResult<List<ProjectStatusResource>> getPreviousCompetitionStatus(Long competitionId); @Override RestResult<ProjectTeamStatusResource> getProjectTeamStatus(Long projectId, Optional<Long> filterByUserId); @Override RestResult<ProjectStatusResource> getProjectStatus(Long projectId); }
@Test public void getPreviousCompetitionStatus() { Long competitionId = 1L; List<ProjectStatusResource> returnedResponse = asList(new ProjectStatusResource()); setupGetWithRestResultExpectations("/project/previous/competition/" + competitionId, projectStatusResourceListType(), returnedResponse); RestResult<List<ProjectStatusResource>> result = service.getPreviousCompetitionStatus(competitionId); assertTrue(result.isSuccess()); assertEquals(returnedResponse, result.getSuccess()); }
StatusRestServiceImpl extends BaseRestService implements StatusRestService { @Override public RestResult<ProjectStatusResource> getProjectStatus(Long projectId) { return getWithRestResult(PROJECT_REST_URL + "/" + projectId + "/status", ProjectStatusResource.class); } @Override RestResult<ProjectStatusPageResource> getCompetitionStatus(Long competitionId, String applicationSearchString, int page); @Override RestResult<List<ProjectStatusResource>> getPreviousCompetitionStatus(Long competitionId); @Override RestResult<ProjectTeamStatusResource> getProjectTeamStatus(Long projectId, Optional<Long> filterByUserId); @Override RestResult<ProjectStatusResource> getProjectStatus(Long projectId); }
@Test public void getStatusByProjectId() { ProjectStatusResource returnedResponse = new ProjectStatusResource(); setupGetWithRestResultExpectations(projectRestURL + "/123/status", ProjectStatusResource.class, returnedResponse); ProjectStatusResource result = service.getProjectStatus(123L).getSuccess(); assertEquals(returnedResponse, result); setupGetWithRestResultVerifications(projectRestURL + "/123/status", null, ProjectStatusResource.class); }
StatusRestServiceImpl extends BaseRestService implements StatusRestService { @Override public RestResult<ProjectTeamStatusResource> getProjectTeamStatus(Long projectId, Optional<Long> filterByUserId){ return filterByUserId. map(userId -> getWithRestResult(PROJECT_REST_URL + "/" + projectId + "/team-status?filterByUserId=" + userId, ProjectTeamStatusResource.class)) .orElseGet(() -> getWithRestResult(PROJECT_REST_URL + "/" + projectId + "/team-status", ProjectTeamStatusResource.class)); } @Override RestResult<ProjectStatusPageResource> getCompetitionStatus(Long competitionId, String applicationSearchString, int page); @Override RestResult<List<ProjectStatusResource>> getPreviousCompetitionStatus(Long competitionId); @Override RestResult<ProjectTeamStatusResource> getProjectTeamStatus(Long projectId, Optional<Long> filterByUserId); @Override RestResult<ProjectStatusResource> getProjectStatus(Long projectId); }
@Test public void getProjectTeamStatus() { String expectedUrl = projectRestURL + "/123/team-status"; setupGetWithRestResultExpectations(expectedUrl, ProjectTeamStatusResource.class, null, OK); RestResult<ProjectTeamStatusResource> result = service.getProjectTeamStatus(123L, Optional.empty()); assertTrue(result.isSuccess()); setupGetWithRestResultVerifications(projectRestURL + "/123/team-status", null, ProjectTeamStatusResource.class); } @Test public void getProjectTeamStatusWithFilterByUserId() { String expectedUrl = projectRestURL + "/123/team-status?filterByUserId=456"; setupGetWithRestResultExpectations(expectedUrl, ProjectTeamStatusResource.class, null, OK); RestResult<ProjectTeamStatusResource> result = service.getProjectTeamStatus(123L, Optional.of(456L)); assertTrue(result.isSuccess()); setupGetWithRestResultVerifications(projectRestURL + "/123/team-status?filterByUserId=456", null, ProjectTeamStatusResource.class); }
ProjectTeamRestServiceImpl extends BaseRestService implements ProjectTeamRestService { @Override public RestResult<Void> inviteProjectMember(long projectId, ProjectUserInviteResource inviteResource) { return postWithRestResult(format(projectTeamRestURL, projectId, "invite"), inviteResource, Void.class); } @Override RestResult<Void> inviteProjectMember(long projectId, ProjectUserInviteResource inviteResource); @Override RestResult<Void> removeUser(long projectId, long userId); @Override RestResult<Void> removeInvite(long projectId, long inviteId); }
@Test public void inviteProjectMember() { long projectId = 1L; ProjectUserInviteResource projectUserInviteResource = newProjectUserInviteResource().build(); setupPostWithRestResultExpectations(format("/project/%d/team/invite", projectId), projectUserInviteResource, HttpStatus.OK); RestResult<Void> result = service.inviteProjectMember(projectId, projectUserInviteResource); assertTrue(result.isSuccess()); setupPostWithRestResulVerifications(format("/project/%d/team/invite", projectId), projectUserInviteResource); }
ProjectTeamRestServiceImpl extends BaseRestService implements ProjectTeamRestService { @Override public RestResult<Void> removeUser(long projectId, long userId) { return postWithRestResult(format(projectTeamRestURL + "/%d", projectId, "remove-user", userId)); } @Override RestResult<Void> inviteProjectMember(long projectId, ProjectUserInviteResource inviteResource); @Override RestResult<Void> removeUser(long projectId, long userId); @Override RestResult<Void> removeInvite(long projectId, long inviteId); }
@Test public void removeUser() { long projectId = 654L; long userId = 987L; setupPostWithRestResultExpectations(format("/project/%d/team/remove-user/%d", projectId, userId), null, OK); RestResult<Void> result = service.removeUser(projectId, userId); setupPostWithRestResultVerifications(format("/project/%d/team/remove-user/%d", projectId, userId), Void.class); assertTrue(result.isSuccess()); }
UsersRolesServiceImpl extends BaseTransactionalService implements UsersRolesService { @Override public ServiceResult<ProcessRoleResource> getProcessRoleById(long id) { return super.getProcessRole(id).andOnSuccessReturn(processRoleMapper::mapToResource); } @Override ServiceResult<ProcessRoleResource> getProcessRoleById(long id); @Override ServiceResult<List<ProcessRoleResource>> getProcessRolesByIds(Long[] ids); @Override ServiceResult<List<ProcessRoleResource>> getProcessRolesByApplicationId(long applicationId); @Override ServiceResult<ProcessRoleResource> getProcessRoleByUserIdAndApplicationId(long userId, long applicationId); @Override ServiceResult<List<ProcessRoleResource>> getProcessRolesByUserId(long userId); @Override ServiceResult<List<ProcessRoleResource>> getAssignableProcessRolesByApplicationId(long applicationId); @Override ServiceResult<Boolean> userHasApplicationForCompetition(long userId, long competitionId); }
@Test public void getProcessRoleById() { ProcessRole processRole = newProcessRole().build(); ProcessRoleResource processRoleResource = newProcessRoleResource().build(); when(processRoleRepositoryMock.findById(1L)).thenReturn(Optional.of(processRole)); when(processRoleMapperMock.mapToResource(same(processRole))).thenReturn(processRoleResource); ServiceResult<ProcessRoleResource> result = service.getProcessRoleById(1L); assertTrue(result.isSuccess()); assertEquals(processRoleResource, result.getSuccess()); verify(processRoleRepositoryMock, only()).findById(1L); }
ProjectTeamRestServiceImpl extends BaseRestService implements ProjectTeamRestService { @Override public RestResult<Void> removeInvite(long projectId, long inviteId) { return postWithRestResult(format(projectTeamRestURL + "/%d", projectId, "remove-invite", inviteId)); } @Override RestResult<Void> inviteProjectMember(long projectId, ProjectUserInviteResource inviteResource); @Override RestResult<Void> removeUser(long projectId, long userId); @Override RestResult<Void> removeInvite(long projectId, long inviteId); }
@Test public void removeInvite() { long projectId = 456L; long inviteId = 789L; setupPostWithRestResultExpectations( format("/project/%d/team/remove-invite/%d", projectId, inviteId), null, OK); RestResult<Void> result = service.removeInvite(projectId, inviteId); setupPostWithRestResultVerifications( format("/project/%d/team/remove-invite/%d", projectId, inviteId), Void.class); assertTrue(result.isSuccess()); }
PendingPartnerProgressRestServiceImpl extends BaseRestService implements PendingPartnerProgressRestService { @Override public RestResult<PendingPartnerProgressResource> getPendingPartnerProgress(long projectId, long organisationId) { return getWithRestResult(format(pendingPartnerProgressUrl, projectId, organisationId), PendingPartnerProgressResource.class); } @Override RestResult<PendingPartnerProgressResource> getPendingPartnerProgress(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationComplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingComplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsComplete(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationIncomplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingIncomplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsIncomplete(long projectId, long organisationId); @Override RestResult<Void> completePartnerSetup(long projectId, long organisationId); }
@Test public void getPendingPartnerProgress() { PendingPartnerProgressResource pendingPartnerProgressResource = new PendingPartnerProgressResource(); setupGetWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId), PendingPartnerProgressResource.class, pendingPartnerProgressResource, HttpStatus.OK); RestResult<PendingPartnerProgressResource> result = service.getPendingPartnerProgress(projectId, organisationId); assertTrue(result.isSuccess()); assertEquals(result.getSuccess(), pendingPartnerProgressResource); }
PendingPartnerProgressRestServiceImpl extends BaseRestService implements PendingPartnerProgressRestService { @Override public RestResult<Void> markYourOrganisationComplete(long projectId, long organisationId) { return postWithRestResult(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-organisation-complete"); } @Override RestResult<PendingPartnerProgressResource> getPendingPartnerProgress(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationComplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingComplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsComplete(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationIncomplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingIncomplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsIncomplete(long projectId, long organisationId); @Override RestResult<Void> completePartnerSetup(long projectId, long organisationId); }
@Test public void markYourOrganisationComplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-organisation-complete", HttpStatus.OK); RestResult<Void> result = service.markYourOrganisationComplete(projectId, organisationId); assertTrue(result.isSuccess()); }
PendingPartnerProgressRestServiceImpl extends BaseRestService implements PendingPartnerProgressRestService { @Override public RestResult<Void> markYourFundingComplete(long projectId, long organisationId) { return postWithRestResult(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-funding-complete"); } @Override RestResult<PendingPartnerProgressResource> getPendingPartnerProgress(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationComplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingComplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsComplete(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationIncomplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingIncomplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsIncomplete(long projectId, long organisationId); @Override RestResult<Void> completePartnerSetup(long projectId, long organisationId); }
@Test public void markYourFundingComplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-funding-complete", HttpStatus.OK); RestResult<Void> result = service.markYourFundingComplete(projectId, organisationId); assertTrue(result.isSuccess()); }
PendingPartnerProgressRestServiceImpl extends BaseRestService implements PendingPartnerProgressRestService { @Override public RestResult<Void> markTermsAndConditionsComplete(long projectId, long organisationId) { return postWithRestResult(format(pendingPartnerProgressUrl, projectId, organisationId) + "/terms-and-conditions-complete"); } @Override RestResult<PendingPartnerProgressResource> getPendingPartnerProgress(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationComplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingComplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsComplete(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationIncomplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingIncomplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsIncomplete(long projectId, long organisationId); @Override RestResult<Void> completePartnerSetup(long projectId, long organisationId); }
@Test public void markTermsAndConditionsComplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/terms-and-conditions-complete", HttpStatus.OK); RestResult<Void> result = service.markTermsAndConditionsComplete(projectId, organisationId); assertTrue(result.isSuccess()); }
PendingPartnerProgressRestServiceImpl extends BaseRestService implements PendingPartnerProgressRestService { @Override public RestResult<Void> markYourOrganisationIncomplete(long projectId, long organisationId) { return postWithRestResult(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-organisation-incomplete"); } @Override RestResult<PendingPartnerProgressResource> getPendingPartnerProgress(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationComplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingComplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsComplete(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationIncomplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingIncomplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsIncomplete(long projectId, long organisationId); @Override RestResult<Void> completePartnerSetup(long projectId, long organisationId); }
@Test public void markYourOrganisationIncomplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-organisation-incomplete", HttpStatus.OK); RestResult<Void> result = service.markYourOrganisationIncomplete(projectId, organisationId); assertTrue(result.isSuccess()); }
PendingPartnerProgressRestServiceImpl extends BaseRestService implements PendingPartnerProgressRestService { @Override public RestResult<Void> markYourFundingIncomplete(long projectId, long organisationId) { return postWithRestResult(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-funding-incomplete"); } @Override RestResult<PendingPartnerProgressResource> getPendingPartnerProgress(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationComplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingComplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsComplete(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationIncomplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingIncomplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsIncomplete(long projectId, long organisationId); @Override RestResult<Void> completePartnerSetup(long projectId, long organisationId); }
@Test public void markYourFundingIncomplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-funding-incomplete", HttpStatus.OK); RestResult<Void> result = service.markYourFundingIncomplete(projectId, organisationId); assertTrue(result.isSuccess()); }
PendingPartnerProgressRestServiceImpl extends BaseRestService implements PendingPartnerProgressRestService { @Override public RestResult<Void> markTermsAndConditionsIncomplete(long projectId, long organisationId) { return postWithRestResult(format(pendingPartnerProgressUrl, projectId, organisationId) + "/terms-and-conditions-incomplete"); } @Override RestResult<PendingPartnerProgressResource> getPendingPartnerProgress(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationComplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingComplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsComplete(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationIncomplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingIncomplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsIncomplete(long projectId, long organisationId); @Override RestResult<Void> completePartnerSetup(long projectId, long organisationId); }
@Test public void markTermsAndConditionsIncomplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/terms-and-conditions-incomplete", HttpStatus.OK); RestResult<Void> result = service.markTermsAndConditionsIncomplete(projectId, organisationId); assertTrue(result.isSuccess()); }
PendingPartnerProgressRestServiceImpl extends BaseRestService implements PendingPartnerProgressRestService { @Override public RestResult<Void> completePartnerSetup(long projectId, long organisationId) { return postWithRestResult(format(pendingPartnerProgressUrl, projectId, organisationId)); } @Override RestResult<PendingPartnerProgressResource> getPendingPartnerProgress(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationComplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingComplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsComplete(long projectId, long organisationId); @Override RestResult<Void> markYourOrganisationIncomplete(long projectId, long organisationId); @Override RestResult<Void> markYourFundingIncomplete(long projectId, long organisationId); @Override RestResult<Void> markTermsAndConditionsIncomplete(long projectId, long organisationId); @Override RestResult<Void> completePartnerSetup(long projectId, long organisationId); }
@Test public void completePartnerSetup() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId), HttpStatus.OK); RestResult<Void> result = service.completePartnerSetup(projectId, organisationId); assertTrue(result.isSuccess()); }
ProjectRestServiceImpl extends BaseRestService implements ProjectRestService { @Override public RestResult<ProjectResource> getProjectById(long projectId) { return getWithRestResult(format(PROJECT_REST_URL + "%d", projectId), ProjectResource.class); } @Override RestResult<ProjectResource> getProjectById(long projectId); RestResult<List<ProjectResource>> findByUserId(long userId); @Override RestResult<List<ProjectUserResource>> getProjectUsersForProject(long projectId); @Override RestResult<List<ProjectUserResource>> getDisplayProjectUsersForProject(long projectId); @Override RestResult<ProjectResource> getByApplicationId(long applicationId); @Override RestResult<OrganisationResource> getOrganisationByProjectAndUser(long projectId, long userId); @Override RestResult<ProjectUserResource> getProjectManager(long projectId); @Override RestResult<List<ProjectUserResource>> getProjectFinanceContacts(long projectId); @Override RestResult<ProjectResource> createProjectFromApplicationId(long applicationId); @Override RestResult<OrganisationResource> getLeadOrganisationByProject(long projectId); @Override RestResult<Boolean> existsOnApplication(long projectId, long organisationId); }
@Test public void getProjectById() { ProjectResource returnedResponse = newProjectResource().build(); setupGetWithRestResultExpectations(format(PROJECT_REST_URL + "/%d", returnedResponse.getId()), ProjectResource.class, returnedResponse); ProjectResource result = service.getProjectById(returnedResponse.getId()).getSuccess(); assertEquals(returnedResponse, result); }
UsersRolesServiceImpl extends BaseTransactionalService implements UsersRolesService { @Override public ServiceResult<List<ProcessRoleResource>> getProcessRolesByIds(Long[] ids) { List<Long> processRoleIds = asList(ids); return serviceSuccess(processRolesToResources(processRoleRepository.findAllById(processRoleIds))); } @Override ServiceResult<ProcessRoleResource> getProcessRoleById(long id); @Override ServiceResult<List<ProcessRoleResource>> getProcessRolesByIds(Long[] ids); @Override ServiceResult<List<ProcessRoleResource>> getProcessRolesByApplicationId(long applicationId); @Override ServiceResult<ProcessRoleResource> getProcessRoleByUserIdAndApplicationId(long userId, long applicationId); @Override ServiceResult<List<ProcessRoleResource>> getProcessRolesByUserId(long userId); @Override ServiceResult<List<ProcessRoleResource>> getAssignableProcessRolesByApplicationId(long applicationId); @Override ServiceResult<Boolean> userHasApplicationForCompetition(long userId, long competitionId); }
@Test public void getProcessRolesByIds() { List<ProcessRole> processRoles = newProcessRole().build(2); List<ProcessRoleResource> processRoleResources = newProcessRoleResource().build(2); List<Long> processRoleIds = asList(new Long[]{1L, 2L}); when(processRoleRepositoryMock.findAllById(processRoleIds)).thenReturn(processRoles); zip(processRoles, processRoleResources, (pr, prr) -> when(processRoleMapperMock.mapToResource(same(pr))).thenReturn(prr)); ServiceResult<List<ProcessRoleResource>> result = service.getProcessRolesByIds(new Long[]{1L, 2L}); assertTrue(result.isSuccess()); assertEquals(processRoleResources, result.getSuccess()); verify(processRoleRepositoryMock, only()).findAllById(processRoleIds); }
ProjectRestServiceImpl extends BaseRestService implements ProjectRestService { @Override public RestResult<List<ProjectUserResource>> getProjectUsersForProject(long projectId) { return getWithRestResult(format(PROJECT_REST_URL + "%d/project-users", projectId), projectUserResourceList()); } @Override RestResult<ProjectResource> getProjectById(long projectId); RestResult<List<ProjectResource>> findByUserId(long userId); @Override RestResult<List<ProjectUserResource>> getProjectUsersForProject(long projectId); @Override RestResult<List<ProjectUserResource>> getDisplayProjectUsersForProject(long projectId); @Override RestResult<ProjectResource> getByApplicationId(long applicationId); @Override RestResult<OrganisationResource> getOrganisationByProjectAndUser(long projectId, long userId); @Override RestResult<ProjectUserResource> getProjectManager(long projectId); @Override RestResult<List<ProjectUserResource>> getProjectFinanceContacts(long projectId); @Override RestResult<ProjectResource> createProjectFromApplicationId(long applicationId); @Override RestResult<OrganisationResource> getLeadOrganisationByProject(long projectId); @Override RestResult<Boolean> existsOnApplication(long projectId, long organisationId); }
@Test public void getProjectUsers() { long projectId = 11L; List<ProjectUserResource> users = newProjectUserResource().build(3); setupGetWithRestResultExpectations(format(PROJECT_REST_URL + "/%d/project-users", projectId), projectUserResourceList(), users); RestResult<List<ProjectUserResource>> result = service.getProjectUsersForProject(projectId); assertEquals(users, result.getSuccess()); }
ProjectRestServiceImpl extends BaseRestService implements ProjectRestService { public RestResult<List<ProjectResource>> findByUserId(long userId) { return getWithRestResult(format(PROJECT_REST_URL + "user/%d", userId), projectResourceListType()); } @Override RestResult<ProjectResource> getProjectById(long projectId); RestResult<List<ProjectResource>> findByUserId(long userId); @Override RestResult<List<ProjectUserResource>> getProjectUsersForProject(long projectId); @Override RestResult<List<ProjectUserResource>> getDisplayProjectUsersForProject(long projectId); @Override RestResult<ProjectResource> getByApplicationId(long applicationId); @Override RestResult<OrganisationResource> getOrganisationByProjectAndUser(long projectId, long userId); @Override RestResult<ProjectUserResource> getProjectManager(long projectId); @Override RestResult<List<ProjectUserResource>> getProjectFinanceContacts(long projectId); @Override RestResult<ProjectResource> createProjectFromApplicationId(long applicationId); @Override RestResult<OrganisationResource> getLeadOrganisationByProject(long projectId); @Override RestResult<Boolean> existsOnApplication(long projectId, long organisationId); }
@Test public void findByUserId() { long userId = 7L; List<ProjectResource> projects = Stream.of(1,2,3).map(i -> new ProjectResource()).collect(toList()); setupGetWithRestResultExpectations(format(PROJECT_REST_URL + "/user/%d", userId), projectResourceListType(), projects); List<ProjectResource> result = service.findByUserId(userId).getSuccess(); assertEquals(projects, result); }
ProjectRestServiceImpl extends BaseRestService implements ProjectRestService { @Override public RestResult<ProjectResource> getByApplicationId(long applicationId) { return getWithRestResult(format(PROJECT_REST_URL + "application/%d", applicationId), ProjectResource.class); } @Override RestResult<ProjectResource> getProjectById(long projectId); RestResult<List<ProjectResource>> findByUserId(long userId); @Override RestResult<List<ProjectUserResource>> getProjectUsersForProject(long projectId); @Override RestResult<List<ProjectUserResource>> getDisplayProjectUsersForProject(long projectId); @Override RestResult<ProjectResource> getByApplicationId(long applicationId); @Override RestResult<OrganisationResource> getOrganisationByProjectAndUser(long projectId, long userId); @Override RestResult<ProjectUserResource> getProjectManager(long projectId); @Override RestResult<List<ProjectUserResource>> getProjectFinanceContacts(long projectId); @Override RestResult<ProjectResource> createProjectFromApplicationId(long applicationId); @Override RestResult<OrganisationResource> getLeadOrganisationByProject(long projectId); @Override RestResult<Boolean> existsOnApplication(long projectId, long organisationId); }
@Test public void getByApplicationId() { ProjectResource projectResource = newProjectResource().build(); setupGetWithRestResultExpectations(format(PROJECT_REST_URL + "/application/%d", projectResource.getId()), ProjectResource.class, projectResource); ProjectResource result = service.getByApplicationId(projectResource.getId()).getSuccess(); assertEquals(projectResource, result); }
ProjectRestServiceImpl extends BaseRestService implements ProjectRestService { @Override public RestResult<ProjectUserResource> getProjectManager(long projectId) { return getWithRestResult(format(PROJECT_REST_URL + "%d/project-manager", projectId), ProjectUserResource.class); } @Override RestResult<ProjectResource> getProjectById(long projectId); RestResult<List<ProjectResource>> findByUserId(long userId); @Override RestResult<List<ProjectUserResource>> getProjectUsersForProject(long projectId); @Override RestResult<List<ProjectUserResource>> getDisplayProjectUsersForProject(long projectId); @Override RestResult<ProjectResource> getByApplicationId(long applicationId); @Override RestResult<OrganisationResource> getOrganisationByProjectAndUser(long projectId, long userId); @Override RestResult<ProjectUserResource> getProjectManager(long projectId); @Override RestResult<List<ProjectUserResource>> getProjectFinanceContacts(long projectId); @Override RestResult<ProjectResource> createProjectFromApplicationId(long applicationId); @Override RestResult<OrganisationResource> getLeadOrganisationByProject(long projectId); @Override RestResult<Boolean> existsOnApplication(long projectId, long organisationId); }
@Test public void getProjectManager() { long projectId = 23; ProjectUserResource returnedResponse = newProjectUserResource().withProject(projectId).build(); setupGetWithRestResultExpectations(format(PROJECT_REST_URL + "/%d/project-manager", projectId), ProjectUserResource.class, returnedResponse); ProjectUserResource result = service.getProjectManager(projectId).getSuccess(); assertEquals(returnedResponse, result); } @Test public void getProjectManager_notFound() { long projectId = 13; setupGetWithRestResultExpectations(format(PROJECT_REST_URL + "/%d/project-manager", projectId), ProjectUserResource.class, null, NOT_FOUND); Optional<ProjectUserResource> result = service.getProjectManager(projectId).toOptionalIfNotFound().getSuccess(); assertFalse(result.isPresent()); }
ProjectRestServiceImpl extends BaseRestService implements ProjectRestService { @Override public RestResult<List<ProjectUserResource>> getProjectFinanceContacts(long projectId) { return getWithRestResult(format(PROJECT_REST_URL + "%d/project-finance-contacts", projectId), projectUserResourceList()); } @Override RestResult<ProjectResource> getProjectById(long projectId); RestResult<List<ProjectResource>> findByUserId(long userId); @Override RestResult<List<ProjectUserResource>> getProjectUsersForProject(long projectId); @Override RestResult<List<ProjectUserResource>> getDisplayProjectUsersForProject(long projectId); @Override RestResult<ProjectResource> getByApplicationId(long applicationId); @Override RestResult<OrganisationResource> getOrganisationByProjectAndUser(long projectId, long userId); @Override RestResult<ProjectUserResource> getProjectManager(long projectId); @Override RestResult<List<ProjectUserResource>> getProjectFinanceContacts(long projectId); @Override RestResult<ProjectResource> createProjectFromApplicationId(long applicationId); @Override RestResult<OrganisationResource> getLeadOrganisationByProject(long projectId); @Override RestResult<Boolean> existsOnApplication(long projectId, long organisationId); }
@Test public void getProjectFinanceContacts() { long projectId = 23; List<ProjectUserResource> returnedResponse = newProjectUserResource().withProject(projectId).build(3); setupGetWithRestResultExpectations(format(PROJECT_REST_URL + "/%d/project-finance-contacts", projectId), projectUserResourceList(), returnedResponse); List<ProjectUserResource> result = service.getProjectFinanceContacts(projectId).getSuccess(); assertEquals(returnedResponse, result); } @Test public void getProjectFinanceContacts_emptyResults() { long projectId = 13; setupGetWithRestResultExpectations(format(PROJECT_REST_URL + "/%d/project-finance-contacts", projectId), projectUserResourceList(), Collections.emptyList()); List<ProjectUserResource> result = service.getProjectFinanceContacts(projectId).getSuccess(); assertEquals(Collections.emptyList(), result); }
ProjectRestServiceImpl extends BaseRestService implements ProjectRestService { @Override public RestResult<ProjectResource> createProjectFromApplicationId(long applicationId) { return postWithRestResult(format(PROJECT_REST_URL + "create-project/application/%d", applicationId), ProjectResource.class); } @Override RestResult<ProjectResource> getProjectById(long projectId); RestResult<List<ProjectResource>> findByUserId(long userId); @Override RestResult<List<ProjectUserResource>> getProjectUsersForProject(long projectId); @Override RestResult<List<ProjectUserResource>> getDisplayProjectUsersForProject(long projectId); @Override RestResult<ProjectResource> getByApplicationId(long applicationId); @Override RestResult<OrganisationResource> getOrganisationByProjectAndUser(long projectId, long userId); @Override RestResult<ProjectUserResource> getProjectManager(long projectId); @Override RestResult<List<ProjectUserResource>> getProjectFinanceContacts(long projectId); @Override RestResult<ProjectResource> createProjectFromApplicationId(long applicationId); @Override RestResult<OrganisationResource> getLeadOrganisationByProject(long projectId); @Override RestResult<Boolean> existsOnApplication(long projectId, long organisationId); }
@Test public void createProjectFromApplicationId() { ProjectResource projectResource = newProjectResource().build(); setupPostWithRestResultExpectations(format(PROJECT_REST_URL + "/create-project/application/%d", projectResource.getId()), ProjectResource.class, null, projectResource, OK); RestResult<ProjectResource> result = service.createProjectFromApplicationId(projectResource.getId()); assertTrue(result.isSuccess()); setupPostWithRestResultVerifications(format(PROJECT_REST_URL + "/create-project/application/%d", projectResource.getId()), ProjectResource.class); }
ProjectRestServiceImpl extends BaseRestService implements ProjectRestService { @Override public RestResult<OrganisationResource> getLeadOrganisationByProject(long projectId) { return getWithRestResult(format(PROJECT_REST_URL + "%d/lead-organisation", projectId), OrganisationResource.class); } @Override RestResult<ProjectResource> getProjectById(long projectId); RestResult<List<ProjectResource>> findByUserId(long userId); @Override RestResult<List<ProjectUserResource>> getProjectUsersForProject(long projectId); @Override RestResult<List<ProjectUserResource>> getDisplayProjectUsersForProject(long projectId); @Override RestResult<ProjectResource> getByApplicationId(long applicationId); @Override RestResult<OrganisationResource> getOrganisationByProjectAndUser(long projectId, long userId); @Override RestResult<ProjectUserResource> getProjectManager(long projectId); @Override RestResult<List<ProjectUserResource>> getProjectFinanceContacts(long projectId); @Override RestResult<ProjectResource> createProjectFromApplicationId(long applicationId); @Override RestResult<OrganisationResource> getLeadOrganisationByProject(long projectId); @Override RestResult<Boolean> existsOnApplication(long projectId, long organisationId); }
@Test public void getLeadOrganisationByProject() { long projectId = 17; OrganisationResource organisation = newOrganisationResource().build(); setupGetWithRestResultExpectations(format(PROJECT_REST_URL + "/%d/lead-organisation", projectId), OrganisationResource.class, organisation); OrganisationResource result = service.getLeadOrganisationByProject(projectId).getSuccess(); assertEquals(organisation, result); }
ProjectStateRestServiceImpl extends BaseRestService implements ProjectStateRestService { @Override public RestResult<Void> withdrawProject(long projectId) { return postWithRestResult(projectRestURL + "/" + projectId + "/withdraw"); } @Override RestResult<Void> withdrawProject(long projectId); @Override RestResult<Void> handleProjectOffline(long projectId); @Override RestResult<Void> completeProjectOffline(long projectId); @Override RestResult<Void> putProjectOnHold(long projectId, OnHoldReasonResource reason); @Override RestResult<Void> resumeProject(long projectId); @Override RestResult<Void> markAsSuccessful(long projectId); @Override RestResult<Void> markAsUnsuccessful(long projectId); @Override RestResult<ProjectStateCommentsResource> findOpenComments(long projectId); @Override RestResult<Void> addPost(PostResource post, long projectId, long threadId); }
@Test public void withdrawProject() { long projectId = 123L; setupPostWithRestResultExpectations(projectRestURL + "/" + projectId + "/withdraw", null, OK ); RestResult<Void> result = service.withdrawProject(projectId); setupPostWithRestResultVerifications(projectRestURL + "/" + projectId + "/withdraw", Void.class); assertTrue(result.isSuccess()); }
UsersRolesServiceImpl extends BaseTransactionalService implements UsersRolesService { @Override public ServiceResult<List<ProcessRoleResource>> getProcessRolesByApplicationId(long applicationId) { return serviceSuccess(processRolesToResources(processRoleRepository.findByApplicationId(applicationId))); } @Override ServiceResult<ProcessRoleResource> getProcessRoleById(long id); @Override ServiceResult<List<ProcessRoleResource>> getProcessRolesByIds(Long[] ids); @Override ServiceResult<List<ProcessRoleResource>> getProcessRolesByApplicationId(long applicationId); @Override ServiceResult<ProcessRoleResource> getProcessRoleByUserIdAndApplicationId(long userId, long applicationId); @Override ServiceResult<List<ProcessRoleResource>> getProcessRolesByUserId(long userId); @Override ServiceResult<List<ProcessRoleResource>> getAssignableProcessRolesByApplicationId(long applicationId); @Override ServiceResult<Boolean> userHasApplicationForCompetition(long userId, long competitionId); }
@Test public void getProcessRolesByApplicationId() { List<ProcessRole> processRoles = newProcessRole().build(2); List<ProcessRoleResource> processRoleResources = newProcessRoleResource().build(2); when(processRoleRepositoryMock.findByApplicationId(1L)).thenReturn(processRoles); zip(processRoles, processRoleResources, (pr, prr) -> when(processRoleMapperMock.mapToResource(same(pr))).thenReturn(prr)); ServiceResult<List<ProcessRoleResource>> result = service.getProcessRolesByApplicationId(1L); assertTrue(result.isSuccess()); assertEquals(processRoleResources, result.getSuccess()); verify(processRoleRepositoryMock, only()).findByApplicationId(1L); }
ProjectStateRestServiceImpl extends BaseRestService implements ProjectStateRestService { @Override public RestResult<Void> handleProjectOffline(long projectId) { return postWithRestResult(projectRestURL + "/" + projectId + "/handle-offline"); } @Override RestResult<Void> withdrawProject(long projectId); @Override RestResult<Void> handleProjectOffline(long projectId); @Override RestResult<Void> completeProjectOffline(long projectId); @Override RestResult<Void> putProjectOnHold(long projectId, OnHoldReasonResource reason); @Override RestResult<Void> resumeProject(long projectId); @Override RestResult<Void> markAsSuccessful(long projectId); @Override RestResult<Void> markAsUnsuccessful(long projectId); @Override RestResult<ProjectStateCommentsResource> findOpenComments(long projectId); @Override RestResult<Void> addPost(PostResource post, long projectId, long threadId); }
@Test public void handleProjectOffline() { long projectId = 123L; setupPostWithRestResultExpectations(projectRestURL + "/" + projectId + "/handle-offline", null, OK ); RestResult<Void> result = service.handleProjectOffline(projectId); setupPostWithRestResultVerifications(projectRestURL + "/" + projectId + "/handle-offline", Void.class); assertTrue(result.isSuccess()); }
ProjectStateRestServiceImpl extends BaseRestService implements ProjectStateRestService { @Override public RestResult<Void> completeProjectOffline(long projectId) { return postWithRestResult(projectRestURL + "/" + projectId + "/complete-offline"); } @Override RestResult<Void> withdrawProject(long projectId); @Override RestResult<Void> handleProjectOffline(long projectId); @Override RestResult<Void> completeProjectOffline(long projectId); @Override RestResult<Void> putProjectOnHold(long projectId, OnHoldReasonResource reason); @Override RestResult<Void> resumeProject(long projectId); @Override RestResult<Void> markAsSuccessful(long projectId); @Override RestResult<Void> markAsUnsuccessful(long projectId); @Override RestResult<ProjectStateCommentsResource> findOpenComments(long projectId); @Override RestResult<Void> addPost(PostResource post, long projectId, long threadId); }
@Test public void completeProjectOffline() { long projectId = 123L; setupPostWithRestResultExpectations(projectRestURL + "/" + projectId + "/complete-offline", null, OK ); RestResult<Void> result = service.completeProjectOffline(projectId); setupPostWithRestResultVerifications(projectRestURL + "/" + projectId + "/complete-offline", Void.class); assertTrue(result.isSuccess()); }
ProjectStateRestServiceImpl extends BaseRestService implements ProjectStateRestService { @Override public RestResult<Void> putProjectOnHold(long projectId, OnHoldReasonResource reason) { return postWithRestResult(projectRestURL + "/" + projectId + "/on-hold", reason, Void.class); } @Override RestResult<Void> withdrawProject(long projectId); @Override RestResult<Void> handleProjectOffline(long projectId); @Override RestResult<Void> completeProjectOffline(long projectId); @Override RestResult<Void> putProjectOnHold(long projectId, OnHoldReasonResource reason); @Override RestResult<Void> resumeProject(long projectId); @Override RestResult<Void> markAsSuccessful(long projectId); @Override RestResult<Void> markAsUnsuccessful(long projectId); @Override RestResult<ProjectStateCommentsResource> findOpenComments(long projectId); @Override RestResult<Void> addPost(PostResource post, long projectId, long threadId); }
@Test public void putProjectOnHold() { long projectId = 123L; OnHoldReasonResource onHoldReasonResource = new OnHoldReasonResource("something", "else"); setupPostWithRestResultExpectations(projectRestURL + "/" + projectId + "/on-hold", onHoldReasonResource, OK ); RestResult<Void> result = service.putProjectOnHold(projectId, onHoldReasonResource); setupPostWithRestResultVerifications(projectRestURL + "/" + projectId + "/on-hold", Void.class, onHoldReasonResource); assertTrue(result.isSuccess()); }
ProjectStateRestServiceImpl extends BaseRestService implements ProjectStateRestService { @Override public RestResult<Void> resumeProject(long projectId) { return postWithRestResult(projectRestURL + "/" + projectId + "/resume"); } @Override RestResult<Void> withdrawProject(long projectId); @Override RestResult<Void> handleProjectOffline(long projectId); @Override RestResult<Void> completeProjectOffline(long projectId); @Override RestResult<Void> putProjectOnHold(long projectId, OnHoldReasonResource reason); @Override RestResult<Void> resumeProject(long projectId); @Override RestResult<Void> markAsSuccessful(long projectId); @Override RestResult<Void> markAsUnsuccessful(long projectId); @Override RestResult<ProjectStateCommentsResource> findOpenComments(long projectId); @Override RestResult<Void> addPost(PostResource post, long projectId, long threadId); }
@Test public void resumeProject() { long projectId = 123L; setupPostWithRestResultExpectations(projectRestURL + "/" + projectId + "/resume", null, OK ); RestResult<Void> result = service.resumeProject(projectId); setupPostWithRestResultVerifications(projectRestURL + "/" + projectId + "/resume", Void.class); assertTrue(result.isSuccess()); }
ProjectStateRestServiceImpl extends BaseRestService implements ProjectStateRestService { @Override public RestResult<Void> markAsSuccessful(long projectId) { return postWithRestResult(projectRestURL + "/" + projectId + "/successful"); } @Override RestResult<Void> withdrawProject(long projectId); @Override RestResult<Void> handleProjectOffline(long projectId); @Override RestResult<Void> completeProjectOffline(long projectId); @Override RestResult<Void> putProjectOnHold(long projectId, OnHoldReasonResource reason); @Override RestResult<Void> resumeProject(long projectId); @Override RestResult<Void> markAsSuccessful(long projectId); @Override RestResult<Void> markAsUnsuccessful(long projectId); @Override RestResult<ProjectStateCommentsResource> findOpenComments(long projectId); @Override RestResult<Void> addPost(PostResource post, long projectId, long threadId); }
@Test public void markAsSuccessful() { long projectId = 123L; setupPostWithRestResultExpectations(projectRestURL + "/" + projectId + "/successful", null, OK ); RestResult<Void> result = service.markAsSuccessful(projectId); setupPostWithRestResultVerifications(projectRestURL + "/" + projectId + "/successful", Void.class); assertTrue(result.isSuccess()); }
ProjectStateRestServiceImpl extends BaseRestService implements ProjectStateRestService { @Override public RestResult<Void> markAsUnsuccessful(long projectId) { return postWithRestResult(projectRestURL + "/" + projectId + "/unsuccessful"); } @Override RestResult<Void> withdrawProject(long projectId); @Override RestResult<Void> handleProjectOffline(long projectId); @Override RestResult<Void> completeProjectOffline(long projectId); @Override RestResult<Void> putProjectOnHold(long projectId, OnHoldReasonResource reason); @Override RestResult<Void> resumeProject(long projectId); @Override RestResult<Void> markAsSuccessful(long projectId); @Override RestResult<Void> markAsUnsuccessful(long projectId); @Override RestResult<ProjectStateCommentsResource> findOpenComments(long projectId); @Override RestResult<Void> addPost(PostResource post, long projectId, long threadId); }
@Test public void markAsUnsuccessful() { long projectId = 123L; setupPostWithRestResultExpectations(projectRestURL + "/" + projectId + "/unsuccessful", null, OK ); RestResult<Void> result = service.markAsUnsuccessful(projectId); setupPostWithRestResultVerifications(projectRestURL + "/" + projectId + "/unsuccessful", Void.class); assertTrue(result.isSuccess()); }