use of org.pmiops.workbench.db.model.CohortAnnotationDefinition in project workbench by all-of-us.
the class CohortAnnotationDefinitionDaoTest method save_NoEnumValues.
@Test
public void save_NoEnumValues() throws Exception {
CohortAnnotationDefinition cohortAnnotationDefinition = createCohortAnnotationDefinition();
cohortAnnotationDefinitionDao.save(cohortAnnotationDefinition);
String sql = "select count(*) from cohort_annotation_definition where cohort_annotation_definition_id = ?";
final Object[] sqlParams = { cohortAnnotationDefinition.getCohortAnnotationDefinitionId() };
final Integer expectedCount = new Integer("1");
assertEquals(expectedCount, jdbcTemplate.queryForObject(sql, sqlParams, Integer.class));
}
use of org.pmiops.workbench.db.model.CohortAnnotationDefinition in project workbench by all-of-us.
the class CohortAnnotationDefinitionDaoTest method save_WithEnumValues.
@Test
public void save_WithEnumValues() throws Exception {
CohortAnnotationDefinition cohortAnnotationDefinition = createCohortAnnotationDefinition();
CohortAnnotationEnumValue enumValue1 = new CohortAnnotationEnumValue().name("z").order(0).cohortAnnotationDefinition(cohortAnnotationDefinition);
CohortAnnotationEnumValue enumValue2 = new CohortAnnotationEnumValue().name("r").order(1).cohortAnnotationDefinition(cohortAnnotationDefinition);
CohortAnnotationEnumValue enumValue3 = new CohortAnnotationEnumValue().name("a").order(2).cohortAnnotationDefinition(cohortAnnotationDefinition);
cohortAnnotationDefinition.getEnumValues().add(enumValue1);
cohortAnnotationDefinition.getEnumValues().add(enumValue2);
cohortAnnotationDefinition.getEnumValues().add(enumValue3);
cohortAnnotationDefinitionDao.save(cohortAnnotationDefinition);
String sql = "select count(*) from cohort_annotation_definition where cohort_annotation_definition_id = ?";
Object[] sqlParams = { cohortAnnotationDefinition.getCohortAnnotationDefinitionId() };
Integer expectedCount = new Integer("1");
assertEquals(expectedCount, jdbcTemplate.queryForObject(sql, sqlParams, Integer.class));
sql = "select count(*) from cohort_annotation_enum_value where cohort_annotation_definition_id = ?";
sqlParams = new Object[] { cohortAnnotationDefinition.getCohortAnnotationDefinitionId() };
expectedCount = new Integer("3");
assertEquals(expectedCount, jdbcTemplate.queryForObject(sql, sqlParams, Integer.class));
List<CohortAnnotationDefinition> cad = cohortAnnotationDefinitionDao.findByCohortId(cohortAnnotationDefinition.getCohortId());
assertEquals(cohortAnnotationDefinition, cad.get(0));
}
use of org.pmiops.workbench.db.model.CohortAnnotationDefinition 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.CohortAnnotationDefinition 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