CountriesGeoJsonServiceImpl implements CountriesGeoJsonService { public Optional<Entry<String, Double>> entryByCountry(Map<String, Double> data, Feature value) { if (value == null) { return Optional.empty(); } String countryID = value.getId(); String countryName = getCountryName(value); return data.entrySet().stream().filter(k -> k.getKey().equalsIgnoreCase(countryID) || k.getKey().equalsIgnoreCase(countryName)) .findFirst(); }  @PostConstruct void setup(); @Override Feature[] getCountries(); @Override String getCountryName(Feature country); @Override String getCountryNameByCode(String code); @Override Optional<Entry<String, Double>> findEntry(Map<String, Double> data, Feature feature); @Override Optional<Double> findValue(Map<String, Double> data, Feature feature); @Override Optional<Feature> findCountry(String idNameOrLocation); Optional<Feature> countryByIdOrName(String idOrName); Optional<Feature> countryByLocation(String location); Optional<Entry<String, Double>> entryByCountry(Map<String, Double> data, Feature value); Optional<Double> valueByCountry(Map<String, Double> data, Feature value); Stream<Entry<String, Double>> entriesByLocation(Map<String, Double> data, Feature feature); Optional<Double> valueByLocation(Map<String, Double> data, Feature feature);  }
@Test public void entryByCountryTest() { Optional<Entry<String, Double>> entryByCountry; Map<String, Double> data = new HashMap<>(); data.put(COUNTRY_NAME, 1d); entryByCountry = countriesGeoJsonServiceImpl.entryByCountry(data, feature); assertTrue(entryByCountry.isPresent()); entryByCountry = countriesGeoJsonServiceImpl.entryByCountry(data, null); assertTrue(!entryByCountry.isPresent()); entryByCountry = countriesGeoJsonServiceImpl.entryByCountry(new HashMap<>(), feature); assertTrue(!entryByCountry.isPresent()); }