Search in sources :

Example 1 with Cohort

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

the class CohortsControllerTest method testMaterializeCohortCdrVersionNotFound.

@Test(expected = NotFoundException.class)
public void testMaterializeCohortCdrVersionNotFound() throws Exception {
    Cohort cohort = createDefaultCohort();
    cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
    MaterializeCohortRequest request = new MaterializeCohortRequest();
    request.setCohortName(cohort.getName());
    request.setCdrVersionName("badCdrVersion");
    cohortsController.materializeCohort(WORKSPACE_NAMESPACE, WORKSPACE_NAME, request);
}
Also used : Cohort(org.pmiops.workbench.model.Cohort) MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 2 with Cohort

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

the class CohortsControllerTest method testMaterializeCohortPageSizeZero.

public void testMaterializeCohortPageSizeZero() throws Exception {
    Cohort cohort = createDefaultCohort();
    cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
    MaterializeCohortRequest request = new MaterializeCohortRequest();
    request.setCohortName(cohort.getName());
    request.setPageSize(0);
    MaterializeCohortRequest adjustedRequest = new MaterializeCohortRequest();
    request.setCohortName(cohort.getName());
    request.setPageSize(CohortsController.DEFAULT_PAGE_SIZE);
    MaterializeCohortResponse response = new MaterializeCohortResponse();
    when(cohortMaterializationService.materializeCohort(null, searchRequest, adjustedRequest)).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)

Example 3 with Cohort

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

the class CohortsControllerTest method testMaterializeCohortBadCohortSpec.

@Test(expected = BadRequestException.class)
public void testMaterializeCohortBadCohortSpec() throws Exception {
    Cohort cohort = createDefaultCohort();
    cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
    MaterializeCohortRequest request = new MaterializeCohortRequest();
    request.setCohortSpec("badSpec");
    cohortsController.materializeCohort(WORKSPACE_NAMESPACE, WORKSPACE_NAME, request);
}
Also used : Cohort(org.pmiops.workbench.model.Cohort) MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 4 with Cohort

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

the class CohortsControllerTest method testMaterializeCohortNoSpecOrCohortName.

@Test(expected = BadRequestException.class)
public void testMaterializeCohortNoSpecOrCohortName() throws Exception {
    Cohort cohort = createDefaultCohort();
    cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
    MaterializeCohortRequest request = new MaterializeCohortRequest();
    cohortsController.materializeCohort(WORKSPACE_NAMESPACE, WORKSPACE_NAME, request);
}
Also used : Cohort(org.pmiops.workbench.model.Cohort) MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 5 with Cohort

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

the class CohortsControllerTest method testGetCohortsInWorkspace.

@Test
public void testGetCohortsInWorkspace() throws Exception {
    Cohort c1 = createDefaultCohort();
    c1.setName("c1");
    c1 = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), c1).getBody();
    Cohort c2 = createDefaultCohort();
    c2.setName("c2");
    c2 = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), c2).getBody();
    List<Cohort> cohorts = cohortsController.getCohortsInWorkspace(workspace.getNamespace(), workspace.getId()).getBody().getItems();
    assertThat(cohorts).containsExactlyElementsIn(ImmutableSet.of(c1, c2));
}
Also used : Cohort(org.pmiops.workbench.model.Cohort) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

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