Search in sources :

Example 6 with ParticipantCohortAnnotation

use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation in project workbench by all-of-us.

the class ParticipantCohortAnnotationDaoTest method findByAnnotationIdAndCohortReviewIdAndParticipantId.

@Test
public void findByAnnotationIdAndCohortReviewIdAndParticipantId() throws Exception {
    ParticipantCohortAnnotation expectedPCA = new ParticipantCohortAnnotation().annotationId(annotationId).cohortAnnotationDefinitionId(cohortAnnotationDefinitionId).cohortReviewId(cohortReviewId).participantId(participantId).annotationValueBoolean(Boolean.TRUE);
    ParticipantCohortAnnotation actualPCA = participantCohortAnnotationDao.findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId);
    assertEquals(expectedPCA, actualPCA);
}
Also used : ParticipantCohortAnnotation(org.pmiops.workbench.db.model.ParticipantCohortAnnotation) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 7 with ParticipantCohortAnnotation

use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation in project workbench by all-of-us.

the class ParticipantCohortAnnotationDaoTest method findByCohortReviewIdAndParticipantIdEnum.

@Test
public void findByCohortReviewIdAndParticipantIdEnum() throws Exception {
    ParticipantCohortAnnotation expectedPCA = new ParticipantCohortAnnotation().annotationId(annotationId).cohortAnnotationDefinitionId(cohortAnnotationDefinitionId1).cohortReviewId(cohortReviewId).participantId(participantId).annotationValueEnum("test");
    List<ParticipantCohortAnnotation> annotations = participantCohortAnnotationDao.findByCohortReviewIdAndParticipantId(cohortReviewId, participantId);
    assertEquals(2, annotations.size());
    assertEquals(expectedPCA, annotations.get(1));
    assertEquals(new CohortAnnotationEnumValue().name("z").order(0), annotations.get(1).getCohortAnnotationEnumValue());
}
Also used : ParticipantCohortAnnotation(org.pmiops.workbench.db.model.ParticipantCohortAnnotation) CohortAnnotationEnumValue(org.pmiops.workbench.db.model.CohortAnnotationEnumValue) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 8 with ParticipantCohortAnnotation

use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation in project workbench by all-of-us.

the class ParticipantCohortAnnotationDaoTest method findByCohortReviewIdAndParticipantId.

@Test
public void findByCohortReviewIdAndParticipantId() throws Exception {
    ParticipantCohortAnnotation expectedPCA = new ParticipantCohortAnnotation().annotationId(annotationId).cohortAnnotationDefinitionId(cohortAnnotationDefinitionId).cohortReviewId(cohortReviewId).participantId(participantId).annotationValueBoolean(Boolean.TRUE);
    List<ParticipantCohortAnnotation> annotations = participantCohortAnnotationDao.findByCohortReviewIdAndParticipantId(cohortReviewId, participantId);
    assertEquals(2, annotations.size());
    assertEquals(expectedPCA, annotations.get(0));
}
Also used : ParticipantCohortAnnotation(org.pmiops.workbench.db.model.ParticipantCohortAnnotation) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 9 with ParticipantCohortAnnotation

use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation 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);
}
Also used : CohortAnnotationDefinition(org.pmiops.workbench.db.model.CohortAnnotationDefinition) ParticipantCohortAnnotation(org.pmiops.workbench.db.model.ParticipantCohortAnnotation) CohortAnnotationEnumValue(org.pmiops.workbench.db.model.CohortAnnotationEnumValue) Before(org.junit.Before)

Example 10 with ParticipantCohortAnnotation

use of org.pmiops.workbench.db.model.ParticipantCohortAnnotation in project workbench by all-of-us.

the class CohortReviewServiceImplTest method saveParticipantCohortAnnotationModifyBadRequest.

@Test
public void saveParticipantCohortAnnotationModifyBadRequest() throws Exception {
    long annotationId = 1;
    long cohortAnnotationDefinitionId = 1;
    long cohortReviewId = 1;
    long participantId = 1;
    ParticipantCohortAnnotation participantCohortAnnotation = new ParticipantCohortAnnotation().cohortAnnotationDefinitionId(cohortAnnotationDefinitionId).cohortReviewId(cohortReviewId).participantId(participantId);
    assertParticipantCohortAnnotationModifyBadRequest(annotationId, participantCohortAnnotation, AnnotationType.BOOLEAN);
    assertParticipantCohortAnnotationModifyBadRequest(annotationId, participantCohortAnnotation, AnnotationType.INTEGER);
    assertParticipantCohortAnnotationModifyBadRequest(annotationId, participantCohortAnnotation, AnnotationType.STRING);
    assertParticipantCohortAnnotationModifyBadRequest(annotationId, participantCohortAnnotation, AnnotationType.ENUM);
    assertParticipantCohortAnnotationModifyBadRequest(annotationId, participantCohortAnnotation, AnnotationType.DATE);
}
Also used : ParticipantCohortAnnotation(org.pmiops.workbench.db.model.ParticipantCohortAnnotation) Test(org.junit.Test)

Aggregations

ParticipantCohortAnnotation (org.pmiops.workbench.db.model.ParticipantCohortAnnotation)16 Test (org.junit.Test)12 CohortAnnotationDefinition (org.pmiops.workbench.db.model.CohortAnnotationDefinition)5 NotFoundException (org.pmiops.workbench.exceptions.NotFoundException)5 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)4 CohortAnnotationEnumValue (org.pmiops.workbench.db.model.CohortAnnotationEnumValue)3 ModifyParticipantCohortAnnotationRequest (org.pmiops.workbench.model.ModifyParticipantCohortAnnotationRequest)3 Date (java.sql.Date)2 SimpleDateFormat (java.text.SimpleDateFormat)2 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)2 ParseException (java.text.ParseException)1 List (java.util.List)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1 Provider (javax.inject.Provider)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Before (org.junit.Before)1 GenderRaceEthnicityConcept (org.pmiops.workbench.cdr.cache.GenderRaceEthnicityConcept)1 PageRequest (org.pmiops.workbench.cohortreview.util.PageRequest)1 CohortAnnotationDefinitionDao (org.pmiops.workbench.db.dao.CohortAnnotationDefinitionDao)1