CountriesGeoJsonServiceImpl implements CountriesGeoJsonService { public Optional<Double> valueByCountry(Map<String, Double> data, Feature value) { return entryByCountry(data, value).flatMap(e -> Optional.ofNullable(e.getValue())); }  @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 valueByCountryTest() { Double val = 1d; Optional<Double> valueByCountry; Map<String, Double> data = new HashMap<>(); data.put(COUNTRY_NAME, val); valueByCountry = countriesGeoJsonServiceImpl.valueByCountry(data, feature); assertTrue(valueByCountry.isPresent()); assertEquals(val, valueByCountry.get()); valueByCountry = countriesGeoJsonServiceImpl.valueByCountry(data, null); assertFalse(valueByCountry.isPresent()); valueByCountry = countriesGeoJsonServiceImpl.valueByCountry(new HashMap<>(), null); assertFalse(valueByCountry.isPresent()); }