use of org.pmiops.workbench.db.model.CdrVersion in project workbench by all-of-us.
the class CohortBuilderControllerMockTest method getCriteriaByTypeAndParentIdIcd10.
@Test
public void getCriteriaByTypeAndParentIdIcd10() throws Exception {
org.pmiops.workbench.cdr.model.Criteria expectedCriteria = new org.pmiops.workbench.cdr.model.Criteria().id(1L).type("ICD10").name("DIAGNOSIS CODES").group(true).selectable(true).count("0").conceptId("0");
when(mockCdrVersionDao.findOne(1L)).thenReturn(new CdrVersion());
when(mockCriteriaDao.findCriteriaByTypeAndParentIdOrderByCodeAsc("ICD10", 0L)).thenReturn(Arrays.asList(expectedCriteria));
assertCriteria(controller.getCriteriaByTypeAndParentId(1L, "ICD10", 0L), new Criteria().id(1L).type("ICD10").name("DIAGNOSIS CODES").group(true).selectable(true).count(0L).conceptId(0L));
verify(mockCdrVersionDao).findOne(1L);
verify(mockCriteriaDao).findCriteriaByTypeAndParentIdOrderByCodeAsc("ICD10", 0L);
verifyNoMoreInteractions(mockCriteriaDao, mockCdrVersionDao);
}
use of org.pmiops.workbench.db.model.CdrVersion in project workbench by all-of-us.
the class CohortBuilderControllerMockTest method getCriteriaByTypeAndSubtypeDemographics.
@Test
public void getCriteriaByTypeAndSubtypeDemographics() throws Exception {
org.pmiops.workbench.cdr.model.Criteria expectedCriteria = new org.pmiops.workbench.cdr.model.Criteria().id(1L).type("DEMO").subtype("RACE").name("African American").group(false).selectable(true).count("100").conceptId("0");
when(mockCdrVersionDao.findOne(1L)).thenReturn(new CdrVersion());
when(mockCriteriaDao.findCriteriaByTypeAndSubtypeOrderByNameAsc("DEMO", "RACE")).thenReturn(Arrays.asList(expectedCriteria));
assertCriteria(controller.getCriteriaByTypeAndSubtype(1l, "DEMO", "RACE"), new Criteria().id(1L).type("DEMO").subtype("RACE").name("African American").group(false).selectable(true).count(100L).conceptId(0L));
verify(mockCdrVersionDao).findOne(1L);
verify(mockCriteriaDao).findCriteriaByTypeAndSubtypeOrderByNameAsc("DEMO", "RACE");
verifyNoMoreInteractions(mockCriteriaDao, mockCdrVersionDao);
}
use of org.pmiops.workbench.db.model.CdrVersion in project workbench by all-of-us.
the class CohortsControllerTest method setUp.
@Before
public void setUp() throws Exception {
User user = new User();
user.setEmail("bob@gmail.com");
user.setUserId(123L);
user.setDisabled(false);
user.setEmailVerificationStatus(EmailVerificationStatus.SUBSCRIBED);
user = userDao.save(user);
when(userProvider.get()).thenReturn(user);
cdrVersion = new CdrVersion();
cdrVersion.setName(CDR_VERSION_NAME);
cdrVersionDao.save(cdrVersion);
searchRequest = SearchRequests.males();
cohortCriteria = new Gson().toJson(searchRequest);
workspace = new Workspace();
workspace.setName(WORKSPACE_NAME);
workspace.setNamespace(WORKSPACE_NAMESPACE);
workspace.setDataAccessLevel(DataAccessLevel.PROTECTED);
workspace.setResearchPurpose(new ResearchPurpose());
workspace.setCdrVersionId(String.valueOf(cdrVersion.getCdrVersionId()));
CLOCK.setInstant(NOW);
WorkspacesController workspacesController = new WorkspacesController(workspaceService, cdrVersionDao, userDao, userProvider, fireCloudService, cloudStorageService, CLOCK, "https://api.blah.com", userService);
stubGetWorkspace(WORKSPACE_NAMESPACE, WORKSPACE_NAME, "bob@gmail.com", WorkspaceAccessLevel.OWNER);
workspace = workspacesController.createWorkspace(workspace).getBody();
this.cohortsController = new CohortsController(workspaceService, cohortDao, cdrVersionDao, cohortReviewDao, cohortMaterializationService, userProvider, CLOCK);
}
use of org.pmiops.workbench.db.model.CdrVersion in project workbench by all-of-us.
the class WorkspacesControllerTest method setUp.
@Before
public void setUp() {
User user = new User();
user.setEmail(LOGGED_IN_USER_EMAIL);
user.setUserId(123L);
user.setFreeTierBillingProjectName("TestBillingProject1");
user.setDisabled(false);
user.setEmailVerificationStatus(EmailVerificationStatus.SUBSCRIBED);
user = userDao.save(user);
when(userProvider.get()).thenReturn(user);
workspacesController.setUserProvider(userProvider);
cdrVersion = new CdrVersion();
cdrVersion.setName("1");
// set the db name to be empty since test cases currently
// run in the workbench schema only.
cdrVersion.setCdrDbName("");
cdrVersion = cdrVersionDao.save(cdrVersion);
cdrVersionId = Long.toString(cdrVersion.getCdrVersionId());
CLOCK.setInstant(NOW);
}
use of org.pmiops.workbench.db.model.CdrVersion in project workbench by all-of-us.
the class WorkspacesControllerTest method testCloneWorkspaceWithCohorts.
@Test
public void testCloneWorkspaceWithCohorts() throws Exception {
CdrVersionContext.setCdrVersion(cdrVersion);
Workspace workspace = createDefaultWorkspace();
workspace = workspacesController.createWorkspace(workspace).getBody();
Cohort c1 = createDefaultCohort("c1");
c1 = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), c1).getBody();
Cohort c2 = createDefaultCohort("c2");
c2 = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), c2).getBody();
stubBigQueryCohortCalls();
CreateReviewRequest reviewReq = new CreateReviewRequest();
reviewReq.setSize(1);
CohortReview cr1 = cohortReviewController.createCohortReview(workspace.getNamespace(), workspace.getId(), c1.getId(), cdrVersion.getCdrVersionId(), reviewReq).getBody();
reviewReq.setSize(2);
CohortReview cr2 = cohortReviewController.createCohortReview(workspace.getNamespace(), workspace.getId(), c2.getId(), cdrVersion.getCdrVersionId(), reviewReq).getBody();
stubGetWorkspace(workspace.getNamespace(), workspace.getName(), LOGGED_IN_USER_EMAIL, WorkspaceAccessLevel.OWNER);
CloneWorkspaceRequest req = new CloneWorkspaceRequest();
Workspace modWorkspace = new Workspace();
modWorkspace.setName("cloned");
modWorkspace.setNamespace("cloned-ns");
ResearchPurpose modPurpose = new ResearchPurpose();
modPurpose.setAncestry(true);
modWorkspace.setResearchPurpose(modPurpose);
req.setWorkspace(modWorkspace);
stubGetWorkspace(modWorkspace.getNamespace(), modWorkspace.getName(), LOGGED_IN_USER_EMAIL, WorkspaceAccessLevel.OWNER);
Workspace cloned = workspacesController.cloneWorkspace(workspace.getNamespace(), workspace.getId(), req).getBody().getWorkspace();
List<Cohort> cohorts = cohortsController.getCohortsInWorkspace(cloned.getNamespace(), cloned.getId()).getBody().getItems();
Map<String, Cohort> cohortsByName = Maps.uniqueIndex(cohorts, c -> c.getName());
assertThat(cohortsByName.keySet()).containsExactlyElementsIn(ImmutableSet.of("c1", "c2"));
assertThat(cohorts.stream().map(c -> c.getId()).collect(Collectors.toList())).containsNoneOf(c1.getId(), c2.getId());
CohortReview gotCr1 = cohortReviewController.getParticipantCohortStatuses(cloned.getNamespace(), cloned.getId(), cohortsByName.get("c1").getId(), cdrVersion.getCdrVersionId(), new ParticipantCohortStatuses().pageFilterType(PageFilterType.PARTICIPANTCOHORTSTATUSES)).getBody();
assertThat(gotCr1.getReviewSize()).isEqualTo(cr1.getReviewSize());
assertThat(gotCr1.getParticipantCohortStatuses()).isEqualTo(cr1.getParticipantCohortStatuses());
CohortReview gotCr2 = cohortReviewController.getParticipantCohortStatuses(cloned.getNamespace(), cloned.getId(), cohortsByName.get("c2").getId(), cdrVersion.getCdrVersionId(), new ParticipantCohortStatuses().pageFilterType(PageFilterType.PARTICIPANTCOHORTSTATUSES)).getBody();
assertThat(gotCr2.getReviewSize()).isEqualTo(cr2.getReviewSize());
assertThat(gotCr2.getParticipantCohortStatuses()).isEqualTo(cr2.getParticipantCohortStatuses());
assertThat(ImmutableSet.of(gotCr1.getCohortReviewId(), gotCr2.getCohortReviewId())).containsNoneOf(cr1.getCohortReviewId(), cr2.getCohortId());
}
Aggregations