HumanPhenotypeOntologyDao implements OntologyDao { @Override public Set<PhenotypeMatch> getPhenotypeMatchesForHpoTerm(PhenotypeTerm hpoTerm) { String mappingQuery = "SELECT simj, ic, score, hp_id_hit AS hit_id, hp_hit_term AS hit_term, lcs_id, lcs_term FROM hp_hp_mappings WHERE hp_id = ?"; try ( Connection connection = dataSource.getConnection(); PreparedStatement ps = PreparedStatementSetter.prepareStatement(connection, mappingQuery, setter -> setter .setString(1, hpoTerm.getId())); ResultSet rs = ps.executeQuery()) { return OntologyDaoResultSetProcessor.processOntologyTermMatchResultSet(rs, hpoTerm); } catch (SQLException e) { logger.error("Unable to execute query '{}' for HP-HP match terms", mappingQuery, e); } return Collections.emptySet(); } HumanPhenotypeOntologyDao(DataSource phenotypeDataSource); @Override Set<PhenotypeTerm> getAllTerms(); @Override Set<PhenotypeMatch> getPhenotypeMatchesForHpoTerm(PhenotypeTerm hpoTerm); Map<String, PhenotypeTerm> getIdToPhenotypeTerms();  }
@Test public void testGetPhenotypeMatchesForNonExistentHpoTermReturnsEmptySet() { PhenotypeTerm nonExistentTerm = PhenotypeTerm.of("", ""); Set<PhenotypeMatch> matches = instance.getPhenotypeMatchesForHpoTerm(nonExistentTerm); assertThat(matches.isEmpty(), is(true)); }
@Test public void testGetPhenotypeMatchesForHpoTerm() { Set<PhenotypeMatch> matches = instance.getPhenotypeMatchesForHpoTerm(multicysticKidneyDysplasia); assertThat(matches.isEmpty(), is(false)); assertThat(matches, equalTo(phenotypeMatches)); }