use of org.pmiops.workbench.db.model.CohortAnnotationDefinition in project workbench by all-of-us.
the class CohortAnnotationDefinitionDaoTest method findByCohortIdOrderByEnumValuesAsc.
@Test
public void findByCohortIdOrderByEnumValuesAsc() throws Exception {
CohortAnnotationDefinition cohortAnnotationDefinition = createCohortAnnotationDefinition();
cohortAnnotationDefinitionDao.save(cohortAnnotationDefinition);
List<CohortAnnotationDefinition> expectedDBList = cohortAnnotationDefinitionDao.findByCohortId(cohortAnnotationDefinition.getCohortId());
assertEquals(expectedDBList.get(0), cohortAnnotationDefinition);
}
use of org.pmiops.workbench.db.model.CohortAnnotationDefinition in project workbench by all-of-us.
the class ParticipantCohortAnnotationDaoTest method setUp.
@Before
public void setUp() throws Exception {
CohortAnnotationDefinition cohortAnnotationDefinition = new CohortAnnotationDefinition().cohortId(COHORT_ID).columnName("enum").annotationType(AnnotationType.ENUM);
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);
ParticipantCohortAnnotation pca = new ParticipantCohortAnnotation().cohortAnnotationDefinitionId(cohortAnnotationDefinitionId).cohortReviewId(cohortReviewId).participantId(participantId).annotationValueBoolean(Boolean.TRUE);
ParticipantCohortAnnotation pca1 = new ParticipantCohortAnnotation().cohortAnnotationDefinitionId(cohortAnnotationDefinitionId1).cohortReviewId(cohortReviewId).participantId(participantId).annotationValueEnum("test");
pca1.setCohortAnnotationEnumValue(enumValue1);
annotationId = participantCohortAnnotationDao.save(pca).getAnnotationId();
participantCohortAnnotationDao.save(pca1);
}
use of org.pmiops.workbench.db.model.CohortAnnotationDefinition in project workbench by all-of-us.
the class CohortReviewControllerTest method assertCreateParticipantCohortAnnotation.
private void assertCreateParticipantCohortAnnotation(ParticipantCohortAnnotation request, AnnotationType annotationType) throws Exception {
ParticipantCohortStatusKey key = new ParticipantCohortStatusKey().cohortReviewId(cohortReviewId).participantId(participantId);
ParticipantCohortStatus participantCohortStatus = new ParticipantCohortStatus().participantKey(key);
CohortAnnotationDefinition cohortAnnotationDefinition = new CohortAnnotationDefinition().annotationType(annotationType);
if (request.getAnnotationValueEnum() != null) {
CohortAnnotationEnumValue cohortAnnotationEnumValue = new CohortAnnotationEnumValue().name(request.getAnnotationValueEnum());
cohortAnnotationDefinition.setEnumValues(new TreeSet(Arrays.asList(cohortAnnotationEnumValue)));
}
when(cohortReviewService.findCohort(cohortId)).thenReturn(createCohort(cohortId, workspaceId, null));
when(cohortReviewService.validateMatchingWorkspace(namespace, name, workspaceId, WorkspaceAccessLevel.WRITER)).thenReturn(new Workspace());
when(cohortReviewService.findCohortReview(cohortId, cdrVersionId)).thenReturn(createCohortReview(0, cohortId, cohortReviewId, cdrVersionId, null));
when(cohortReviewService.saveParticipantCohortAnnotation(isA(Long.class), isA(org.pmiops.workbench.db.model.ParticipantCohortAnnotation.class))).thenReturn(createParticipantCohortAnnotation(request));
ParticipantCohortAnnotation response = reviewController.createParticipantCohortAnnotation(namespace, name, cohortId, cdrVersionId, participantId, request).getBody();
assertEquals(request, response);
verify(cohortReviewService, atLeastOnce()).findCohort(cohortId);
verify(cohortReviewService, atLeastOnce()).validateMatchingWorkspace(namespace, name, workspaceId, WorkspaceAccessLevel.WRITER);
verify(cohortReviewService, atLeastOnce()).findCohortReview(cohortId, cdrVersionId);
verify(cohortReviewService, atLeastOnce()).saveParticipantCohortAnnotation(isA(Long.class), isA(org.pmiops.workbench.db.model.ParticipantCohortAnnotation.class));
verifyNoMoreMockInteractions();
}
use of org.pmiops.workbench.db.model.CohortAnnotationDefinition in project workbench by all-of-us.
the class CohortReviewServiceImplTest method assertSaveParticipantCohortAnnotation.
private void assertSaveParticipantCohortAnnotation(ParticipantCohortAnnotation participantCohortAnnotation, AnnotationType annotationType) {
long cohortAnnotationDefinitionId = participantCohortAnnotation.getCohortAnnotationDefinitionId();
long cohortReviewId = participantCohortAnnotation.getCohortReviewId();
long participantId = participantCohortAnnotation.getParticipantId();
CohortAnnotationDefinition cohortAnnotationDefinition = createCohortAnnotationDefinition(cohortAnnotationDefinitionId, annotationType);
when(cohortAnnotationDefinitionDao.findOne(cohortAnnotationDefinitionId)).thenReturn(cohortAnnotationDefinition);
when(participantCohortAnnotationDao.findByCohortReviewIdAndCohortAnnotationDefinitionIdAndParticipantId(cohortReviewId, cohortAnnotationDefinitionId, participantId)).thenReturn(null);
when(participantCohortAnnotationDao.save(participantCohortAnnotation)).thenReturn(participantCohortAnnotation);
cohortReviewService.saveParticipantCohortAnnotation(cohortReviewId, participantCohortAnnotation);
verify(cohortAnnotationDefinitionDao, atLeastOnce()).findOne(cohortAnnotationDefinitionId);
verify(participantCohortAnnotationDao, atLeastOnce()).findByCohortReviewIdAndCohortAnnotationDefinitionIdAndParticipantId(cohortReviewId, cohortAnnotationDefinitionId, participantId);
verify(participantCohortAnnotationDao, atLeastOnce()).save(participantCohortAnnotation);
verifyNoMoreMockInteractions();
}
use of org.pmiops.workbench.db.model.CohortAnnotationDefinition in project workbench by all-of-us.
the class CohortAnnotationDefinitionDaoTest method findByCohortIdAndColumnName.
@Test
public void findByCohortIdAndColumnName() throws Exception {
CohortAnnotationDefinition cohortAnnotationDefinition = createCohortAnnotationDefinition();
cohortAnnotationDefinitionDao.save(cohortAnnotationDefinition);
CohortAnnotationDefinition expectedAnnotationDefinition = cohortAnnotationDefinitionDao.findByCohortIdAndColumnName(cohortAnnotationDefinition.getCohortId(), cohortAnnotationDefinition.getColumnName());
assertEquals(expectedAnnotationDefinition, cohortAnnotationDefinition);
}
Aggregations