@Override protected PersonAttribute getObjectByUuid(String uuid) { return Context.getPersonService().getPersonAttributeByUuid(uuid); } }
/** * @see PersonService#getPersonAttributeByUuid(String) */ @Test public void getPersonAttributeByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() throws Exception { Assert.assertNull(Context.getPersonService().getPersonAttributeByUuid("some invalid uuid")); }
/** * @see PersonService#getPersonAttributeByUuid(String) */ @Test public void getPersonAttributeByUuid_shouldFindObjectGivenValidUuid() throws Exception { String uuid = "0768f3da-b692-44b7-a33f-abf2c450474e"; PersonAttribute person = Context.getPersonService().getPersonAttributeByUuid(uuid); Assert.assertEquals(1, (int) person.getPersonAttributeId()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) */ @Override public PersonAttribute getByUniqueId(String uniqueId) { return Context.getPersonService().getPersonAttributeByUuid(uniqueId); }
@Test public void shouldVoidAttribute() throws Exception { PersonAttribute personAttribute = service.getPersonAttributeByUuid(getUuid()); assertThat(personAttribute.isVoided(), is(false)); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("reason", "unit test"))); personAttribute = service.getPersonAttributeByUuid(getUuid()); assertThat(personAttribute.isVoided(), is(true)); assertThat(personAttribute.getVoidReason(), is("unit test")); }
@Test public void shouldEditAttribute() throws Exception { String json = "{ \"attributeType\":\"54fc8400-1683-4d71-a1ac-98d40836ff7c\" }"; PersonAttribute personAttribute = service.getPersonAttributeByUuid(getUuid()); assertThat(personAttribute.getAttributeType().getName(), is("Race")); handle(newPostRequest(getURI() + "/" + getUuid(), json)); personAttribute = service.getPersonAttributeByUuid(getUuid()); assertThat(personAttribute.getAttributeType().getName(), is("Birthplace")); }
@Test public void shouldPurgeAttribute() throws Exception { handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("purge", ""))); assertThat(service.getPersonAttributeByUuid(getUuid()), nullValue()); }