@Test public void testDayWithMaxTemperatureInOporto(){ WeatherService service = new WeatherService(new WeatherRestfullApi()); Stream<Location> locals = service.search("oporto"); WeatherInfo[] oportoWeather = locals .skip(1) .findFirst() .get() .getPast30daysWeather() .toArray(size -> new WeatherInfo[size]); WeatherInfo maxTemp = of(oportoWeather).max(comparing(WeatherInfo::getTempC)).get(); WeatherInfo maxDesc = of(oportoWeather).max(comparing(WeatherInfo::getDesc)).get(); assertEquals(18, maxDesc.getTempC()); WeatherInfo maxDescAndTemp = of(oportoWeather).max( comparing(WeatherInfo::getDesc).thenComparing(WeatherInfo::getTempC)).get(); assertEquals(18, maxDescAndTemp.getTempC()); Comparator<WeatherInfo> cmp = comparing(WeatherInfo::getDesc) .thenComparing(WeatherInfo::getTempC) .thenComparing(WeatherInfo::getPrecipMM) .thenComparing(WeatherInfo::getDate); }
public Stream<Location> search(String query) { Stream<LocationInfo> locals = api.search(query); return locals.map(this::toLocation); }
WeatherService { public Stream<Location> search(String query) { Stream<LocationInfo> locals = api.search(query); return locals.map(this::toLocation); } }
WeatherService { public Stream<Location> search(String query) { Stream<LocationInfo> locals = api.search(query); return locals.map(this::toLocation); } WeatherService(WeatherApi api);  WeatherService(); }
WeatherService { public Stream<Location> search(String query) { Stream<LocationInfo> locals = api.search(query); return locals.map(this::toLocation); } WeatherService(WeatherApi api);  WeatherService(); Stream<Location> search(String query); }
WeatherService { public Stream<Location> search(String query) { Stream<LocationInfo> locals = api.search(query); return locals.map(this::toLocation); } WeatherService(WeatherApi api);  WeatherService(); Stream<Location> search(String query);  }