/** * @see CohortService#getCohortMembershipByUuid(String) */ @Test public void getCohortMembershipByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { assertNull(Context.getCohortService().getCohortMembershipByUuid("some invalid uuid")); }
/** * @see CohortService#getCohortMembershipByUuid(String) */ @Test public void getCohortMembershipByUuid_shouldFindObjectGivenValidUuid() { executeDataSet(COHORT_XML); String uuid = "v9a9m5i6-17e6-407c-9d4v-hbi8teu9lf0f"; CohortMembership byUuid = Context.getCohortService().getCohortMembershipByUuid(uuid); Assert.assertEquals(1, (int) byUuid.getId()); }
@Test public void purgeCohortMembership_shouldRemoveMembershipFromCohort() { executeDataSet(COHORT_XML); CohortMembership toPurge = service.getCohortMembershipByUuid("v9a9m5i6-17e6-407c-9d4v-hbi8teu9lf0f"); Cohort owner = toPurge.getCohort(); service.purgeCohortMembership(toPurge); Context.flushSession(); assertNull(service.getCohortMembershipByUuid("v9a9m5i6-17e6-407c-9d4v-hbi8teu9lf0f")); assertFalse(service.getCohort(owner.getId()).contains(toPurge.getPatientId())); }
@Override public CohortMembership newObject() { return cohortService.getCohortMembershipByUuid(RestTestConstants2_1.COHORT_MEMBERSHIP_UUID); }
@Override public CohortMembership getByUniqueId(String uniqueId) { return Context.getCohortService().getCohortMembershipByUuid(uniqueId); }
@Test public void shouldVoid() throws Exception { MockHttpServletRequest request = newDeleteRequest(getURI() + "/" + getUuid()); handle(request); assertTrue(cohortService.getCohortMembershipByUuid(RestTestConstants2_1.COHORT_MEMBERSHIP_UUID).getVoided()); }
@Test public void shouldPurge() throws Exception { MockHttpServletRequest request = newDeleteRequest(getURI() + "/" + getUuid()); request.setParameter("purge", "true"); handle(request); assertNull(cohortService.getCohortMembershipByUuid(RestTestConstants2_1.COHORT_MEMBERSHIP_UUID)); }