### Question:
ParserWrapper implements Parser { @Override public Instant getInstant() throws MatchbookSDKParsingException { if (isNotNullValue()) { try { return Instant.parse(jsonParser.getValueAsString()); } catch (IOException | DateTimeException e) { throw new MatchbookSDKParsingException(e); } } return null; } ParserWrapper(JsonFactory jsonFactory, InputStream inputStream); @Override boolean hasCurrentToken(); @Override boolean isEndOfObject(); @Override boolean isEndOfArray(); @Override void moveToNextToken(); @Override void moveToNextValue(); @Override void skipChildren(); @Override String getFieldName(); @Override Boolean getBoolean(); @Override String getString(); @Override Integer getInteger(); @Override Long getLong(); @Override Double getDouble(); @Override BigDecimal getDecimal(); @Override Instant getInstant(); @Override T getEnum(Class<T> enumClass); @Override void close();  }### Answer:
@Test @DisplayName("Read time instant value") void getInstantTest() throws IOException { String instantAsString = "2017-02-14T11:08:00.000Z"; Instant expectedResult = Instant.parse(instantAsString); when(jsonParser.getValueAsString()).thenReturn(instantAsString); when(jsonParser.hasToken(JsonToken.VALUE_NULL)).thenReturn(false); Instant result = unit.getInstant(); assertThat(result).isNotNull(); assertThat(result).isEqualTo(expectedResult); }
@Test @DisplayName("Read null time instant value") void getInstantNullTest() { when(jsonParser.hasToken(JsonToken.VALUE_NULL)).thenReturn(true); Instant result = unit.getInstant(); assertThat(result).isNull(); }
@Test @DisplayName("Read bad formatted time instant value") void getInstantIncorrectFormatTest() throws IOException { String badInstanceString = "not a well-formed timestamp"; when(jsonParser.getValueAsString()).thenReturn(badInstanceString); when(jsonParser.hasToken(JsonToken.VALUE_NULL)).thenReturn(false); assertThatExceptionOfType(MatchbookSDKParsingException.class) .isThrownBy(() -> unit.getInstant()); }
@Test @DisplayName("Exception reading time instant value") void getInstantFailedTest() throws IOException { doThrow(IOException.class).when(jsonParser).getValueAsString(); when(jsonParser.hasToken(JsonToken.VALUE_NULL)).thenReturn(false); assertThatExceptionOfType(MatchbookSDKParsingException.class) .isThrownBy(() -> unit.getInstant()); }