@Test
public void testPastWeatherInOporto(){

    // CountableRequest req = new CountableRequest(new HttpRequest());
    Request r = new HttpRequest();
    int[] count = {0};
    Function<String, String> counter = path -> {
        count[0]++;
        System.out.println("Request " + path);
        return path;
    };
    Function<String, Stream<String>> req = counter.andThen(r::getLines);
    WeatherService service = new WeatherService(new WeatherRestfullApi(req::apply));
    Location[] locals = service.search("oporto").toArray(size -> new Location[size]);
    assertEquals(1, count[0]);
    Stream<WeatherInfo> oportoWeather = of(locals).skip(1).findFirst().get().getPast30daysWeather();
    int tempC = oportoWeather
        .map(WeatherInfo::getTempC)
        .max(Integer::compareTo)
        .get();
    assertEquals(25, tempC);
    assertEquals(2, count[0]);
    of(locals).count(); // + 6 requests of pastWeather for 6 locations
    assertEquals(2, count[0]);
}