use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortsControllerTest method testMaterializeCohortWithSpec.
@Test
public void testMaterializeCohortWithSpec() throws Exception {
Cohort cohort = createDefaultCohort();
cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
MaterializeCohortRequest request = new MaterializeCohortRequest();
request.setCohortSpec(cohort.getCriteria());
MaterializeCohortResponse response = new MaterializeCohortResponse();
when(cohortMaterializationService.materializeCohort(null, searchRequest, request)).thenReturn(response);
assertThat(cohortsController.materializeCohort(WORKSPACE_NAMESPACE, WORKSPACE_NAME, request).getBody()).isEqualTo(response);
}
use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortsControllerTest method testMaterializeCohortPageSizeTooLarge.
public void testMaterializeCohortPageSizeTooLarge() throws Exception {
Cohort cohort = createDefaultCohort();
cohort = cohortsController.createCohort(workspace.getNamespace(), workspace.getId(), cohort).getBody();
MaterializeCohortRequest request = new MaterializeCohortRequest();
request.setCohortName(cohort.getName());
request.setPageSize(CohortsController.MAX_PAGE_SIZE + 1);
MaterializeCohortRequest adjustedRequest = new MaterializeCohortRequest();
request.setCohortName(cohort.getName());
request.setPageSize(CohortsController.MAX_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);
}
use of org.pmiops.workbench.model.MaterializeCohortResponse 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);
}
use of org.pmiops.workbench.model.MaterializeCohortResponse 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);
}
use of org.pmiops.workbench.model.MaterializeCohortResponse 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);
}
Aggregations