use of org.pmiops.workbench.model.ModifyParticipantCohortAnnotationRequest in project workbench by all-of-us.
the class CohortReviewServiceImplTest method updateParticipantCohortAnnotationModifyNotFoundCohortAnnotationDefinition.
@Test
public void updateParticipantCohortAnnotationModifyNotFoundCohortAnnotationDefinition() throws Exception {
long annotationId = 1;
long cohortAnnotationDefinitionId = 1;
long cohortReviewId = 1;
long participantId = 1;
ParticipantCohortAnnotation participantCohortAnnotation = new ParticipantCohortAnnotation().annotationValueBoolean(Boolean.TRUE).cohortAnnotationDefinitionId(cohortAnnotationDefinitionId).cohortReviewId(cohortReviewId).participantId(participantId);
ModifyParticipantCohortAnnotationRequest modifyRequest = new ModifyParticipantCohortAnnotationRequest().annotationValueBoolean(Boolean.FALSE);
when(participantCohortAnnotationDao.findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId)).thenReturn(participantCohortAnnotation);
when(cohortAnnotationDefinitionDao.findOne(cohortAnnotationDefinitionId)).thenReturn(null);
try {
cohortReviewService.updateParticipantCohortAnnotation(annotationId, cohortReviewId, participantId, modifyRequest);
fail("Should have thrown NotFoundException!");
} catch (NotFoundException e) {
assertEquals("Not Found: No cohort annotation definition found for id: " + cohortAnnotationDefinitionId, e.getMessage());
}
verify(participantCohortAnnotationDao).findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId);
verify(cohortAnnotationDefinitionDao).findOne(cohortAnnotationDefinitionId);
verifyNoMoreMockInteractions();
}
use of org.pmiops.workbench.model.ModifyParticipantCohortAnnotationRequest in project workbench by all-of-us.
the class CohortReviewServiceImplTest method assertParticipantCohortAnnotationModifyBadRequest.
private void assertParticipantCohortAnnotationModifyBadRequest(Long annotationId, ParticipantCohortAnnotation participantCohortAnnotation, AnnotationType annotationType) {
Long cohortAnnotationDefinitionId = participantCohortAnnotation.getCohortAnnotationDefinitionId();
Long cohortReviewId = participantCohortAnnotation.getCohortReviewId();
Long participantId = participantCohortAnnotation.getParticipantId();
CohortAnnotationDefinition cohortAnnotationDefinition = createCohortAnnotationDefinition(cohortAnnotationDefinitionId, annotationType);
when(participantCohortAnnotationDao.findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId)).thenReturn(participantCohortAnnotation);
when(cohortAnnotationDefinitionDao.findOne(cohortAnnotationDefinitionId)).thenReturn(cohortAnnotationDefinition);
try {
cohortReviewService.updateParticipantCohortAnnotation(annotationId, cohortReviewId, participantId, new ModifyParticipantCohortAnnotationRequest());
fail("Should have thrown BadRequestExcpetion!");
} catch (BadRequestException e) {
assertEquals("Invalid Request: Please provide a valid " + cohortAnnotationDefinition.getAnnotationType().name() + " value for annotation defintion id: " + cohortAnnotationDefinition.getCohortAnnotationDefinitionId(), e.getMessage());
}
verify(participantCohortAnnotationDao, atLeastOnce()).findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId);
verify(cohortAnnotationDefinitionDao, atLeastOnce()).findOne(cohortAnnotationDefinitionId);
verifyNoMoreMockInteractions();
}
use of org.pmiops.workbench.model.ModifyParticipantCohortAnnotationRequest in project workbench by all-of-us.
the class CohortReviewServiceImplTest method updateParticipantCohortAnnotationModifyNotFoundParticipantCohortAnnotation.
@Test
public void updateParticipantCohortAnnotationModifyNotFoundParticipantCohortAnnotation() throws Exception {
long annotationId = 1;
long cohortAnnotationDefinitionId = 1;
long cohortReviewId = 1;
long participantId = 1;
ModifyParticipantCohortAnnotationRequest modifyRequest = new ModifyParticipantCohortAnnotationRequest().annotationValueBoolean(Boolean.FALSE);
when(participantCohortAnnotationDao.findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId)).thenReturn(null);
try {
cohortReviewService.updateParticipantCohortAnnotation(annotationId, cohortReviewId, participantId, modifyRequest);
fail("Should have thrown NotFoundException!");
} catch (NotFoundException e) {
assertEquals("Not Found: Participant Cohort Annotation does not exist for annotationId: " + annotationId + ", cohortReviewId: " + cohortReviewId + ", participantId: " + cohortAnnotationDefinitionId, e.getMessage());
}
verify(participantCohortAnnotationDao).findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId);
verifyNoMoreMockInteractions();
}
use of org.pmiops.workbench.model.ModifyParticipantCohortAnnotationRequest in project workbench by all-of-us.
the class CohortReviewServiceImplTest method updateParticipantCohortAnnotationModify.
@Test
public void updateParticipantCohortAnnotationModify() throws Exception {
long annotationId = 1;
long cohortAnnotationDefinitionId = 1;
long cohortReviewId = 1;
long participantId = 1;
ParticipantCohortAnnotation participantCohortAnnotation = new ParticipantCohortAnnotation().annotationValueBoolean(Boolean.TRUE).cohortAnnotationDefinitionId(cohortAnnotationDefinitionId).cohortReviewId(cohortReviewId).participantId(participantId);
ModifyParticipantCohortAnnotationRequest modifyRequest = new ModifyParticipantCohortAnnotationRequest().annotationValueBoolean(Boolean.FALSE);
CohortAnnotationDefinition cohortAnnotationDefinition = createCohortAnnotationDefinition(cohortAnnotationDefinitionId, AnnotationType.BOOLEAN);
when(participantCohortAnnotationDao.findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId)).thenReturn(participantCohortAnnotation);
when(cohortAnnotationDefinitionDao.findOne(cohortAnnotationDefinitionId)).thenReturn(cohortAnnotationDefinition);
cohortReviewService.updateParticipantCohortAnnotation(annotationId, cohortReviewId, participantId, modifyRequest);
verify(participantCohortAnnotationDao).findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId);
verify(cohortAnnotationDefinitionDao).findOne(cohortAnnotationDefinitionId);
verifyNoMoreMockInteractions();
}
Aggregations