@Test public void search() { Iterable<LocationInfo> infos = new WeatherWebApi(new MockRequest()) .search("Oporto"); Iterator<LocationInfo> iter = infos.iterator(); assertNotNull(infos); assertTrue(iter.hasNext()); LocationInfo li = iter.next(); assertEquals(li.getCountry(), "Spain"); assertEquals(li.getRegion(), "Galicia"); assertEquals(li.getLatitude(), 42.383); assertEquals(li.getLongitude(), -7.100); }
public Iterable<LocationInfo> search(String query) { String path = HOST + String.format(PATH_SEARCH, query, WEATHER_KEY); Iterable<String> src = request.getLines(path); src = filter(src , line -> !line.startsWith("#")); return map(src, line -> LocationInfo.valueOf(line)); }
WeatherWebApi { public Iterable<LocationInfo> search(String query) { String path = HOST + String.format(PATH_SEARCH, query, WEATHER_KEY); Iterable<String> src = request.getLines(path); src = filter(src , line -> !line.startsWith("#")); return map(src, line -> LocationInfo.valueOf(line)); } }
WeatherWebApi { public Iterable<LocationInfo> search(String query) { String path = HOST + String.format(PATH_SEARCH, query, WEATHER_KEY); Iterable<String> src = request.getLines(path); src = filter(src , line -> !line.startsWith("#")); return map(src, line -> LocationInfo.valueOf(line)); } WeatherWebApi(Request request); }
WeatherWebApi { public Iterable<LocationInfo> search(String query) { String path = HOST + String.format(PATH_SEARCH, query, WEATHER_KEY); Iterable<String> src = request.getLines(path); src = filter(src , line -> !line.startsWith("#")); return map(src, line -> LocationInfo.valueOf(line)); } WeatherWebApi(Request request); Iterable<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to); Iterable<LocationInfo> search(String query); }
WeatherWebApi { public Iterable<LocationInfo> search(String query) { String path = HOST + String.format(PATH_SEARCH, query, WEATHER_KEY); Iterable<String> src = request.getLines(path); src = filter(src , line -> !line.startsWith("#")); return map(src, line -> LocationInfo.valueOf(line)); } WeatherWebApi(Request request); Iterable<WeatherInfo> pastWeather(double lat, double log, LocalDate from, LocalDate to); Iterable<LocationInfo> search(String query);  }