HpoIdChecker { @Nullable public PhenotypeTerm getCurrentTerm(String hpoId) { logger.debug("Checking ID {} is not obsolete", hpoId); Matcher hpoIdMatcher = HPO_ID_PATTERN.matcher(hpoId); if (!hpoIdMatcher.matches()) { throw new IllegalArgumentException("Input '" + hpoId + "' not a valid HPO identifier!"); } PhenotypeTerm term = termIdToTerms.get(hpoId); if (term == null) { logger.warn("Input {} - unable to find current id. Returning input {}", hpoId, hpoId); return null; } if (hpoId.equals(term.getId())) { logger.debug("Input is current - {} ({})", hpoId, term.getLabel()); return term; } else { logger.info("Input term {} is obsolete. Replaced by {} ({})", hpoId, term.getId(), term.getLabel()); return term; } } private  HpoIdChecker(Map<String, PhenotypeTerm> termIdToTerms); static HpoIdChecker of(Map<String, PhenotypeTerm> termIdToTerms); String getCurrentId(String hpoId); @Nullable PhenotypeTerm getCurrentTerm(String hpoId);  }
@Test void throwsErrorWhenIdUnrecognised() { assertThrows(Exception.class, () -> instance.getCurrentTerm("Wibble")); }
@Test void checkLastTermIsIncluded() { assertThat(instance.getCurrentTerm("HP:3000079"), equalTo(BAZ)); }