use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation in project workbench by all-of-us.
the class ParticipantCohortAnnotationDaoTest method findByCohortReviewIdAndCohortAnnotationDefinitionIdAndParticipantId.
@Test
public void findByCohortReviewIdAndCohortAnnotationDefinitionIdAndParticipantId() throws Exception {
ParticipantCohortAnnotation expectedPCA = new ParticipantCohortAnnotation().annotationId(annotationId).cohortAnnotationDefinitionId(cohortAnnotationDefinitionId).cohortReviewId(cohortReviewId).participantId(participantId).annotationValueBoolean(Boolean.TRUE);
ParticipantCohortAnnotation actualPCA = participantCohortAnnotationDao.findByCohortReviewIdAndCohortAnnotationDefinitionIdAndParticipantId(cohortReviewId, cohortAnnotationDefinitionId, participantId);
assertEquals(expectedPCA, actualPCA);
}
use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation in project workbench by all-of-us.
the class CohortReviewServiceImplTest method saveParticipantCohortAnnotationNotFoundCohortAnnotationDefinition.
@Test
public void saveParticipantCohortAnnotationNotFoundCohortAnnotationDefinition() throws Exception {
long cohortAnnotationDefinitionId = 1;
long cohortReviewId = 1;
long participantId = 1;
ParticipantCohortAnnotation participantCohortAnnotation = new ParticipantCohortAnnotation().annotationValueBoolean(Boolean.TRUE).cohortAnnotationDefinitionId(cohortAnnotationDefinitionId).cohortReviewId(cohortReviewId).participantId(participantId);
when(cohortAnnotationDefinitionDao.findOne(cohortAnnotationDefinitionId)).thenReturn(null);
try {
cohortReviewService.saveParticipantCohortAnnotation(cohortReviewId, participantCohortAnnotation);
fail("Should have thrown NotFoundExcpetion!");
} catch (NotFoundException e) {
assertEquals("Not Found: No cohort annotation definition found for id: " + cohortAnnotationDefinitionId, e.getMessage());
}
verify(cohortAnnotationDefinitionDao).findOne(cohortAnnotationDefinitionId);
verifyNoMoreMockInteractions();
}
use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation 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();
}
use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation in project workbench by all-of-us.
the class CohortReviewServiceImplTest method saveParticipantCohortAnnotationBadRequest.
@Test
public void saveParticipantCohortAnnotationBadRequest() throws Exception {
long cohortAnnotationDefinitionId = 1;
long cohortReviewId = 1;
long participantId = 1;
ParticipantCohortAnnotation participantCohortAnnotation = new ParticipantCohortAnnotation().cohortAnnotationDefinitionId(cohortAnnotationDefinitionId).cohortReviewId(cohortReviewId).participantId(participantId);
assertParticipantCohortAnnotationBadRequest(participantCohortAnnotation, createCohortAnnotationDefinition(cohortAnnotationDefinitionId, AnnotationType.BOOLEAN));
assertParticipantCohortAnnotationBadRequest(participantCohortAnnotation, createCohortAnnotationDefinition(cohortAnnotationDefinitionId, AnnotationType.STRING));
assertParticipantCohortAnnotationBadRequest(participantCohortAnnotation, createCohortAnnotationDefinition(cohortAnnotationDefinitionId, AnnotationType.INTEGER));
assertParticipantCohortAnnotationBadRequest(participantCohortAnnotation, createCohortAnnotationDefinition(cohortAnnotationDefinitionId, AnnotationType.STRING));
assertParticipantCohortAnnotationBadRequest(participantCohortAnnotation, createCohortAnnotationDefinition(cohortAnnotationDefinitionId, AnnotationType.ENUM));
}
use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation in project workbench by all-of-us.
the class CohortReviewServiceImpl method updateParticipantCohortAnnotation.
@Override
public ParticipantCohortAnnotation updateParticipantCohortAnnotation(Long annotationId, Long cohortReviewId, Long participantId, ModifyParticipantCohortAnnotationRequest modifyRequest) {
ParticipantCohortAnnotation participantCohortAnnotation = participantCohortAnnotationDao.findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId);
if (participantCohortAnnotation == null) {
throw new NotFoundException(String.format("Not Found: Participant Cohort Annotation does not exist for annotationId: %s, cohortReviewId: %s, participantId: %s", annotationId, cohortReviewId, participantId));
}
participantCohortAnnotation.annotationValueString(modifyRequest.getAnnotationValueString()).annotationValueEnum(modifyRequest.getAnnotationValueEnum()).annotationValueDateString(modifyRequest.getAnnotationValueDate()).annotationValueBoolean(modifyRequest.getAnnotationValueBoolean()).annotationValueInteger(modifyRequest.getAnnotationValueInteger());
CohortAnnotationDefinition cohortAnnotationDefinition = findCohortAnnotationDefinition(participantCohortAnnotation.getCohortAnnotationDefinitionId());
validateParticipantCohortAnnotation(participantCohortAnnotation, cohortAnnotationDefinition);
return participantCohortAnnotationDao.save(participantCohortAnnotation);
}
Aggregations