/** * @see org.openmrs.api.PersonService#getAllRelationships() */ @Override @Transactional(readOnly = true) public List<Relationship> getAllRelationships() throws APIException { return Context.getPersonService().getAllRelationships(false); }
/** * @see PersonService#getAllRelationships(null) */ @Test public void getAllRelationships_shouldReturnAllRelationshipIncludingVoidedWhenIncludeVoidedEqualsTrue() throws Exception { executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredRelationship.xml"); List<Relationship> relationships = Context.getPersonService().getAllRelationships(true); assertTrue("At least one element, otherwise no checking for voided will take place", relationships.size() > 0); boolean foundVoided = false; for (Relationship relationship : relationships) { if (relationship.getVoided()) { foundVoided = true; break; } } assertTrue("There should be voided relationship here", foundVoided); }
/** * @see PersonService#getAllRelationships() */ @Test public void getAllRelationships_shouldReturnAllUnvoidedRelationships() throws Exception { executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredRelationship.xml"); List<Relationship> relationships = Context.getPersonService().getAllRelationships(); assertTrue("At least one element, otherwise no checking for voided will take place", relationships.size() > 0); boolean foundVoided = false; for (Relationship relationship : relationships) { if (relationship.getVoided()) { foundVoided = true; break; } } Assert.assertFalse("There should be no voided relationship here", foundVoided); }
/** * @see PersonService#getAllRelationships(null) */ @Test public void getAllRelationships_shouldReturnAllRelationshipExcludingVoidedWhenIncludeVoidedEqualsFalse() throws Exception { executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredRelationship.xml"); List<Relationship> relationships = Context.getPersonService().getAllRelationships(false); assertTrue("At least one element, otherwise no checking for voided will take place", relationships.size() > 0); boolean foundVoided = false; for (Relationship relationship : relationships) { if (relationship.getVoided()) { foundVoided = true; break; } } Assert.assertFalse("There should be no voided relationship here", foundVoided); }
/** * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getAllCount() */ @Override public long getAllCount() { return service.getAllRelationships().size(); //not supported }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(java.lang.String, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<Relationship> doGetAll(RequestContext context) throws ResponseException { return new NeedsPaging<Relationship>(Context.getPersonService().getAllRelationships(), context); }
List<Relationship> allRels = personService.getAllRelationships(); for (Relationship r : allRels) { personService.voidRelationship(r, "Because of a JUnit test.");
List<Relationship> allRels = personService.getAllRelationships(); for (Relationship r : allRels) { personService.voidRelationship(r, "Because of a JUnit test.");
@Test public void shouldCreateARelationship() throws Exception { int originalCount = service.getAllRelationships().size(); String json = "{ \"personA\":\"da7f524f-27ce-4bb2-86d6-6d1d05312bd5\", \"relationshipType\":\"" + RestTestConstants1_8.RELATIONSHIP_TYPE_UUID + "\", \"personB\":" + "\"5946f880-b197-400b-9caa-a3c661d23041\"" + "}"; Object newRelationship = deserialize(handle(newPostRequest(getURI(), json))); Assert.assertNotNull(PropertyUtils.getProperty(newRelationship, "uuid")); Assert.assertEquals(originalCount + 1, service.getAllRelationships().size()); }
@Test public void shouldPurgeARelatonship() throws Exception { Assert.assertNotNull(service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID)); int originalCount = service.getAllRelationships().size(); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("purge", "true"))); Assert.assertNull(service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID)); Assert.assertEquals(originalCount - 1, service.getAllRelationships().size()); }