@Test public void pastWeather() { List<WeatherInfo> infos = new WeatherWebApi(new MockRequest()) .pastWeather(37.017,-7.933, parse("2019-02-01"), parse("2019-02-28")); assertNotNull(infos); assertFalse(infos.isEmpty()); assertTrue(infos.size() > 0); WeatherInfo wi = infos.get(0); assertEquals(parse("2019-02-01"), wi.date); assertEquals(14, wi.tempC); assertEquals(13.8, wi.precipMM); assertEquals("Patchy rain possible", wi.desc); }
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); Iterator<String> reader = request.getLines(path).iterator(); List<WeatherInfo> infos = new ArrayList<>(); while (reader.next().startsWith("#")) { } reader.next(); while (reader.hasNext()) { infos.add(WeatherInfo.valueOf(reader.next())); if(reader.hasNext()) reader.next(); } return infos; }
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); Iterator<String> reader = request.getLines(path).iterator(); List<WeatherInfo> infos = new ArrayList<>(); while (reader.next().startsWith("#")) { } reader.next(); while (reader.hasNext()) { infos.add(WeatherInfo.valueOf(reader.next())); if(reader.hasNext()) reader.next(); } return infos; } }
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); Iterator<String> reader = request.getLines(path).iterator(); List<WeatherInfo> infos = new ArrayList<>(); while (reader.next().startsWith("#")) { } reader.next(); while (reader.hasNext()) { infos.add(WeatherInfo.valueOf(reader.next())); if(reader.hasNext()) reader.next(); } return infos; } WeatherWebApi(Request request); }
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); Iterator<String> reader = request.getLines(path).iterator(); List<WeatherInfo> infos = new ArrayList<>(); while (reader.next().startsWith("#")) { } reader.next(); while (reader.hasNext()) { infos.add(WeatherInfo.valueOf(reader.next())); if(reader.hasNext()) reader.next(); } return infos; } WeatherWebApi(Request request); List<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to); List<LocationInfo> search(String query); }
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); Iterator<String> reader = request.getLines(path).iterator(); List<WeatherInfo> infos = new ArrayList<>(); while (reader.next().startsWith("#")) { } reader.next(); while (reader.hasNext()) { infos.add(WeatherInfo.valueOf(reader.next())); if(reader.hasNext()) reader.next(); } return infos; } WeatherWebApi(Request request); List<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to); List<LocationInfo> search(String query);  }