method2testcases
stringlengths 118
3.08k
|
---|
### Question:
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<List<SectionResource>> getSectionsByCompetitionIdAndType(Long competitionId, SectionType type) { return getWithRestResult(sectionRestURL + "/get-sections-by-competition-id-and-type/" + competitionId + "/" + type.name(), sectionResourceListType()); } @Override RestResult<SectionResource> getById(Long sectionId); @Override RestResult<List<SectionResource>> getChildSectionsByParentId(long parentId); @Override RestResult<List<SectionResource>> getByCompetition(final Long competitionId); @Override RestResult<SectionResource> getSectionByQuestionId(Long questionId); @Override RestResult<Set<Long>> getQuestionsForSectionAndSubsections(Long sectionId); @Override RestResult<List<SectionResource>> getSectionsByCompetitionIdAndType(Long competitionId, SectionType type); @Override RestResult<List<SectionResource>> getByCompetitionIdVisibleForAssessment(Long competitionId); }### Answer:
@Test public void getSectionsForCompetitionByType() { String expectedUrl = sectionRestUrl + "/get-sections-by-competition-id-and-type/123/FINANCE"; List<SectionResource> returnedResponse = singletonList(new SectionResource()); setupGetWithRestResultExpectations(expectedUrl, sectionResourceListType(), returnedResponse); List<SectionResource> response = service.getSectionsByCompetitionIdAndType(123L, SectionType.FINANCE).getSuccess(); assertEquals(returnedResponse, response); } |
### Question:
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<List<SectionResource>> getByCompetitionIdVisibleForAssessment(Long competitionId) { return getWithRestResult(sectionRestURL + "/get-by-competition-id-visible-for-assessment/" + competitionId, sectionResourceListType()); } @Override RestResult<SectionResource> getById(Long sectionId); @Override RestResult<List<SectionResource>> getChildSectionsByParentId(long parentId); @Override RestResult<List<SectionResource>> getByCompetition(final Long competitionId); @Override RestResult<SectionResource> getSectionByQuestionId(Long questionId); @Override RestResult<Set<Long>> getQuestionsForSectionAndSubsections(Long sectionId); @Override RestResult<List<SectionResource>> getSectionsByCompetitionIdAndType(Long competitionId, SectionType type); @Override RestResult<List<SectionResource>> getByCompetitionIdVisibleForAssessment(Long competitionId); }### Answer:
@Test public void getByCompetitionIdVisibleForAssessment() throws Exception { List<SectionResource> expected = newSectionResource().build(2); long competitionId = 1L; setupGetWithRestResultExpectations(format("%s/get-by-competition-id-visible-for-assessment/%s", sectionRestUrl, competitionId), sectionResourceListType(), expected); assertSame(expected, service.getByCompetitionIdVisibleForAssessment(competitionId).getSuccess()); } |
### Question:
SectionRestServiceImpl extends BaseRestService implements SectionRestService { @Override public RestResult<List<SectionResource>> getChildSectionsByParentId(long parentId) { return getWithRestResult(sectionRestURL + "/get-child-sections/" + parentId, sectionResourceListType()); } @Override RestResult<SectionResource> getById(Long sectionId); @Override RestResult<List<SectionResource>> getChildSectionsByParentId(long parentId); @Override RestResult<List<SectionResource>> getByCompetition(final Long competitionId); @Override RestResult<SectionResource> getSectionByQuestionId(Long questionId); @Override RestResult<Set<Long>> getQuestionsForSectionAndSubsections(Long sectionId); @Override RestResult<List<SectionResource>> getSectionsByCompetitionIdAndType(Long competitionId, SectionType type); @Override RestResult<List<SectionResource>> getByCompetitionIdVisibleForAssessment(Long competitionId); }### Answer:
@Test public void getChildSectionsByParentId() { long parentId = 12L; String expectedUrl = sectionRestUrl + "/get-child-sections/" + parentId; SectionResource parentSectionResource = newSectionResource().withId(parentId).build(); List<SectionResource> childSectionResources = newSectionResource().withParentSection(parentSectionResource.getId()).build(4); setupGetWithRestResultExpectations(expectedUrl, sectionResourceListType(), childSectionResources); RestResult<List<SectionResource>> result = service.getChildSectionsByParentId(parentId); assertEquals(childSectionResources, result.getSuccess()); } |
### Question:
ApplicationAssessmentSummaryRestServiceImpl extends BaseRestService implements ApplicationAssessmentSummaryRestService { @Override public RestResult<ApplicationAvailableAssessorPageResource> getAvailableAssessors(long applicationId, Integer pageIndex, Integer pageSize, String assessorNameFilter, Sort sort) { String uriWithParams = buildUri(applicationAssessmentSummaryRestURL + "/{applicationId}/available-assessors",pageIndex, pageSize, assessorNameFilter, sort, applicationId); return getWithRestResult(uriWithParams, ApplicationAvailableAssessorPageResource.class); } @Override RestResult<List<ApplicationAssessorResource>> getAssignedAssessors(long applicationId); @Override RestResult<ApplicationAvailableAssessorPageResource> getAvailableAssessors(long applicationId, Integer pageIndex, Integer pageSize, String assessorNameFilter, Sort sort); @Override RestResult<List<Long>> getAvailableAssessorsIds(long applicationId, String assessorName); @Override RestResult<ApplicationAssessmentSummaryResource> getApplicationAssessmentSummary(long applicationId); }### Answer:
@Test public void getAvailableAssessors() { ApplicationAvailableAssessorPageResource expected = new ApplicationAvailableAssessorPageResource(); Long applicationId = 1L; int page = 2; int size = 3; String assessorNameFilter = "Name"; Sort sort = Sort.ASSESSOR; setupGetWithRestResultExpectations(format("%s/%s/available-assessors?page=%s&size=%s&assessorNameFilter=%s&sort=%s", applicationAssessmentSummaryRestUrl, applicationId, page, size, assessorNameFilter, sort), ApplicationAvailableAssessorPageResource.class, expected); assertSame(expected, service.getAvailableAssessors(applicationId, page, size, assessorNameFilter, sort).getSuccess()); } |
### Question:
ApplicationAssessmentSummaryRestServiceImpl extends BaseRestService implements ApplicationAssessmentSummaryRestService { @Override public RestResult<List<ApplicationAssessorResource>> getAssignedAssessors(long applicationId) { return getWithRestResult(format("%s/%s/assigned-assessors", applicationAssessmentSummaryRestURL, applicationId), ParameterizedTypeReferences.applicationAssessorResourceListType()); } @Override RestResult<List<ApplicationAssessorResource>> getAssignedAssessors(long applicationId); @Override RestResult<ApplicationAvailableAssessorPageResource> getAvailableAssessors(long applicationId, Integer pageIndex, Integer pageSize, String assessorNameFilter, Sort sort); @Override RestResult<List<Long>> getAvailableAssessorsIds(long applicationId, String assessorName); @Override RestResult<ApplicationAssessmentSummaryResource> getApplicationAssessmentSummary(long applicationId); }### Answer:
@Test public void getAssignedAssessors() { List<ApplicationAssessorResource> expected = newApplicationAssessorResource().build(2); Long applicationId = 1L; setupGetWithRestResultExpectations( format("%s/%s/assigned-assessors", applicationAssessmentSummaryRestUrl, applicationId), ParameterizedTypeReferences.applicationAssessorResourceListType(), expected); assertSame(expected, service.getAssignedAssessors(applicationId).getSuccess()); } |
### Question:
ApplicationAssessmentSummaryRestServiceImpl extends BaseRestService implements ApplicationAssessmentSummaryRestService { @Override public RestResult<ApplicationAssessmentSummaryResource> getApplicationAssessmentSummary(long applicationId) { return getWithRestResult(format("%s/%s", applicationAssessmentSummaryRestURL, applicationId), ApplicationAssessmentSummaryResource.class); } @Override RestResult<List<ApplicationAssessorResource>> getAssignedAssessors(long applicationId); @Override RestResult<ApplicationAvailableAssessorPageResource> getAvailableAssessors(long applicationId, Integer pageIndex, Integer pageSize, String assessorNameFilter, Sort sort); @Override RestResult<List<Long>> getAvailableAssessorsIds(long applicationId, String assessorName); @Override RestResult<ApplicationAssessmentSummaryResource> getApplicationAssessmentSummary(long applicationId); }### Answer:
@Test public void getApplicationAssessmentSummary() { ApplicationAssessmentSummaryResource expected = newApplicationAssessmentSummaryResource().build(); Long applicationId = 1L; setupGetWithRestResultExpectations( format("%s/%s", applicationAssessmentSummaryRestUrl, applicationId), ApplicationAssessmentSummaryResource.class, expected); assertSame(expected, service.getApplicationAssessmentSummary(applicationId).getSuccess()); } |
### Question:
ApplicationAssessmentSummaryRestServiceImpl extends BaseRestService implements ApplicationAssessmentSummaryRestService { @Override public RestResult<List<Long>> getAvailableAssessorsIds(long applicationId, String assessorName) { String uriWithParams = buildUri(applicationAssessmentSummaryRestURL + "/{applicationId}/available-assessors-ids", null, null, assessorName, null, applicationId); return getWithRestResult(uriWithParams, longsListType()); } @Override RestResult<List<ApplicationAssessorResource>> getAssignedAssessors(long applicationId); @Override RestResult<ApplicationAvailableAssessorPageResource> getAvailableAssessors(long applicationId, Integer pageIndex, Integer pageSize, String assessorNameFilter, Sort sort); @Override RestResult<List<Long>> getAvailableAssessorsIds(long applicationId, String assessorName); @Override RestResult<ApplicationAssessmentSummaryResource> getApplicationAssessmentSummary(long applicationId); }### Answer:
@Test public void getAvailableAssessorIds() { List<Long> expected = asList(1L, 2L); long applicationId = 1L; String assessorNameFilter = "Name"; setupGetWithRestResultExpectations(format("%s/%s/available-assessors-ids?assessorNameFilter=%s", applicationAssessmentSummaryRestUrl, applicationId, assessorNameFilter), longsListType(), expected); assertSame(expected, service.getAvailableAssessorsIds(applicationId, assessorNameFilter).getSuccess()); } |
### Question:
AssessorCompetitionSummaryRestServiceImpl extends BaseRestService implements AssessorCompetitionSummaryRestService { @Override public RestResult<AssessorCompetitionSummaryResource> getAssessorSummary(long assessorId, long competitionId) { return getWithRestResult(format(baseUrl + "/summary", assessorId, competitionId), AssessorCompetitionSummaryResource.class); } @Override RestResult<AssessorCompetitionSummaryResource> getAssessorSummary(long assessorId, long competitionId); }### Answer:
@Test public void getAssessorSummary() throws Exception { long assessorId = 1L; long competitionId = 2L; AssessorCompetitionSummaryResource expected = newAssessorCompetitionSummaryResource() .withCompetitionId(competitionId) .withCompetitionName("Test Competition") .build(); setupGetWithRestResultExpectations(format("/assessor/%s/competition/%s/summary", assessorId, competitionId), AssessorCompetitionSummaryResource.class, expected); AssessorCompetitionSummaryResource actual = service.getAssessorSummary(assessorId, competitionId).getSuccess(); assertEquals(expected, actual); } |
### Question:
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponses(long assessmentId) { return getWithRestResult(format("%s/assessment/%s", assessorFormInputResponseRestUrl, assessmentId), assessorFormInputResponseResourceListType()); } @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponses(long assessmentId); @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponsesByAssessmentAndQuestion(long assessmentId, long questionId); @Override RestResult<Void> updateFormInputResponse(long assessmentId, long formInputId, String value); @Override RestResult<Void> updateFormInputResponses(AssessorFormInputResponsesResource assessorFormInputResponseResources); @Override RestResult<ApplicationAssessmentsResource> getApplicationAssessments(long applicationId); @Override RestResult<ApplicationAssessmentResource> getApplicationAssessment(long applicationId, long assessment); @Override RestResult<ApplicationAssessmentAggregateResource> getApplicationAssessmentAggregate(long applicationId); @Override RestResult<AssessmentFeedbackAggregateResource> getAssessmentAggregateFeedback(long applicationId, long questionId); @Override RestResult<AssessmentDetailsResource> getAssessmentDetails(long assessmentId); }### Answer:
@Test public void getAllAssessorFormInputResponses() { List<AssessorFormInputResponseResource> expected = Stream.of(1, 2, 3).map(i -> new AssessorFormInputResponseResource()).collect(Collectors.toList()); long assessmentId = 1L; setupGetWithRestResultExpectations(format("%s/assessment/%s", assessorFormInputResponseRestUrl, assessmentId), assessorFormInputResponseResourceListType(), expected, OK); List<AssessorFormInputResponseResource> response = service.getAllAssessorFormInputResponses(assessmentId).getSuccess(); assertSame(expected, response); } |
### Question:
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<Void> updateFormInputResponse(long assessmentId, long formInputId, String value) { return updateFormInputResponses(new AssessorFormInputResponsesResource( new AssessorFormInputResponseResource(assessmentId, formInputId, value))); } @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponses(long assessmentId); @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponsesByAssessmentAndQuestion(long assessmentId, long questionId); @Override RestResult<Void> updateFormInputResponse(long assessmentId, long formInputId, String value); @Override RestResult<Void> updateFormInputResponses(AssessorFormInputResponsesResource assessorFormInputResponseResources); @Override RestResult<ApplicationAssessmentsResource> getApplicationAssessments(long applicationId); @Override RestResult<ApplicationAssessmentResource> getApplicationAssessment(long applicationId, long assessment); @Override RestResult<ApplicationAssessmentAggregateResource> getApplicationAssessmentAggregate(long applicationId); @Override RestResult<AssessmentFeedbackAggregateResource> getAssessmentAggregateFeedback(long applicationId, long questionId); @Override RestResult<AssessmentDetailsResource> getAssessmentDetails(long assessmentId); }### Answer:
@Test public void updateFormInputResponse() { long assessmentId = 1L; long formInputId = 2L; String value = "Response"; AssessorFormInputResponsesResource responses = new AssessorFormInputResponsesResource( newAssessorFormInputResponseResource() .with(id(null)) .withAssessment(assessmentId) .withFormInput(formInputId) .withValue(value) .build()); setupPutWithRestResultExpectations(format("%s", assessorFormInputResponseRestUrl), responses, OK); RestResult<Void> response = service.updateFormInputResponse(assessmentId, formInputId, value); assertTrue(response.isSuccess()); } |
### Question:
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<Void> updateFormInputResponses(AssessorFormInputResponsesResource assessorFormInputResponseResources) { return putWithRestResult(format("%s", assessorFormInputResponseRestUrl), assessorFormInputResponseResources, Void.class); } @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponses(long assessmentId); @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponsesByAssessmentAndQuestion(long assessmentId, long questionId); @Override RestResult<Void> updateFormInputResponse(long assessmentId, long formInputId, String value); @Override RestResult<Void> updateFormInputResponses(AssessorFormInputResponsesResource assessorFormInputResponseResources); @Override RestResult<ApplicationAssessmentsResource> getApplicationAssessments(long applicationId); @Override RestResult<ApplicationAssessmentResource> getApplicationAssessment(long applicationId, long assessment); @Override RestResult<ApplicationAssessmentAggregateResource> getApplicationAssessmentAggregate(long applicationId); @Override RestResult<AssessmentFeedbackAggregateResource> getAssessmentAggregateFeedback(long applicationId, long questionId); @Override RestResult<AssessmentDetailsResource> getAssessmentDetails(long assessmentId); }### Answer:
@Test public void updateFormInputResponses() { AssessorFormInputResponsesResource responses = new AssessorFormInputResponsesResource( newAssessorFormInputResponseResource() .with(id(null)) .withAssessment(1L) .withFormInput(2L, 3L) .withValue("Response 1", "Response 2") .build(2)); setupPutWithRestResultExpectations(format("%s", assessorFormInputResponseRestUrl), responses, OK); RestResult<Void> response = service.updateFormInputResponses(responses); assertTrue(response.isSuccess()); } |
### Question:
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<ApplicationAssessmentAggregateResource> getApplicationAssessmentAggregate(long applicationId) { return getWithRestResult(format("%s/application/%s/scores", assessorFormInputResponseRestUrl, applicationId), ApplicationAssessmentAggregateResource.class); } @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponses(long assessmentId); @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponsesByAssessmentAndQuestion(long assessmentId, long questionId); @Override RestResult<Void> updateFormInputResponse(long assessmentId, long formInputId, String value); @Override RestResult<Void> updateFormInputResponses(AssessorFormInputResponsesResource assessorFormInputResponseResources); @Override RestResult<ApplicationAssessmentsResource> getApplicationAssessments(long applicationId); @Override RestResult<ApplicationAssessmentResource> getApplicationAssessment(long applicationId, long assessment); @Override RestResult<ApplicationAssessmentAggregateResource> getApplicationAssessmentAggregate(long applicationId); @Override RestResult<AssessmentFeedbackAggregateResource> getAssessmentAggregateFeedback(long applicationId, long questionId); @Override RestResult<AssessmentDetailsResource> getAssessmentDetails(long assessmentId); }### Answer:
@Test public void getApplicationAssessmentAggregate() { long applicationId = 7; Map<Long, BigDecimal> expectedScores = new HashMap<>(); expectedScores.put(17L, new BigDecimal(20)); ApplicationAssessmentAggregateResource expected = new ApplicationAssessmentAggregateResource(true, 13, 11, expectedScores, BigDecimal.valueOf(17)); setupGetWithRestResultExpectations(format("%s/application/%s/scores", assessorFormInputResponseRestUrl, applicationId), ApplicationAssessmentAggregateResource.class, expected, OK); ApplicationAssessmentAggregateResource response = service.getApplicationAssessmentAggregate(applicationId).getSuccess(); assertSame(expected, response); } |
### Question:
AssessorFormInputResponseRestServiceImpl extends BaseRestService implements AssessorFormInputResponseRestService { @Override public RestResult<AssessmentFeedbackAggregateResource> getAssessmentAggregateFeedback(long applicationId, long questionId) { return getWithRestResult(format("%s/application/%s/question/%s/feedback", assessorFormInputResponseRestUrl, applicationId, questionId), AssessmentFeedbackAggregateResource.class); } @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponses(long assessmentId); @Override RestResult<List<AssessorFormInputResponseResource>> getAllAssessorFormInputResponsesByAssessmentAndQuestion(long assessmentId, long questionId); @Override RestResult<Void> updateFormInputResponse(long assessmentId, long formInputId, String value); @Override RestResult<Void> updateFormInputResponses(AssessorFormInputResponsesResource assessorFormInputResponseResources); @Override RestResult<ApplicationAssessmentsResource> getApplicationAssessments(long applicationId); @Override RestResult<ApplicationAssessmentResource> getApplicationAssessment(long applicationId, long assessment); @Override RestResult<ApplicationAssessmentAggregateResource> getApplicationAssessmentAggregate(long applicationId); @Override RestResult<AssessmentFeedbackAggregateResource> getAssessmentAggregateFeedback(long applicationId, long questionId); @Override RestResult<AssessmentDetailsResource> getAssessmentDetails(long assessmentId); }### Answer:
@Test public void getAssessmentAggregateFeedback() { long applicationId = 1L; long questionId = 2L; AssessmentFeedbackAggregateResource expected = newAssessmentFeedbackAggregateResource().build(); setupGetWithRestResultExpectations(format("%s/application/%s/question/%s/feedback", assessorFormInputResponseRestUrl, applicationId, questionId), AssessmentFeedbackAggregateResource.class, expected, OK); AssessmentFeedbackAggregateResource response = service.getAssessmentAggregateFeedback(applicationId, questionId).getSuccess(); assertSame(expected, response); } |
### Question:
RoleProfileStatusServiceImpl implements RoleProfileStatusService { @Override public ServiceResult<List<RoleProfileStatusResource>> findByUserId(long userId) { return find(roleProfileStatusRepository.findByUserId(userId), notFoundError(RoleProfileStatus.class, userId)) .andOnSuccessReturn(rp -> rp.stream() .map(roleProfileStatusMapper::mapToResource) .collect(toList())); } @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); }### Answer:
@Test public void findByUserId() { long userId = 1l; User user = newUser().withId(userId).build(); List<RoleProfileStatus> roleProfileStatus = newRoleProfileStatus().withUser(user).build(1); RoleProfileStatusResource roleProfileStatusResource = newRoleProfileStatusResource().withUserId(userId).build(); when(roleProfileStatusRepositoryMock.findByUserId(userId)).thenReturn(roleProfileStatus); when(roleProfileStatusMapper.mapToResource(roleProfileStatus.get(0))).thenReturn(roleProfileStatusResource); ServiceResult<List<RoleProfileStatusResource>> result = service.findByUserId(userId); assertTrue(result.isSuccess()); assertEquals(roleProfileStatusResource, result.getSuccess().get(0)); } |
### Question:
RoleProfileStatusServiceImpl implements RoleProfileStatusService { @Override public ServiceResult<RoleProfileStatusResource> findByUserIdAndProfileRole(long userId, ProfileRole profileRole) { return find(roleProfileStatusRepository.findByUserIdAndProfileRole(userId, profileRole), notFoundError(RoleProfileStatus.class, userId)) .andOnSuccessReturn(roleProfileStatusMapper::mapToResource); } @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); }### Answer:
@Test public void findByUserIdAndProfileRole() { long userId = 1l; ProfileRole profileRole = ProfileRole.ASSESSOR; User user = newUser().withId(userId).build(); RoleProfileStatus roleProfileStatus = newRoleProfileStatus().withUser(user).build(); RoleProfileStatusResource roleProfileStatusResource = newRoleProfileStatusResource().withUserId(userId).build(); when(roleProfileStatusRepositoryMock.findByUserIdAndProfileRole(userId, profileRole)).thenReturn(Optional.of(roleProfileStatus)); when(roleProfileStatusMapper.mapToResource(roleProfileStatus)).thenReturn(roleProfileStatusResource); ServiceResult<RoleProfileStatusResource> result = service.findByUserIdAndProfileRole(userId, profileRole); assertTrue(result.isSuccess()); assertEquals(roleProfileStatusResource, result.getSuccess()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
AgreementServiceImpl extends BaseTransactionalService implements AgreementService { @Override public ServiceResult<AgreementResource> getCurrent() { return find(repository.findByCurrentTrue(), notFoundError(Agreement.class)).andOnSuccessReturn(mapper::mapToResource); } @Override ServiceResult<AgreementResource> getCurrent(); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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"))); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@Test public void findAllVisibleFallback() { assertTrue(service.findAllVisibleFallback(new Throwable()).getSuccess().isEmpty()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@Test public void delete() throws Exception { setupDeleteWithRestResultExpectations(alertRestURL + "/9999"); service.delete(9999L); setupDeleteWithRestResultVerifications(alertRestURL + "/9999"); } |
### Question:
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); }### Answer:
@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(); } |
### Question:
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); }### Answer:
@Test public void deleteAllByType() throws Exception { setupDeleteWithRestResultExpectations(alertRestURL + "/delete/MAINTENANCE"); service.deleteAllByType(AlertType.MAINTENANCE); setupDeleteWithRestResultVerifications(alertRestURL + "/delete/MAINTENANCE"); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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(); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@Test public void markYourOrganisationComplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-organisation-complete", HttpStatus.OK); RestResult<Void> result = service.markYourOrganisationComplete(projectId, organisationId); assertTrue(result.isSuccess()); } |
### Question:
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); }### Answer:
@Test public void markYourFundingComplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-funding-complete", HttpStatus.OK); RestResult<Void> result = service.markYourFundingComplete(projectId, organisationId); assertTrue(result.isSuccess()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@Test public void markYourOrganisationIncomplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-organisation-incomplete", HttpStatus.OK); RestResult<Void> result = service.markYourOrganisationIncomplete(projectId, organisationId); assertTrue(result.isSuccess()); } |
### Question:
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); }### Answer:
@Test public void markYourFundingIncomplete() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId) + "/your-funding-incomplete", HttpStatus.OK); RestResult<Void> result = service.markYourFundingIncomplete(projectId, organisationId); assertTrue(result.isSuccess()); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@Test public void completePartnerSetup() { setupPostWithRestResultExpectations(format(pendingPartnerProgressUrl, projectId, organisationId), HttpStatus.OK); RestResult<Void> result = service.completePartnerSetup(projectId, organisationId); assertTrue(result.isSuccess()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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()); } |
### Question:
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); }### Answer:
@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); } |
### Question:
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); }### Answer:
@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); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.