### Question:
InstantMapper extends TypedMapper<Instant> { @Override protected Instant extractByIndex(ResultSet r, int index) throws SQLException { final Timestamp timestamp = calendar.isPresent() ? r.getTimestamp(index, cloneCalendar()) : r.getTimestamp(index); return timestamp == null ? null : timestamp.toInstant(); } InstantMapper();  InstantMapper(final Optional<TimeZone> tz);   }### Answer:
@Test public void extractByIndex() throws Exception { ZonedDateTime expected = ZonedDateTime.parse("2012-12-21T00:00:00.000Z"); ZonedDateTime stored = expected.withZoneSameInstant(ZoneId.systemDefault()); when(resultSet.getTimestamp(1)).thenReturn(Timestamp.from(stored.toInstant())); Instant actual = new InstantMapper().extractByIndex(resultSet, 1); assertThat(actual).isEqualTo(expected.toInstant()); }
@Test public void extractByIndex_TimestampIsNull() throws Exception { when(resultSet.getTimestamp(1)).thenReturn(null); Instant actual = new InstantMapper().extractByIndex(resultSet, 1); assertThat(actual).isNull(); }