@Test void ifAtLeastOneIdMatchesWeGetNonEmptyOptional() { BioentityPropertyName randomIdPropertyName = generateRandomKnownBioentityPropertyName(); while (!SPECIES_OVERRIDE_PROPERTY_NAMES.contains(randomIdPropertyName)) { randomIdPropertyName = generateRandomKnownBioentityPropertyName(); } ID_PROPERTY_NAMES.forEach(propertyName -> { when(geneIdSearchDao.searchGeneIds("foobar", propertyName.name, HUMAN.getEnsemblName())) .thenReturn(Optional.empty()); when(geneIdSearchDao.searchGeneIds("foobar", propertyName.name)) .thenReturn(Optional.empty()); }); when(geneIdSearchDao.searchGeneIds("foobar", randomIdPropertyName.name, HUMAN.getEnsemblName())) .thenReturn(Optional.of(ImmutableSet.of())); when(geneIdSearchDao.searchGeneIds("foobar", randomIdPropertyName.name)) .thenReturn(Optional.of(ImmutableSet.of())); assertThat(subject.search(GeneQuery.create("foobar", HUMAN))) .hasValue(ImmutableSet.of()); assertThat(subject.search(GeneQuery.create("foobar"))) .hasValue(ImmutableSet.of()); }
public Optional<ImmutableSet<String>> search(GeneQuery geneQuery) { if (geneQuery.category().isPresent()) { if (geneQuery.species().isPresent() && !BioentitiesCollectionProxy.SPECIES_OVERRIDE_PROPERTY_NAMES.contains(geneQuery.category().get())) { LOGGER.debug( "Searching {}/{} in species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().get().getEnsemblName()); return geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), geneQuery.category().get().name, geneQuery.species().get().getEnsemblName()); } LOGGER.debug( "Searching {}/{} ignoring species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), geneQuery.category().get().name); } LOGGER.debug( "Searching {} (free text without category) in species {}", geneQuery.queryTerm(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneQuery.species().isPresent() ? searchIds(propertyName -> geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), propertyName, geneQuery.species().get().getEnsemblName())) : searchIds(propertyName -> geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), propertyName)); }
GeneIdSearchService { public Optional<ImmutableSet<String>> search(GeneQuery geneQuery) { if (geneQuery.category().isPresent()) { if (geneQuery.species().isPresent() && !BioentitiesCollectionProxy.SPECIES_OVERRIDE_PROPERTY_NAMES.contains(geneQuery.category().get())) { LOGGER.debug( "Searching {}/{} in species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().get().getEnsemblName()); return geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), geneQuery.category().get().name, geneQuery.species().get().getEnsemblName()); } LOGGER.debug( "Searching {}/{} ignoring species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), geneQuery.category().get().name); } LOGGER.debug( "Searching {} (free text without category) in species {}", geneQuery.queryTerm(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneQuery.species().isPresent() ? searchIds(propertyName -> geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), propertyName, geneQuery.species().get().getEnsemblName())) : searchIds(propertyName -> geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), propertyName)); } }
GeneIdSearchService { public Optional<ImmutableSet<String>> search(GeneQuery geneQuery) { if (geneQuery.category().isPresent()) { if (geneQuery.species().isPresent() && !BioentitiesCollectionProxy.SPECIES_OVERRIDE_PROPERTY_NAMES.contains(geneQuery.category().get())) { LOGGER.debug( "Searching {}/{} in species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().get().getEnsemblName()); return geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), geneQuery.category().get().name, geneQuery.species().get().getEnsemblName()); } LOGGER.debug( "Searching {}/{} ignoring species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), geneQuery.category().get().name); } LOGGER.debug( "Searching {} (free text without category) in species {}", geneQuery.queryTerm(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneQuery.species().isPresent() ? searchIds(propertyName -> geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), propertyName, geneQuery.species().get().getEnsemblName())) : searchIds(propertyName -> geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), propertyName)); } GeneIdSearchService(GeneIdSearchDao geneIdSearchDao); }
GeneIdSearchService { public Optional<ImmutableSet<String>> search(GeneQuery geneQuery) { if (geneQuery.category().isPresent()) { if (geneQuery.species().isPresent() && !BioentitiesCollectionProxy.SPECIES_OVERRIDE_PROPERTY_NAMES.contains(geneQuery.category().get())) { LOGGER.debug( "Searching {}/{} in species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().get().getEnsemblName()); return geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), geneQuery.category().get().name, geneQuery.species().get().getEnsemblName()); } LOGGER.debug( "Searching {}/{} ignoring species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), geneQuery.category().get().name); } LOGGER.debug( "Searching {} (free text without category) in species {}", geneQuery.queryTerm(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneQuery.species().isPresent() ? searchIds(propertyName -> geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), propertyName, geneQuery.species().get().getEnsemblName())) : searchIds(propertyName -> geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), propertyName)); } GeneIdSearchService(GeneIdSearchDao geneIdSearchDao); Optional<ImmutableSet<String>> search(GeneQuery geneQuery); }
GeneIdSearchService { public Optional<ImmutableSet<String>> search(GeneQuery geneQuery) { if (geneQuery.category().isPresent()) { if (geneQuery.species().isPresent() && !BioentitiesCollectionProxy.SPECIES_OVERRIDE_PROPERTY_NAMES.contains(geneQuery.category().get())) { LOGGER.debug( "Searching {}/{} in species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().get().getEnsemblName()); return geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), geneQuery.category().get().name, geneQuery.species().get().getEnsemblName()); } LOGGER.debug( "Searching {}/{} ignoring species {}", geneQuery.queryTerm(), geneQuery.category().get(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), geneQuery.category().get().name); } LOGGER.debug( "Searching {} (free text without category) in species {}", geneQuery.queryTerm(), geneQuery.species().map(Species::getEnsemblName).orElse("(none provided)")); return geneQuery.species().isPresent() ? searchIds(propertyName -> geneIdSearchDao.searchGeneIds( geneQuery.queryTerm(), propertyName, geneQuery.species().get().getEnsemblName())) : searchIds(propertyName -> geneIdSearchDao.searchGeneIds(geneQuery.queryTerm(), propertyName)); } GeneIdSearchService(GeneIdSearchDao geneIdSearchDao); Optional<ImmutableSet<String>> search(GeneQuery geneQuery);  }