/** @see {@link CohortService#getCohortsContainingPatient(Patient)} */ @Test @Verifies( value = "should return cohorts that have given patient", method = "getCohortsContainingPatient(Patient)") public void getCohortsContainingPatient_shouldReturnCohortsThatHaveGivenPatient() throws Exception { executeDataSet(COHORT_XML); Patient patientToAdd = new Patient(4); service.addPatientToCohort(service.getCohort(2), patientToAdd); assertTrue(service.getCohort(2).contains(patientToAdd)); List<Cohort> cohortsWithGivenPatient = service.getCohortsContainingPatient(patientToAdd); assertTrue(cohortsWithGivenPatient.contains(service.getCohort(2))); }
/** @see {@link CohortService#getCohortsContainingPatient(Patient)} */ @Test @Verifies( value = "should not return voided cohorts", method = "getCohortsContainingPatient(Patient)") public void getCohortsContainingPatient_shouldNotReturnVoidedCohorts() throws Exception { executeDataSet(COHORT_XML); // make sure we have two cohorts, the first of which is voided assertTrue(service.getCohort(1).isVoided()); assertFalse(service.getCohort(2).isVoided()); // add a patient to both cohorts Patient patientToAdd = new Patient(4); service.addPatientToCohort(service.getCohort(1), patientToAdd); service.addPatientToCohort(service.getCohort(2), patientToAdd); assertTrue(service.getCohort(1).contains(patientToAdd)); assertTrue(service.getCohort(2).contains(patientToAdd)); // call the method and it should not return the voided cohort List<Cohort> cohortsWithPatientAdded = service.getCohortsContainingPatient(patientToAdd); assertNotNull(cohortsWithPatientAdded); assertFalse(cohortsWithPatientAdded.contains(service.getCohort(1))); }