use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortMaterializationServiceTest method testMaterializeCohortObservationFilterObservationDatetimeGreaterThanOrEqualTo.
@Test
public void testMaterializeCohortObservationFilterObservationDatetimeGreaterThanOrEqualTo() {
TableQuery tableQuery = new TableQuery();
tableQuery.setTableName("observation");
tableQuery.setColumns(ImmutableList.of("observation_id"));
ColumnFilter columnFilter = new ColumnFilter();
columnFilter.setColumnName("observation_datetime");
columnFilter.setOperator(Operator.GREATER_THAN_OR_EQUAL_TO);
columnFilter.setValueDate("2009-12-03 05:00:00 UTC");
tableQuery.addFiltersItem(ImmutableList.of(columnFilter));
FieldSet fieldSet = new FieldSet();
fieldSet.setTableQuery(tableQuery);
MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.males(), makeRequest(fieldSet, 1000));
assertResults(response, ImmutableMap.of("observation_id", 5L));
assertThat(response.getNextPageToken()).isNull();
}
use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortMaterializationServiceTest method testMaterializeCohortPersonFieldSetPersonIdWithNumberLessThanOrEqualToFilter.
@Test
public void testMaterializeCohortPersonFieldSetPersonIdWithNumberLessThanOrEqualToFilter() {
TableQuery tableQuery = new TableQuery();
tableQuery.setTableName("person");
tableQuery.setColumns(ImmutableList.of("person_id"));
ColumnFilter filter = new ColumnFilter();
filter.setColumnName("person_id");
filter.setOperator(Operator.LESS_THAN_OR_EQUAL_TO);
filter.setValueNumber(new BigDecimal(2L));
tableQuery.addFiltersItem(ImmutableList.of(filter));
FieldSet fieldSet = new FieldSet();
fieldSet.setTableQuery(tableQuery);
MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), makeRequest(fieldSet, 1000));
assertPersonIds(response, 1L, 2L);
assertThat(response.getNextPageToken()).isNull();
}
use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortMaterializationServiceTest method testMaterializeCohortPersonFieldSetPersonIdWithNumbersFilter.
@Test
public void testMaterializeCohortPersonFieldSetPersonIdWithNumbersFilter() {
TableQuery tableQuery = new TableQuery();
tableQuery.setTableName("person");
tableQuery.setColumns(ImmutableList.of("person_id"));
ColumnFilter filter = new ColumnFilter();
filter.setColumnName("person_id");
filter.setOperator(Operator.IN);
filter.setValueNumbers(ImmutableList.of(new BigDecimal(1L), new BigDecimal(2L)));
tableQuery.addFiltersItem(ImmutableList.of(filter));
FieldSet fieldSet = new FieldSet();
fieldSet.setTableQuery(tableQuery);
MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), makeRequest(fieldSet, 1000));
assertPersonIds(response, 1L, 2L);
assertThat(response.getNextPageToken()).isNull();
}
use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortMaterializationServiceTest method testMaterializeCohortObservationFilterObservationDatetimeGreaterThan.
@Test
public void testMaterializeCohortObservationFilterObservationDatetimeGreaterThan() {
TableQuery tableQuery = new TableQuery();
tableQuery.setTableName("observation");
tableQuery.setColumns(ImmutableList.of("observation_id"));
ColumnFilter columnFilter = new ColumnFilter();
columnFilter.setColumnName("observation_datetime");
columnFilter.setOperator(Operator.GREATER_THAN);
columnFilter.setValueDate("2009-12-03 04:59:59 UTC");
tableQuery.addFiltersItem(ImmutableList.of(columnFilter));
FieldSet fieldSet = new FieldSet();
fieldSet.setTableQuery(tableQuery);
MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.males(), makeRequest(fieldSet, 1000));
assertResults(response, ImmutableMap.of("observation_id", 5L));
assertThat(response.getNextPageToken()).isNull();
}
use of org.pmiops.workbench.model.MaterializeCohortResponse 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
}
}
Aggregations