@Override protected ConceptSource getObjectByUuid(String uuid) { return Context.getConceptService().getConceptSourceByUuid(uuid); } }
/** * @see ConceptService#getConceptSourceByUuid(String) */ @Test public void getConceptSourceByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { Assert.assertNull(Context.getConceptService().getConceptSourceByUuid("some invalid uuid")); }
/** * @see ConceptService#getConceptSourceByUuid(String) */ @Test public void getConceptSourceByUuid_shouldFindObjectGivenValidUuid() { String uuid = "75f5b378-5065-11de-80cb-001e378eb67e"; ConceptSource conceptSource = Context.getConceptService().getConceptSourceByUuid(uuid); Assert.assertEquals(3, (int) conceptSource.getConceptSourceId()); }
/** * Fetches a conceptSource 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 conceptSource name * * @see DelegatingCrudResource#getByUniqueId(java.lang.String) */ @Override public ConceptSource getByUniqueId(String uuid) { ConceptSource conceptSource = Context.getConceptService().getConceptSourceByUuid(uuid); //We assume the caller was fetching by name if (conceptSource == null) conceptSource = Context.getConceptService().getConceptSourceByName(uuid); return conceptSource; }
ConceptSource source = null; if (StringUtils.isNotBlank(sourceUuid)) { source = conceptService.getConceptSourceByUuid(sourceUuid); if (source == null) { throw new ObjectNotFoundException();
ConceptSource source = null; if (StringUtils.isNotBlank(sourceUuid)) { source = conceptService.getConceptSourceByUuid(sourceUuid); if (source == null) { throw new ObjectNotFoundException();
@Override public ConceptSource newObject() { return Context.getConceptService().getConceptSourceByUuid(getUuidProperty()); }
@Override public ConceptSource newObject() { return Context.getConceptService().getConceptSourceByUuid(getUuidProperty()); }
@Test public void shouldEditAConceptSource() throws Exception { final String newName = "updated name"; SimpleObject conceptSource = new SimpleObject(); conceptSource.add("name", newName); String json = new ObjectMapper().writeValueAsString(conceptSource); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); Assert.assertEquals(newName, service.getConceptSourceByUuid(getUuid()).getName()); }
@Test public void shouldPurgeAConceptSource() throws Exception { Assert.assertNotNull(service.getConceptSourceByUuid(getUuid())); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("purge", "true"); handle(req); Assert.assertNull(service.getConceptSourceByUuid(getUuid())); }
@Test public void shouldEditAConceptSource() throws Exception { final String newName = "updated name"; SimpleObject conceptSource = new SimpleObject(); conceptSource.add("name", newName); String json = new ObjectMapper().writeValueAsString(conceptSource); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); Assert.assertEquals(newName, service.getConceptSourceByUuid(getUuid()).getName()); }
@Test public void shouldPurgeAConceptSource() throws Exception { Assert.assertNotNull(service.getConceptSourceByUuid(getUuid())); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("purge", "true"); handle(req); Assert.assertNull(service.getConceptSourceByUuid(getUuid())); }
ConceptSource conceptSource = conceptService.getConceptSourceByUuid(source); if (conceptSource == null) { conceptSource = conceptService.getConceptSourceByName(source);
@Test public void shouldRetireAConceptSource() throws Exception { Assert.assertEquals(false, service.getConceptSourceByUuid(getUuid()).isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("!purge", ""); final String reason = "none"; req.addParameter("reason", reason); handle(req); Assert.assertEquals(true, service.getConceptSourceByUuid(getUuid()).isRetired()); Assert.assertEquals(reason, service.getConceptSourceByUuid(getUuid()).getRetireReason()); }
@Test public void shouldGetAConceptSourceByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); ConceptSource conceptSource = service.getConceptSourceByUuid(getUuid()); Assert.assertEquals(conceptSource.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(conceptSource.getName(), PropertyUtils.getProperty(result, "name")); Assert.assertEquals(conceptSource.getHl7Code(), PropertyUtils.getProperty(result, "hl7Code")); Assert.assertEquals(conceptSource.getDescription(), PropertyUtils.getProperty(result, "description")); }
@Test public void shouldRetireAConceptSource() throws Exception { Assert.assertEquals(false, service.getConceptSourceByUuid(getUuid()).isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("!purge", ""); final String reason = "none"; req.addParameter("reason", reason); handle(req); Assert.assertEquals(true, service.getConceptSourceByUuid(getUuid()).isRetired()); Assert.assertEquals(reason, service.getConceptSourceByUuid(getUuid()).getRetireReason()); }
@Test public void shouldGetAConceptSourceByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); ConceptSource conceptSource = service.getConceptSourceByUuid(getUuid()); Assert.assertEquals(conceptSource.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(conceptSource.getName(), PropertyUtils.getProperty(result, "name")); Assert.assertEquals(conceptSource.getHl7Code(), PropertyUtils.getProperty(result, "hl7Code")); Assert.assertEquals(conceptSource.getDescription(), PropertyUtils.getProperty(result, "description")); }
conceptSource = conceptService.getConceptSourceByUuid(source); if (conceptSource == null) { conceptSource = conceptService.getConceptSourceByName(source);