@Override protected PersonAttributeType getObjectByUuid(String uuid) { return Context.getPersonService().getPersonAttributeTypeByUuid(uuid); } }
/** * @see PersonService#getPersonAttributeTypeByUuid(String) */ @Test public void getPersonAttributeTypeByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() throws Exception { Assert.assertNull(Context.getPersonService().getPersonAttributeTypeByUuid("some invalid uuid")); }
/** * @see PersonService#getPersonAttributeTypeByUuid(String) */ @Test public void getPersonAttributeTypeByUuid_shouldFindObjectGivenValidUuid() throws Exception { String uuid = "b3b6d540-a32e-44c7-91b3-292d97667518"; PersonAttributeType personAttributeType = Context.getPersonService().getPersonAttributeTypeByUuid(uuid); Assert.assertEquals(1, (int) personAttributeType.getPersonAttributeTypeId()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) */ @Override public PersonAttributeType getByUniqueId(String uniqueId) { return service().getPersonAttributeTypeByUuid(uniqueId); }
/** * Sets the attribute type for a person attribute. * * @param instance * @param attributeType * @throws org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException */ @PropertySetter("attributeType") public void setAttributeType(PersonAttribute instance, PersonAttributeType attributeType) { instance.setAttributeType(Context.getPersonService().getPersonAttributeTypeByUuid(attributeType.getUuid())); }
@Override public PersonAttributeType newObject() { return Context.getPersonService().getPersonAttributeTypeByUuid(getUuidProperty()); }
@Override public PersonAttributeType newObject() { return Context.getPersonService().getPersonAttributeTypeByUuid(getUuidProperty()); }
/** * Sets attributes on the given person. * * @param instance * @param attrs */ @PropertySetter("attributes") public static void setAttributes(Person instance, List<PersonAttribute> attrs) { for (PersonAttribute attr : attrs) { PersonAttribute existingAttribute = instance.getAttribute(Context.getPersonService() .getPersonAttributeTypeByUuid(attr.getAttributeType().getUuid())); if (existingAttribute != null) { if (attr.getValue() == null) { instance.removeAttribute(existingAttribute); } else { existingAttribute.setValue(attr.getValue()); } } else { instance.addAttribute(attr); } } }
/** * @see PersonAttributeTypeController#retirePersonAttributeType(PersonAttributeType,String,WebRequest) * @throws Exception * @verifies void a person attribute type */ @Test public void retirePersonAttributeType_shouldRetireAPersonAttributeType() throws Exception { final String nonRetiredAttribute = "a0f5521c-dbbd-4c10-81b2-1b7ab18330df"; PersonAttributeType obj = service.getPersonAttributeTypeByUuid(nonRetiredAttribute); Assert.assertNotNull(obj); Assert.assertFalse(obj.isRetired()); MockHttpServletRequest delRequest = request(RequestMethod.DELETE, getURI() + "/" + nonRetiredAttribute); delRequest.addParameter("!purge", ""); delRequest.addParameter("reason", "unit test"); handle(delRequest); obj = service.getPersonAttributeTypeByUuid(nonRetiredAttribute); Assert.assertNotNull(obj); Assert.assertTrue(obj.isRetired()); Assert.assertTrue("unit test".equals(obj.getRetireReason())); }
/** * @see PersonAttributeTypeController#updatePersonAttributeType(PersonAttributeType,SimpleObject,WebRequest) * @throws Exception * @verifies change a property on a person */ @Test public void updatePersonAttributeType_shouldChangeAPropertyOnAPersonAttributeType() throws Exception { final String newDescription = "Updated description"; PersonAttributeType obj = service.getPersonAttributeTypeByUuid(getUuid()); Assert.assertNotNull(obj); Assert.assertFalse(newDescription.equals(obj.getDescription())); Util.log("Old PersonAttributeType Description: ", obj.getDescription()); String json = "{\"description\":\"Updated description\"}"; MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); PersonAttributeType editedAttr = service.getPersonAttributeTypeByUuid(getUuid()); Assert.assertNotNull(editedAttr); Assert.assertEquals(newDescription, editedAttr.getDescription()); Util.log("Edited PersonAttributeType Description: ", editedAttr.getDescription()); }