@Test public void pastWeather() { Iterable<WeatherInfo> infos = new WeatherWebApi(new MockRequest()) .pastWeather(37.017,-7.933, parse("2019-02-01"), parse("2019-02-28")); Iterator<WeatherInfo> iter = infos.iterator(); assertNotNull(infos); assertTrue(iter.hasNext()); WeatherInfo wi = iter.next(); assertEquals(parse("2019-02-01"), wi.getDate()); assertEquals(14, wi.getTempC()); assertEquals(13.8, wi.getPrecipMM()); assertEquals("Patchy rain possible", wi.getDesc()); }
public Iterable<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to) { String path = HOST + String.format(PATH_PAST_WEATHER, lat, log, from, to, WEATHER_KEY); Iterable<String> src = request.getLines(path); boolean[] isOdd = {true}; src = filter(src, line -> !line.startsWith("#")); src = skip(src, 1); src = filter(src, __-> {isOdd[0] = !isOdd[0]; return isOdd[0];}); return map(src, line -> WeatherInfo.valueOf(line)); }
WeatherWebApi { public Iterable<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to) { String path = HOST + String.format(PATH_PAST_WEATHER, lat, log, from, to, WEATHER_KEY); Iterable<String> src = request.getLines(path); boolean[] isOdd = {true}; src = filter(src, line -> !line.startsWith("#")); src = skip(src, 1); src = filter(src, __-> {isOdd[0] = !isOdd[0]; return isOdd[0];}); return map(src, line -> WeatherInfo.valueOf(line)); } }
WeatherWebApi { public Iterable<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to) { String path = HOST + String.format(PATH_PAST_WEATHER, lat, log, from, to, WEATHER_KEY); Iterable<String> src = request.getLines(path); boolean[] isOdd = {true}; src = filter(src, line -> !line.startsWith("#")); src = skip(src, 1); src = filter(src, __-> {isOdd[0] = !isOdd[0]; return isOdd[0];}); return map(src, line -> WeatherInfo.valueOf(line)); } WeatherWebApi(Request request); }
WeatherWebApi { public Iterable<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to) { String path = HOST + String.format(PATH_PAST_WEATHER, lat, log, from, to, WEATHER_KEY); Iterable<String> src = request.getLines(path); boolean[] isOdd = {true}; src = filter(src, line -> !line.startsWith("#")); src = skip(src, 1); src = filter(src, __-> {isOdd[0] = !isOdd[0]; return isOdd[0];}); return map(src, line -> WeatherInfo.valueOf(line)); } WeatherWebApi(Request request); Iterable<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to); Iterable<LocationInfo> search(String query); }
WeatherWebApi { public Iterable<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to) { String path = HOST + String.format(PATH_PAST_WEATHER, lat, log, from, to, WEATHER_KEY); Iterable<String> src = request.getLines(path); boolean[] isOdd = {true}; src = filter(src, line -> !line.startsWith("#")); src = skip(src, 1); src = filter(src, __-> {isOdd[0] = !isOdd[0]; return isOdd[0];}); return map(src, line -> WeatherInfo.valueOf(line)); } WeatherWebApi(Request request); Iterable<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to); Iterable<LocationInfo> search(String query);  }