Search in sources :

Example 11 with CohortReview

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

the class CohortReviewDaoTest method findCohortReviewByCohortIdAndCdrVersionId.

@Test
public void findCohortReviewByCohortIdAndCdrVersionId() throws Exception {
    CohortReview cohortReview = createCohortReview();
    cohortReviewDao.save(cohortReview);
    assertEquals(cohortReview, cohortReviewDao.findCohortReviewByCohortIdAndCdrVersionId(cohortReview.getCohortId(), cohortReview.getCdrVersionId()));
}
Also used : CohortReview(org.pmiops.workbench.db.model.CohortReview) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 12 with CohortReview

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

the class CohortReviewDaoTest method createCohortReview.

private CohortReview createCohortReview() {
    final Sort sort = new Sort(Sort.Direction.ASC, "status");
    final PageRequest pageRequest = new PageRequest(0, 25, sort);
    Gson gson = new Gson();
    return new CohortReview().cohortId(cohortId).cdrVersionId(CDR_VERSION_ID).creationTime(new Timestamp(Calendar.getInstance().getTimeInMillis())).lastModifiedTime(new Timestamp(Calendar.getInstance().getTimeInMillis())).matchedParticipantCount(100).reviewedCount(10);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Sort(org.springframework.data.domain.Sort) Gson(com.google.gson.Gson) CohortReview(org.pmiops.workbench.db.model.CohortReview) Timestamp(java.sql.Timestamp)

Example 13 with CohortReview

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

the class CohortReviewServiceImplTest method saveCohortReview.

@Test
public void saveCohortReview() throws Exception {
    CohortReview cohortReview = new CohortReview();
    when(cohortReviewDao.save(cohortReview)).thenReturn(cohortReview);
    assertEquals(cohortReview, cohortReviewService.saveCohortReview(cohortReview));
    verify(cohortReviewDao).save(cohortReview);
    verifyNoMoreMockInteractions();
}
Also used : CohortReview(org.pmiops.workbench.db.model.CohortReview) Test(org.junit.Test)

Example 14 with CohortReview

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

the class CohortReviewServiceImplTest method findCohortReviewCohortIdAndCdrVersionId.

@Test
public void findCohortReviewCohortIdAndCdrVersionId() throws Exception {
    long cohortReviewId = 1;
    long cdrVersionId = 1;
    CohortReview cohortReview = new CohortReview();
    when(cohortReviewDao.findCohortReviewByCohortIdAndCdrVersionId(cohortReviewId, cdrVersionId)).thenReturn(cohortReview);
    CohortReview actualCohortReview = cohortReviewService.findCohortReview(cohortReviewId, cdrVersionId);
    assertEquals(cohortReview, actualCohortReview);
    verify(cohortReviewDao).findCohortReviewByCohortIdAndCdrVersionId(cohortReviewId, cdrVersionId);
    verifyNoMoreMockInteractions();
}
Also used : CohortReview(org.pmiops.workbench.db.model.CohortReview) Test(org.junit.Test)

Example 15 with CohortReview

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

the class CohortReviewController method getParticipantCohortAnnotations.

@Override
public ResponseEntity<ParticipantCohortAnnotationListResponse> getParticipantCohortAnnotations(String workspaceNamespace, String workspaceId, Long cohortId, Long cdrVersionId, Long participantId) {
    CohortReview review = validateRequestAndSetCdrVersion(workspaceNamespace, workspaceId, cohortId, cdrVersionId, WorkspaceAccessLevel.READER);
    List<org.pmiops.workbench.db.model.ParticipantCohortAnnotation> annotations = cohortReviewService.findParticipantCohortAnnotations(review.getCohortReviewId(), participantId);
    ParticipantCohortAnnotationListResponse response = new ParticipantCohortAnnotationListResponse();
    response.setItems(annotations.stream().map(TO_CLIENT_PARTICIPANT_COHORT_ANNOTATION).collect(Collectors.toList()));
    return ResponseEntity.ok(response);
}
Also used : CohortReview(org.pmiops.workbench.db.model.CohortReview)

Aggregations

CohortReview (org.pmiops.workbench.db.model.CohortReview)23 org.pmiops.workbench.model (org.pmiops.workbench.model)7 Test (org.junit.Test)6 Cohort (org.pmiops.workbench.db.model.Cohort)6 ParticipantCohortStatus (org.pmiops.workbench.db.model.ParticipantCohortStatus)6 Workspace (org.pmiops.workbench.db.model.Workspace)6 Gson (com.google.gson.Gson)4 Timestamp (java.sql.Timestamp)4 PageRequest (org.pmiops.workbench.cohortreview.util.PageRequest)4 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)4 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)4 QueryResult (com.google.cloud.bigquery.QueryResult)3 CdrVersion (org.pmiops.workbench.db.model.CdrVersion)3 NotFoundException (org.pmiops.workbench.exceptions.NotFoundException)3 FieldValue (com.google.cloud.bigquery.FieldValue)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Before (org.junit.Before)2 ParticipantCohortStatusKey (org.pmiops.workbench.db.model.ParticipantCohortStatusKey)2 MaterializeCohortResponse (org.pmiops.workbench.model.MaterializeCohortResponse)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)1