Search in sources :

Example 11 with CdrVersion

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

the class ParticipantCohortStatusDaoTest method onSetup.

@Before
public void onSetup() {
    page = 0;
    pageSize = 25;
    CdrVersion cdrVersion = new CdrVersion();
    cdrVersion.setCdrDbName("");
    CdrVersionContext.setCdrVersion(cdrVersion);
    jdbcTemplate.execute("insert into participant_cohort_status" + "(cohort_review_id, participant_id, status, gender_concept_id, birth_date, race_concept_id, ethnicity_concept_id)" + "values (1, 1, 1, 1, sysdate(), 2, 3)");
    jdbcTemplate.execute("insert into participant_cohort_status" + "(cohort_review_id, participant_id, status, gender_concept_id, birth_date, race_concept_id, ethnicity_concept_id)" + "values (1, 2, 0, 1, sysdate(), 2, 3)");
    jdbcTemplate.execute("insert into concept" + "(concept_id, concept_name, domain_id, vocabulary_id, concept_class_id, standard_concept, concept_code, count_value, prevalence)" + "values (1, 'MALE', 3, 'Gender', 1, 'c', 'c', 1, 1)");
    jdbcTemplate.execute("insert into concept" + "(concept_id, concept_name, domain_id, vocabulary_id, concept_class_id, standard_concept, concept_code, count_value, prevalence)" + "values (2, 'Asian', 3, 'Race', 1, 'c', 'c', 1, 1)");
    jdbcTemplate.execute("insert into concept" + "(concept_id, concept_name, domain_id, vocabulary_id, concept_class_id, standard_concept, concept_code, count_value, prevalence)" + "values (3, 'Not Hispanic', 3, 'Ethnicity', 1, 'c', 'c', 1, 1)");
}
Also used : CdrVersion(org.pmiops.workbench.db.model.CdrVersion) Before(org.junit.Before)

Example 12 with CdrVersion

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

the class CohortBuilderControllerMockTest method getCriteriaByTypeAndParentIdPhecodes.

@Test
public void getCriteriaByTypeAndParentIdPhecodes() throws Exception {
    org.pmiops.workbench.cdr.model.Criteria expectedCriteria = new org.pmiops.workbench.cdr.model.Criteria().id(1L).type("PHECODE").name("Intestinal infection").group(true).selectable(true).count("0").conceptId("0");
    when(mockCdrVersionDao.findOne(1L)).thenReturn(new CdrVersion());
    when(mockCriteriaDao.findCriteriaByTypeAndParentIdOrderByCodeAsc("PHECODE", 0L)).thenReturn(Arrays.asList(expectedCriteria));
    assertCriteria(controller.getCriteriaByTypeAndParentId(1l, "PHECODE", 0L), new Criteria().id(1L).type("PHECODE").name("Intestinal infection").group(true).selectable(true).count(0L).conceptId(0L));
    verify(mockCdrVersionDao).findOne(1L);
    verify(mockCriteriaDao).findCriteriaByTypeAndParentIdOrderByCodeAsc("PHECODE", 0L);
    verifyNoMoreInteractions(mockCriteriaDao, mockCdrVersionDao);
}
Also used : CdrVersion(org.pmiops.workbench.db.model.CdrVersion) Criteria(org.pmiops.workbench.model.Criteria) Test(org.junit.Test)

Example 13 with CdrVersion

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

the class CohortBuilderControllerMockTest method getCriteriaByTypeAndParentIdDemo.

@Test
public void getCriteriaByTypeAndParentIdDemo() throws Exception {
    org.pmiops.workbench.cdr.model.Criteria expectedCriteria = new org.pmiops.workbench.cdr.model.Criteria().id(1L).type("DEMO").name("Age").group(false).selectable(true).count("0").conceptId("12").subtype("AGE");
    when(mockCdrVersionDao.findOne(1L)).thenReturn(new CdrVersion());
    when(mockCriteriaDao.findCriteriaByTypeAndParentIdOrderByCodeAsc("DEMO", 0L)).thenReturn(Arrays.asList(expectedCriteria));
    assertCriteria(controller.getCriteriaByTypeAndParentId(1L, "DEMO", 0L), new Criteria().id(1L).type("DEMO").name("Age").group(false).selectable(true).count(0L).conceptId(12L).subtype("AGE"));
    verify(mockCdrVersionDao).findOne(1L);
    verify(mockCriteriaDao).findCriteriaByTypeAndParentIdOrderByCodeAsc("DEMO", 0L);
    verifyNoMoreInteractions(mockCriteriaDao, mockCdrVersionDao);
}
Also used : CdrVersion(org.pmiops.workbench.db.model.CdrVersion) Criteria(org.pmiops.workbench.model.Criteria) Test(org.junit.Test)

