@Test void should_error_out_when_invoked_given_invalid_driver_row() { { given(row.getString(SYMBOL)).willReturn(null); RowToStockMapper mapper = new RowToStockMapper(); assertThatNullPointerException() .isThrownBy(() -> mapper.apply(row)) .withMessage("column symbol cannot be null"); } { given(row.getString(SYMBOL)).willReturn("ABC"); given(row.getInstant(DATE)).willReturn(null); RowToStockMapper mapper = new RowToStockMapper(); assertThatNullPointerException() .isThrownBy(() -> mapper.apply(row)) .withMessage("column date cannot be null"); } { given(row.getString(SYMBOL)).willReturn("ABC"); given(row.getInstant(DATE)).willReturn(Instant.parse("2019-01-01T12:34:56.789Z")); given(row.getBigDecimal(VALUE)).willReturn(null); RowToStockMapper mapper = new RowToStockMapper(); assertThatNullPointerException() .isThrownBy(() -> mapper.apply(row)) .withMessage("column value cannot be null"); } }
@Override public Stock apply(Row row) { var symbol = Objects.requireNonNull(row.getString(SYMBOL), "column symbol cannot be null"); var date = Objects.requireNonNull(row.getInstant(DATE), "column date cannot be null"); var value = Objects.requireNonNull(row.getBigDecimal(VALUE), "column value cannot be null"); return new Stock(symbol, date, value); }
RowToStockMapper implements Function<Row, Stock> { @Override public Stock apply(Row row) { var symbol = Objects.requireNonNull(row.getString(SYMBOL), "column symbol cannot be null"); var date = Objects.requireNonNull(row.getInstant(DATE), "column date cannot be null"); var value = Objects.requireNonNull(row.getBigDecimal(VALUE), "column value cannot be null"); return new Stock(symbol, date, value); } }
RowToStockMapper implements Function<Row, Stock> { @Override public Stock apply(Row row) { var symbol = Objects.requireNonNull(row.getString(SYMBOL), "column symbol cannot be null"); var date = Objects.requireNonNull(row.getInstant(DATE), "column date cannot be null"); var value = Objects.requireNonNull(row.getBigDecimal(VALUE), "column value cannot be null"); return new Stock(symbol, date, value); }  }
RowToStockMapper implements Function<Row, Stock> { @Override public Stock apply(Row row) { var symbol = Objects.requireNonNull(row.getString(SYMBOL), "column symbol cannot be null"); var date = Objects.requireNonNull(row.getInstant(DATE), "column date cannot be null"); var value = Objects.requireNonNull(row.getBigDecimal(VALUE), "column value cannot be null"); return new Stock(symbol, date, value); }  @Override Stock apply(Row row); }
RowToStockMapper implements Function<Row, Stock> { @Override public Stock apply(Row row) { var symbol = Objects.requireNonNull(row.getString(SYMBOL), "column symbol cannot be null"); var date = Objects.requireNonNull(row.getInstant(DATE), "column date cannot be null"); var value = Objects.requireNonNull(row.getBigDecimal(VALUE), "column value cannot be null"); return new Stock(symbol, date, value); }  @Override Stock apply(Row row);  }