@Override
    public Optional<GeoLocationInformation> doGetGeoIpData(InetAddress address) {

        try (Timer.Context ignored = getTimer()) {
            final CityResponse response = getCityResponse(address);
            final Location location = response.getLocation();
            final Country country = response.getCountry();
            final City city = response.getCity();

            GeoLocationInformation info = GeoLocationInformation.create(
                    location.getLatitude(), location.getLongitude(),
                    country.getGeoNameId() == null ? "N/A" : country.getIsoCode(),
                    country.getGeoNameId() == null ? "N/A" : country.getName(),
                    city.getGeoNameId() == null ? "N/A" : city.getName(),// calling to .getName() may throw a NPE
                    "N/A",
                    "N/A");
            return Optional.of(info);
        } catch (Exception e) {
            if (!(e instanceof AddressNotFoundException)) {
                LOG.debug("Could not get location from IP {}", address.getHostAddress(), e);
                lastError = e.getMessage();
            }
            return Optional.empty();
        }
    }
@Test
    void testDoGetGeoIpData() throws IOException, GeoIp2Exception {

        Country country = createCountry();
        City city = createCity();
        Location location = createLocation();
        CityResponse cityResponse = createCityResponse(country, city, location);

        when(resolver.getCityResponse(any(InetAddress.class))).thenReturn(cityResponse);

        InetAddress address = InetAddress.getByName("localhost");
        Optional<GeoLocationInformation> optInfo = resolver.doGetGeoIpData(address);

        assertTrue(optInfo.isPresent());
        GeoLocationInformation info = optInfo.get();
        assertEquals(country.getName(), info.countryName());
        assertEquals(country.getIsoCode(), info.countryIsoCode());
        assertEquals(city.getName(), info.cityName());
        assertEquals(location.getLatitude(), info.latitude());
        assertEquals(location.getLongitude(), info.longitude());
        assertEquals(location.getTimeZone(), info.timeZone());

    }