Dictionary extends Metadata.Concept { public static Concept getConcept(String identifier) { Concept concept; if (identifier.contains(":")) { String[] tokens = identifier.split(":"); concept = Context.getConceptService().getConceptByMapping(tokens[1].trim(), tokens[0].trim()); } else { concept = Context.getConceptService().getConceptByUuid(identifier); } if (concept == null) { throw new MissingMetadataException(Concept.class, identifier); } if (concept.getDatatype().isNumeric() && !(concept instanceof ConceptNumeric)) { concept = Context.getConceptService().getConceptNumeric(concept.getId()); if (concept == null) { throw new MissingMetadataException(ConceptNumeric.class, identifier); } } return concept; }  static Concept getConcept(String identifier); static List<Concept> getConcepts(String... identifiers);  }
@Test public void getConcept_shouldFetchByMappingOrUuid() { Concept cd4 = Context.getConceptService().getConceptByUuid(Dictionary.CD4_COUNT); Concept fetched = Dictionary.getConcept(Dictionary.CD4_COUNT); Assert.assertThat(fetched, is(cd4)); Assert.assertThat(fetched, is(instanceOf(ConceptNumeric.class))); }
@Test(expected = MissingMetadataException.class) public void getConcept_shouldThrowExceptionForNonExistent() { Dictionary.getConcept("PIH:XXXXXXXXXXXXXXX"); }