@Override public Model getUPDATEModel(Representation rep) { return getCREATEModel(rep); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() */ @Override public DelegatingResourceDescription getUpdatableProperties() { return getCreatableProperties(); }
@Test public void setValue_shouldSetThePassedValueForNonAttributableClasses() throws ClassNotFoundException { PersonAttributeType type = personService.getPersonAttributeTypeByName("Race"); PersonAttribute attribute = new PersonAttribute(type, null); Assert.assertNull(attribute.getValue()); Assert.assertEquals("java.lang.String", type.getFormat()); Assert.assertFalse(Attributable.class.isAssignableFrom(Context.loadClass(type.getFormat()))); resource.setValue(attribute, "arab"); Assert.assertEquals("arab", attribute.getValue()); } }
@Test public void shouldCreatePersonAttribute() throws Exception { SimpleObject created = (SimpleObject) resource.create("da7f524f-27ce-4bb2-86d6-6d1d05312bd5", personAttributeSimpleObject, new RequestContext()); Assert.assertEquals("Bangalore", created.get("value")); }
@Test public void setValue_shouldSetPassedValueIfCouldNotBeConvertedToAttributable() throws ClassNotFoundException { PersonAttributeType type = new PersonAttributeType(); type.setFormat("org.openmrs.Location"); type.setName("Second Home"); type.setDescription("Testing Attributable domain objects"); type.setSortWeight(5.5); type.setSearchable(false); type = personService.savePersonAttributeType(type); String nonExistenceLocationUuid = "this-uuid-does-not-exist-of-course"; PersonAttribute attribute = new PersonAttribute(type, null); Assert.assertNull(attribute.getValue()); Assert.assertTrue(Attributable.class.isAssignableFrom(Context.loadClass(type.getFormat()))); resource.setValue(attribute, nonExistenceLocationUuid); Assert.assertEquals(nonExistenceLocationUuid, attribute.getValue()); }
@Test public void setValue_shouldSetProperAttributableIdIfFound() { PersonAttributeType type = new PersonAttributeType(); type.setFormat("org.openmrs.Location"); type.setName("Second Home"); type.setDescription("Testing Attributable domain objects"); type.setSortWeight(5.5); type.setSearchable(false); type = personService.savePersonAttributeType(type); //Get the first location in from the list Location location = locationService.getAllLocations().get(0); PersonAttribute attribute = new PersonAttribute(type, null); attribute.setAttributeType(type); Assert.assertNull(attribute.getValue()); resource.setValue(attribute, location.getUuid()); Assert.assertEquals(location.getUuid(), attribute.getValue()); }