/** * @see PersonService#getRelationshipTypeByUuid(String) */ @Test public void getRelationshipTypeByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() throws Exception { Assert.assertNull(Context.getPersonService().getRelationshipTypeByUuid("some invalid uuid")); }
/** * @see PersonService#getRelationshipTypeByUuid(String) */ @Test public void getRelationshipTypeByUuid_shouldFindObjectGivenValidUuid() throws Exception { String uuid = "6d9002ea-a96b-4889-af78-82d48c57a110"; RelationshipType relationshipType = Context.getPersonService().getRelationshipTypeByUuid(uuid); Assert.assertEquals(1, (int) relationshipType.getRelationshipTypeId()); }
/** * Fetches a relationshipType by uuid, if no match is found, it tries to look up one with a * matching name with the assumption that the passed parameter is a relationshipType name * * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getByUniqueId(java.lang.String) */ @Override public RelationshipType getByUniqueId(String uuid) { RelationshipType relationshipType = Context.getPersonService().getRelationshipTypeByUuid(uuid); if (relationshipType == null) { List<RelationshipType> relationshipTypes = Context.getPersonService().getAllRelationshipTypes(); for (RelationshipType possibleRelationshipType : relationshipTypes) { if (possibleRelationshipType.getaIsToB().equalsIgnoreCase(uuid) || possibleRelationshipType.getbIsToA().equalsIgnoreCase(uuid)) { relationshipType = possibleRelationshipType; break; } } } return relationshipType; }
RelationshipType r = Context.getPersonService().getRelationshipTypeByUuid(rel); if (r == null) { try {
@Override public RelationshipType newObject() { return Context.getPersonService().getRelationshipTypeByUuid(getUuidProperty()); }
@Test public void shouldPurgeARelationshipType() throws Exception { String uuid = "2a5f4ff4-a179-4b8a-aa4c-40f71956eabc"; Assert.assertNotNull(service.getRelationshipTypeByUuid(uuid)); int originalCount = service.getAllRelationshipTypes().size(); handle(newDeleteRequest(getURI() + "/" + uuid, new Parameter("purge", "true"))); Assert.assertNull(service.getRelationshipTypeByUuid(uuid)); Assert.assertEquals(originalCount - 1, service.getAllRelationshipTypes().size()); }
@Test public void shouldRetireARelationshipType() throws Exception { RelationshipType relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID); Assert.assertFalse(relationshipType.isRetired()); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("reason", "test reason"))); relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID); Assert.assertTrue(relationshipType.isRetired()); Assert.assertEquals("test reason", relationshipType.getRetireReason()); }
if (personService.getRelationshipTypeByUuid(relation) != null) { relationshipType = personService.getRelationshipTypeByUuid(relation); } else { List<RelationshipType> relationshipTypes = personService.getAllRelationshipTypes();
@Test public void shouldEditARelationshipType() throws Exception { String json = "{ \"aIsToB\":\"Teacher\",\"bIsToA\":\"Student\",\"weight\":\"0\",\"description\":\"new description\"}"; handle(newPostRequest(getURI() + "/" + getUuid(), json)); RelationshipType updated = service.getRelationshipTypeByUuid(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID); Assert.assertNotNull(updated); Assert.assertEquals("new description", updated.getDescription()); }