### Question:
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);  }### Answer:
@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"); } }
@Test void should_create_stock_when_invoked_given_valid_driver_row() { var i = Instant.parse("2019-01-01T12:34:56.789Z"); BigDecimal value = BigDecimal.valueOf(42); given(row.getString(SYMBOL)).willReturn("ABC"); given(row.getInstant(DATE)).willReturn(i); given(row.getBigDecimal(VALUE)).willReturn(value); RowToStockMapper mapper = new RowToStockMapper(); Stock result = mapper.apply(row); assertThat(result.getSymbol()).isEqualTo("ABC"); assertThat(result.getDate()).isEqualTo(i); assertThat(result.getValue()).isEqualTo(value); }