Search in sources :

Example 21 with MaterializeCohortRequest

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

the class CohortMaterializationServiceTest method testMaterializeCohortWithReviewIncludedAndExcludedFilter.

@Test
public void testMaterializeCohortWithReviewIncludedAndExcludedFilter() {
    MaterializeCohortRequest request = makeRequest(2);
    request.setStatusFilter(ImmutableList.of(CohortStatus.EXCLUDED, CohortStatus.INCLUDED));
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(cohortReview, SearchRequests.allGenders(), request);
    assertPersonIds(response, 1L, 2L);
    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 22 with MaterializeCohortRequest

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

the class CohortMaterializationServiceTest method testMaterializeCohortWithReviewNotReviewedAndExcludedFilter.

@Test
public void testMaterializeCohortWithReviewNotReviewedAndExcludedFilter() {
    MaterializeCohortRequest request = makeRequest(2);
    request.setStatusFilter(ImmutableList.of(CohortStatus.EXCLUDED, CohortStatus.NOT_REVIEWED));
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(cohortReview, SearchRequests.allGenders(), request);
    assertPersonIds(response, 2L, 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 23 with MaterializeCohortRequest

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

the class CohortMaterializationServiceTest method testMaterializeCohortWithReviewNullStatusFilter.

@Test
public void testMaterializeCohortWithReviewNullStatusFilter() {
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(cohortReview, SearchRequests.allGenders(), makeRequest(2));
    // With a null status filter, everyone is returned.
    assertPersonIds(response, 1L, 2L);
    assertThat(response.getNextPageToken()).isNotNull();
    MaterializeCohortRequest request = makeRequest(2);
    request.setPageToken(response.getNextPageToken());
    MaterializeCohortResponse response2 = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), request);
    assertPersonIds(response2, 102246L);
    assertThat(response2.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 24 with MaterializeCohortRequest

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

the class CohortMaterializationServiceTest method testMaterializeCohortPaging.

@Test
public void testMaterializeCohortPaging() {
    MaterializeCohortRequest request = makeRequest(2);
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), request);
    assertPersonIds(response, 1L, 2L);
    assertThat(response.getNextPageToken()).isNotNull();
    request.setPageToken(response.getNextPageToken());
    MaterializeCohortResponse response2 = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), request);
    assertPersonIds(response2, 102246L);
    assertThat(response2.getNextPageToken()).isNull();
    try {
        // Pagination token doesn't match, this should fail.
        cohortMaterializationService.materializeCohort(null, SearchRequests.males(), request);
        fail("Exception expected");
    } catch (BadRequestException e) {
    // expected
    }
    PaginationToken token = PaginationToken.fromBase64(response.getNextPageToken());
    PaginationToken invalidToken = new PaginationToken(-1L, token.getParameterHash());
    request.setPageToken(invalidToken.toBase64());
    try {
        // Pagination token doesn't match, this should fail.
        cohortMaterializationService.materializeCohort(null, SearchRequests.males(), request);
        fail("Exception expected");
    } catch (BadRequestException e) {
    // expected
    }
}
Also used : MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) BadRequestException(org.pmiops.workbench.exceptions.BadRequestException) PaginationToken(org.pmiops.workbench.utils.PaginationToken) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Example 25 with MaterializeCohortRequest

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

the class CohortMaterializationServiceTest method testMaterializeCohortWithReviewJustIncludedFilter.

@Test
public void testMaterializeCohortWithReviewJustIncludedFilter() {
    MaterializeCohortRequest request = makeRequest(2);
    request.setStatusFilter(ImmutableList.of(CohortStatus.INCLUDED));
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(cohortReview, SearchRequests.allGenders(), request);
    assertPersonIds(response, 1L);
    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