Example 14 with CdrVersion

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

the class CohortBuilderControllerMockTest method getCriteriaTreeQuickSearch.

@Test
public void getCriteriaTreeQuickSearch() throws Exception {
    org.pmiops.workbench.cdr.model.Criteria expectedCriteria = new org.pmiops.workbench.cdr.model.Criteria().id(1L).type("PHECODE").name("Intestinal infection").group(true).selectable(true).count("0").conceptId("0");
    when(mockCdrVersionDao.findOne(1L)).thenReturn(new CdrVersion());
    when(mockCriteriaDao.findCriteriaByTypeAndNameOrCode("PHECODE", "infect*")).thenReturn(Arrays.asList(expectedCriteria));
    assertCriteria(controller.getCriteriaTreeQuickSearch(1L, "PHECODE", "infect"), new Criteria().id(1L).type("PHECODE").name("Intestinal infection").group(true).selectable(true).count(0L).conceptId(0L));
    verify(mockCdrVersionDao).findOne(1L);
    verify(mockCriteriaDao).findCriteriaByTypeAndNameOrCode("PHECODE", "infect*");
    verifyNoMoreInteractions(mockCriteriaDao, mockCdrVersionDao);
}
Also used : CdrVersion(org.pmiops.workbench.db.model.CdrVersion) Criteria(org.pmiops.workbench.model.Criteria) Test(org.junit.Test)

Example 15 with CdrVersion

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

the class CohortBuilderControllerMockTest method getCriteriaByTypeAndParentIdIcd9.

@Test
public void getCriteriaByTypeAndParentIdIcd9() throws Exception {
    org.pmiops.workbench.cdr.model.Criteria expectedCriteria = new org.pmiops.workbench.cdr.model.Criteria().id(1L).type("ICD9").code("001-139.99").name("Infectious and parasitic diseases").group(false).selectable(false).count("0").conceptId("0");
    when(mockCdrVersionDao.findOne(1L)).thenReturn(new CdrVersion());
    when(mockCriteriaDao.findCriteriaByTypeAndParentIdOrderByCodeAsc("ICD9", 0L)).thenReturn(Arrays.asList(expectedCriteria));
    assertCriteria(controller.getCriteriaByTypeAndParentId(1L, "ICD9", 0L), new Criteria().id(1L).type("ICD9").code("001-139.99").name("Infectious and parasitic diseases").group(false).selectable(false).count(0L).conceptId(0L));
    verify(mockCdrVersionDao).findOne(1L);
    verify(mockCriteriaDao).findCriteriaByTypeAndParentIdOrderByCodeAsc("ICD9", 0L);
    verifyNoMoreInteractions(mockCriteriaDao, mockCdrVersionDao);
}
Also used : CdrVersion(org.pmiops.workbench.db.model.CdrVersion) Criteria(org.pmiops.workbench.model.Criteria) Test(org.junit.Test)

Aggregations

CdrVersion (org.pmiops.workbench.db.model.CdrVersion)18 Before (org.junit.Before)8 Test (org.junit.Test)8 Criteria (org.pmiops.workbench.model.Criteria)7 Gson (com.google.gson.Gson)4 User (org.pmiops.workbench.db.model.User)4 CohortReview (org.pmiops.workbench.db.model.CohortReview)2 Workspace (org.pmiops.workbench.db.model.Workspace)2 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)2 ResearchPurpose (org.pmiops.workbench.model.ResearchPurpose)2 Workspace (org.pmiops.workbench.model.Workspace)2 FieldValue (com.google.cloud.bigquery.FieldValue)1 QueryResult (com.google.cloud.bigquery.QueryResult)1 Blob (com.google.cloud.storage.Blob)1 BlobId (com.google.cloud.storage.BlobId)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Maps (com.google.common.collect.Maps)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1