CountriesGeoJsonServiceImpl implements CountriesGeoJsonService { public Stream<Entry<String, Double>> entriesByLocation(Map<String, Double> data, Feature feature) { return data.entrySet().stream() .filter(e -> e.getKey().matches(LAT_LONG_REGEX)) .filter(e -> containsLocation(e.getKey(), feature)); }  @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 entryByLocationTest() { when(d3.geoContains(any(), any())).thenReturn(true); Optional<Entry<String, Double>> entryByLocation; Map<String, Double> data = new HashMap<>(); data.put(COUNTRY_LOCATION, 1d); entryByLocation = countriesGeoJsonServiceImpl.entriesByLocation(data, feature).findFirst(); ; assertTrue(entryByLocation.isPresent()); verify(d3).geoContains(any(), any()); when(d3.geoContains(any(), any())).thenReturn(false); entryByLocation = countriesGeoJsonServiceImpl.entriesByLocation(data, null).findFirst(); assertFalse(entryByLocation.isPresent()); entryByLocation = countriesGeoJsonServiceImpl.entriesByLocation(new HashMap<>(), feature).findFirst(); assertFalse(entryByLocation.isPresent()); when(d3.geoContains(any(), any())).thenReturn(false); entryByLocation = countriesGeoJsonServiceImpl.entriesByLocation(data, feature).findFirst(); assertFalse(entryByLocation.isPresent()); }