@Override protected EncounterType getObjectByUuid(String uuid) { return Context.getEncounterService().getEncounterTypeByUuid(uuid); } }
/** * @see EncounterService#getEncounterTypeByUuid(String) */ @Test public void getEncounterTypeByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { Assert.assertNull(Context.getEncounterService().getEncounterTypeByUuid("some invalid uuid")); }
/** * @see EncounterService#getEncounterTypeByUuid(String) */ @Test public void getEncounterTypeByUuid_shouldFindObjectGivenValidUuid() { String uuid = "02c533ab-b74b-4ee4-b6e5-ffb6d09a0ac8"; EncounterType encounterType = Context.getEncounterService().getEncounterTypeByUuid(uuid); Assert.assertEquals(6, (int) encounterType.getEncounterTypeId()); }
/** * Fetches a encounterType 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 encounterType name * * @see DelegatingCrudResource#getByUniqueId(java.lang.String) */ @Override public EncounterType getByUniqueId(String uuid) { EncounterType encounterType = Context.getEncounterService().getEncounterTypeByUuid(uuid); //We assume the caller was fetching by name if (encounterType == null) encounterType = Context.getEncounterService().getEncounterType(uuid); return encounterType; }
@Override public EncounterType newObject() { return Context.getEncounterService().getEncounterTypeByUuid(getUuidProperty()); }
encounterType = Context.getEncounterService().getEncounterTypeByUuid(id);
@Test public void shouldPurgeAEncounterType() throws Exception { final String uuid = "02c533ab-b74b-4ee4-b6e5-ffb6d09a0ac8"; assertNotNull(service.getEncounterTypeByUuid(uuid)); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + uuid); req.addParameter("purge", "true"); handle(req); assertNull(service.getEncounterTypeByUuid(uuid)); }
@Test public void shouldEditingAnEncounterType() throws Exception { final String newName = "updated name"; SimpleObject encounterType = new SimpleObject(); encounterType.add("name", newName); String json = new ObjectMapper().writeValueAsString(encounterType); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); assertEquals(newName, service.getEncounterTypeByUuid(getUuid()).getName()); }
@Test public void shouldRetireAEncounterType() throws Exception { assertEquals(false, service.getEncounterTypeByUuid(getUuid()).isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("!purge", ""); final String reason = "none"; req.addParameter("reason", reason); handle(req); assertEquals(true, service.getEncounterTypeByUuid(getUuid()).isRetired()); assertEquals(reason, service.getEncounterTypeByUuid(getUuid()).getRetireReason()); }
@Test public void shouldGetAnEncounterTypeByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); EncounterType encounterType = service.getEncounterTypeByUuid(getUuid()); assertEquals(encounterType.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertEquals(encounterType.getName(), PropertyUtils.getProperty(result, "name")); assertEquals(encounterType.getDescription(), PropertyUtils.getProperty(result, "description")); }