WeatherWebApi { public List<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to) { String path = HOST + String.format(PATH_PAST_WEATHER, lat, log, from, to, WEATHER_KEY); List<WeatherInfo> infos = new ArrayList<>(); List<String> body = req.getLines(path); Iterator<String> reader = body.iterator(); while (reader.next().startsWith("#")) { } reader.next(); while (reader.hasNext()) { infos.add(WeatherInfo.valueOf(reader.next())); if(reader.hasNext()) reader.next(); } return infos; } WeatherWebApi(Request req); List<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to); List<LocationInfo> search(String query);  }
@Test public void testPastWeather() { WeatherWebApi api = new WeatherWebApi(new HttpRequest()); List<WeatherInfo> jan = api.pastWeather(37.017, -7.933, LocalDate.of(2020, 1, 1), LocalDate.of(2020, 1, 30)); WeatherInfo first = jan.iterator().next(); Assert.assertEquals(14, first.tempC); }