CountriesGeoJsonServiceImpl implements CountriesGeoJsonService { public Optional<Feature> countryByIdOrName(String idOrName) { return Arrays.stream(featureCollection.getFeatures()) .filter(f -> { String countryName = getCountryName(f); return idOrName.equalsIgnoreCase(f.getId()) || idOrName.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 countryByIdOrNameTest() { Optional<Feature> countryByIdOrName = countriesGeoJsonServiceImpl.countryByIdOrName(COUNTRY_CODE); assertTrue(countryByIdOrName.isPresent()); assertEquals(feature, countryByIdOrName.get()); countryByIdOrName = countriesGeoJsonServiceImpl.countryByIdOrName(COUNTRY_NAME); assertTrue(countryByIdOrName.isPresent()); assertEquals(feature, countryByIdOrName.get()); countryByIdOrName = countriesGeoJsonServiceImpl.countryByIdOrName("123"); assertTrue(!countryByIdOrName.isPresent()); }