Search in sources :

Example 11 with Cohort

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

the class CohortsControllerTest method testMaterializeCohortNamedCohort.

@Test
public void testMaterializeCohortNamedCohort() throws Exception {
    Cohort cohort = createDefaultCohort();
    cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
    MaterializeCohortRequest request = new MaterializeCohortRequest();
    request.setCohortName(cohort.getName());
    MaterializeCohortResponse response = new MaterializeCohortResponse();
    when(cohortMaterializationService.materializeCohort(null, searchRequest, request)).thenReturn(response);
    assertThat(cohortsController.materializeCohort(WORKSPACE_NAMESPACE, WORKSPACE_NAME, request).getBody()).isEqualTo(response);
}
Also used : Cohort(org.pmiops.workbench.model.Cohort) MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 12 with Cohort

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

the class WorkspacesControllerTest method createDefaultCohort.

public Cohort createDefaultCohort(String name) {
    Cohort cohort = new Cohort();
    cohort.setName(name);
    cohort.setCriteria(new Gson().toJson(SearchRequests.males()));
    return cohort;
}
Also used : Cohort(org.pmiops.workbench.model.Cohort) Gson(com.google.gson.Gson)

Example 13 with Cohort

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

the class CohortsControllerTest method testMaterializeCohortWithEverything.

@Test
public void testMaterializeCohortWithEverything() throws Exception {
    Cohort cohort = createDefaultCohort();
    cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
    MaterializeCohortRequest request = new MaterializeCohortRequest();
    request.setCohortName(cohort.getName());
    request.setPageSize(123);
    request.setPageToken("token");
    request.setCdrVersionName(CDR_VERSION_NAME);
    List<CohortStatus> statuses = ImmutableList.of(CohortStatus.INCLUDED, CohortStatus.NOT_REVIEWED);
    request.setStatusFilter(statuses);
    MaterializeCohortResponse response = new MaterializeCohortResponse();
    when(cohortMaterializationService.materializeCohort(null, searchRequest, request)).thenReturn(response);
    assertThat(cohortsController.materializeCohort(WORKSPACE_NAMESPACE, WORKSPACE_NAME, request).getBody()).isEqualTo(response);
}
Also used : CohortStatus(org.pmiops.workbench.model.CohortStatus) Cohort(org.pmiops.workbench.model.Cohort) MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 14 with Cohort

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

the class CohortsControllerTest method testMaterializeCohortNamedCohortWithReview.

@Test
public void testMaterializeCohortNamedCohortWithReview() throws Exception {
    Cohort cohort = createDefaultCohort();
    cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
    CohortReview cohortReview = new CohortReview();
    cohortReview.setCohortId(cohort.getId());
    cohortReview.setCdrVersionId(cdrVersion.getCdrVersionId());
    cohortReview.setReviewSize(2);
    cohortReview.setReviewedCount(2);
    cohortReviewDao.save(cohortReview);
    MaterializeCohortRequest request = new MaterializeCohortRequest();
    request.setCohortName(cohort.getName());
    MaterializeCohortResponse response = new MaterializeCohortResponse();
    when(cohortMaterializationService.materializeCohort(cohortReview, searchRequest, request)).thenReturn(response);
    assertThat(cohortsController.materializeCohort(WORKSPACE_NAMESPACE, WORKSPACE_NAME, request).getBody()).isEqualTo(response);
}
Also used : Cohort(org.pmiops.workbench.model.Cohort) MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) CohortReview(org.pmiops.workbench.db.model.CohortReview) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 15 with Cohort

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

the class CohortsControllerTest method createDefaultCohort.

public Cohort createDefaultCohort() {
    Cohort cohort = new Cohort();
    cohort.setName(COHORT_NAME);
    cohort.setCriteria(cohortCriteria);
    return cohort;
}
Also used : Cohort(org.pmiops.workbench.model.Cohort)

Aggregations

Cohort (org.pmiops.workbench.model.Cohort)19 Test (org.junit.Test)15 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)15 MaterializeCohortRequest (org.pmiops.workbench.model.MaterializeCohortRequest)12 MaterializeCohortResponse (org.pmiops.workbench.model.MaterializeCohortResponse)6 Gson (com.google.gson.Gson)2 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)2 NotFoundException (org.pmiops.workbench.exceptions.NotFoundException)2 WorkspaceAccessLevel (org.pmiops.workbench.model.WorkspaceAccessLevel)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 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)1 Timestamp (java.sql.Timestamp)1