/** * @see CohortService#getCohorts(String) */ @Test public void getCohorts_shouldMatchCohortsByPartialName() { executeDataSet(COHORT_XML); List<Cohort> matchedCohorts = service.getCohorts("Example"); assertEquals(2, matchedCohorts.size()); matchedCohorts = service.getCohorts("e Coh"); assertEquals(2, matchedCohorts.size()); matchedCohorts = service.getCohorts("hort"); assertEquals(2, matchedCohorts.size()); matchedCohorts = service.getCohorts("Examples"); assertEquals(0, matchedCohorts.size()); }
/** * @see CohortService#getCohorts(String) */ @Test public void getCohorts_shouldNeverReturnNull() { executeDataSet(COHORT_XML); String invalidFragment = "Not Present"; //data set should have two cohorts, one of which is voided List<Cohort> allCohorts = service.getCohorts(invalidFragment); assertNotNull(allCohorts); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(RequestContext) */ @Override protected NeedsPaging<Cohort> doSearch(RequestContext context) { List<Cohort> cohorts = Context.getCohortService().getCohorts(context.getParameter("q")); return new NeedsPaging<Cohort>(cohorts, context); }