use of org.pmiops.workbench.db.model.CohortAnnotationEnumValue 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));
}
Aggregations