CountriesGeoJsonServiceImpl implements CountriesGeoJsonService { @Override public String getCountryNameByCode(String code) { return Arrays.stream(featureCollection.getFeatures()) .filter(f -> f.getId().equalsIgnoreCase(code)) .map(this::getCountryName) .findFirst().orElse(""); }  @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 getCountryNameByCodeTest() { String countryName = countriesGeoJsonServiceImpl.getCountryNameByCode(COUNTRY_CODE); assertEquals(COUNTRY_NAME, countryName); countryName = countriesGeoJsonServiceImpl.getCountryNameByCode("123"); assertTrue(countryName.isEmpty()); countryName = countriesGeoJsonServiceImpl.getCountryNameByCode(null); assertTrue(countryName.isEmpty()); }