Search in sources :

Example 16 with MaterializeCohortRequest

use of org.pmiops.workbench.model.MaterializeCohortRequest 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 17 with MaterializeCohortRequest

use of org.pmiops.workbench.model.MaterializeCohortRequest 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 18 with MaterializeCohortRequest

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

the class CohortsControllerTest method testMaterializeCohortWorkspaceNotFound.

@Test(expected = NotFoundException.class)
public void testMaterializeCohortWorkspaceNotFound() throws Exception {
    Cohort cohort = createDefaultCohort();
    cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
    WorkspaceAccessLevel owner = WorkspaceAccessLevel.OWNER;
    String workspaceName = "badWorkspace";
    org.pmiops.workbench.firecloud.model.WorkspaceResponse fcResponse = new org.pmiops.workbench.firecloud.model.WorkspaceResponse();
    fcResponse.setAccessLevel(owner.toString());
    when(fireCloudService.getWorkspace(WORKSPACE_NAMESPACE, workspaceName)).thenReturn(fcResponse);
    when(workspaceService.getWorkspaceAccessLevel(WORKSPACE_NAMESPACE, workspaceName)).thenThrow(new NotFoundException());
    MaterializeCohortRequest request = new MaterializeCohortRequest();
    request.setCohortName(cohort.getName());
    cohortsController.materializeCohort(WORKSPACE_NAMESPACE, workspaceName, request);
}
Also used : Cohort(org.pmiops.workbench.model.Cohort) MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) NotFoundException(org.pmiops.workbench.exceptions.NotFoundException) WorkspaceAccessLevel(org.pmiops.workbench.model.WorkspaceAccessLevel) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 19 with MaterializeCohortRequest

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

the class CohortMaterializationServiceTest method testMaterializeCohortWithReviewJustNotReviewedFilter.

@Test
public void testMaterializeCohortWithReviewJustNotReviewedFilter() {
    MaterializeCohortRequest request = makeRequest(2);
    request.setStatusFilter(ImmutableList.of(CohortStatus.NOT_REVIEWED));
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(cohortReview, SearchRequests.allGenders(), request);
    assertPersonIds(response, 102246L);
    assertThat(response.getNextPageToken()).isNull();
}
Also used : MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Example 20 with MaterializeCohortRequest

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

the class CohortMaterializationServiceTest method testMaterializeCohortWithReviewNotReviewedAndIncludedFilter.

@Test
public void testMaterializeCohortWithReviewNotReviewedAndIncludedFilter() {
    MaterializeCohortRequest request = makeRequest(2);
    request.setStatusFilter(ImmutableList.of(CohortStatus.INCLUDED, CohortStatus.NOT_REVIEWED));
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(cohortReview, SearchRequests.allGenders(), request);
    assertPersonIds(response, 1L, 102246L);
    assertThat(response.getNextPageToken()).isNull();
}
Also used : MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Aggregations

MaterializeCohortRequest (org.pmiops.workbench.model.MaterializeCohortRequest)25 Test (org.junit.Test)21 MaterializeCohortResponse (org.pmiops.workbench.model.MaterializeCohortResponse)17 Cohort (org.pmiops.workbench.model.Cohort)12 BigQueryBaseTest (org.pmiops.workbench.api.BigQueryBaseTest)11 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)10 CohortReview (org.pmiops.workbench.db.model.CohortReview)1 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)1 NotFoundException (org.pmiops.workbench.exceptions.NotFoundException)1 CohortStatus (org.pmiops.workbench.model.CohortStatus)1 WorkspaceAccessLevel (org.pmiops.workbench.model.WorkspaceAccessLevel)1 PaginationToken (org.pmiops.workbench.utils.PaginationToken)1