@Override protected ConceptName getObjectByUuid(String uuid) { return Context.getConceptService().getConceptNameByUuid(uuid); } }
/** * @see ConceptService#getConceptNameByUuid(String) */ @Test public void getConceptNameByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { Assert.assertNull(Context.getConceptService().getConceptNameByUuid("some invalid uuid")); }
/** * @see ConceptService#getConceptNameByUuid(String) */ @Test public void getConceptNameByUuid_shouldFindObjectGivenValidUuid() { String uuid = "9bc5693a-f558-40c9-8177-145a4b119ca7"; ConceptName conceptName = Context.getConceptService().getConceptNameByUuid(uuid); Assert.assertEquals(1439, (int) conceptName.getConceptNameId()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) */ @Override public ConceptName getByUniqueId(String uuid) { return Context.getConceptService().getConceptNameByUuid(uuid); }
@Override public void setProperty(Object instance, String propertyName, Object value) throws ConversionException { if (propertyName.equals("specificName")) { ((CodedOrFreeText) instance).setSpecificName(Context.getConceptService().getConceptNameByUuid((String) value)); } else if (propertyName.equals("coded")) { ((CodedOrFreeText) instance).setCoded(Context.getConceptService().getConceptByUuid((String) value)); } else if (propertyName.equals("nonCoded")) { ((CodedOrFreeText) instance).setNonCoded((String) value); } }
@Override public ConceptName newObject() { return Context.getConceptService().getConceptNameByUuid(getUuidProperty()); }
@Test public void shouldEditAConceptName() throws Exception { ConceptName conceptName = service.getConceptNameByUuid(nameUuid); Assert.assertNotNull(conceptName); Assert.assertEquals("COUGH SYRUP", conceptName.getName()); String json = "{ \"name\":\"NEW TEST NAME\"}"; handle(newPostRequest(getURI() + "/" + getUuid(), json)); ConceptName updateConceptName = service.getConceptNameByUuid(nameUuid); //should have voided the old edited name Assert.assertTrue(updateConceptName.isVoided()); SimpleObject results2 = deserialize(handle(newGetRequest(getURI()))); List<Object> results2List = Util.getResultsList(results2); Assert.assertEquals(1, results2List.size()); //should have created a new one with the new name Assert.assertTrue(PropertyUtils.getProperty(results2List.get(0), "name").equals("NEW TEST NAME")); }