@Test public void testDayWithMaxTemperatureInOporto(){ WeatherService service = new WeatherService(new WeatherRestfullApi()); Iterable<Location> locals = service.search("oporto"); Iterable<WeatherInfo> oportoWeather = first(skip(locals, 1)).getPast30daysWeather(); WeatherInfo maxTemp = max(oportoWeather, comparing(WeatherInfo::getTempC)); WeatherInfo maxDesc = max(oportoWeather, comparing(WeatherInfo::getDesc)); assertEquals(14, maxDesc.getTempC()); WeatherInfo maxDescAndTemp = max( oportoWeather, comparing(WeatherInfo::getDesc).andThen(WeatherInfo::getTempC)); assertEquals(24, maxDescAndTemp.getTempC()); Cmposable<WeatherInfo> cmp = comparing(WeatherInfo::getDesc) .andThen(WeatherInfo::getTempC) .andThen(WeatherInfo::getPrecipMM) .andThen(WeatherInfo::getDate); }
public Iterable<Location> search(String query) { Iterable<LocationInfo> locals = api.search(query); return LazyQueries.map(locals, this::toLocation); }
WeatherService { public Iterable<Location> search(String query) { Iterable<LocationInfo> locals = api.search(query); return LazyQueries.map(locals, this::toLocation); } }
WeatherService { public Iterable<Location> search(String query) { Iterable<LocationInfo> locals = api.search(query); return LazyQueries.map(locals, this::toLocation); } WeatherService(WeatherApi api);  WeatherService(); }
WeatherService { public Iterable<Location> search(String query) { Iterable<LocationInfo> locals = api.search(query); return LazyQueries.map(locals, this::toLocation); } WeatherService(WeatherApi api);  WeatherService(); Iterable<Location> search(String query); }
WeatherService { public Iterable<Location> search(String query) { Iterable<LocationInfo> locals = api.search(query); return LazyQueries.map(locals, this::toLocation); } WeatherService(WeatherApi api);  WeatherService(); Iterable<Location> search(String query);  }