InlinedWeather { public static Optional<Integer> minTemperatureSpreadDay(URL weatherFile) throws IOException { Optional<TemperatureExtremum> temperatureExtremum = MinimumDifferenceInFile.minimum(weatherFile, datas -> { try { Integer day = Integer.valueOf(datas.get(0)); Integer max = Integer.valueOf(datas.get(1)); Integer min = Integer.valueOf(datas.get(2)); return Optional.of(new TemperatureExtremum(day, max, min)); } catch (NumberFormatException e) { return empty(); } }); return temperatureExtremum.map(TemperatureExtremum::getDay); }  static Optional<Integer> minTemperatureSpreadDay(URL weatherFile);  }
@Test public void acceptance() throws IOException { URL weatherFile = getResource("weather.dat"); Optional<Integer> minTemperatureSpreadDay = InlinedWeather.minTemperatureSpreadDay(weatherFile); assertThat(minTemperatureSpreadDay).isPresent().hasValue(14); }
@Test public void with_empty_file() throws IOException { URL footballFile = getResource("empty.dat"); Optional<Integer> minTemperatureSpreadDay = InlinedWeather.minTemperatureSpreadDay(footballFile); assertThat(minTemperatureSpreadDay).isEmpty(); }