@Test void should_throw_IOE_when_input_invalid() throws IOException { var error = new JsonParseException(parser, "not really"); given(parser.readValueAs(String.class)).willThrow(error); assertThatThrownBy(() -> deserializer.deserialize(parser, ctx)) .isInstanceOf(JsonParseException.class) .hasMessage("Could not parse node as instant") .hasRootCause(error); verify(parser).readValueAs(String.class); }
@Override public Instant deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { try { String text = p.readValueAs(String.class); return text == null ? null : converter.convert(text); } catch (Exception e) { throw new JsonParseException(p, "Could not parse node as instant", e); } }
InstantDeserializer extends StdScalarDeserializer<Instant> { @Override public Instant deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { try { String text = p.readValueAs(String.class); return text == null ? null : converter.convert(text); } catch (Exception e) { throw new JsonParseException(p, "Could not parse node as instant", e); } } }
InstantDeserializer extends StdScalarDeserializer<Instant> { @Override public Instant deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { try { String text = p.readValueAs(String.class); return text == null ? null : converter.convert(text); } catch (Exception e) { throw new JsonParseException(p, "Could not parse node as instant", e); } } InstantDeserializer(Converter<String, Instant> converter); }
InstantDeserializer extends StdScalarDeserializer<Instant> { @Override public Instant deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { try { String text = p.readValueAs(String.class); return text == null ? null : converter.convert(text); } catch (Exception e) { throw new JsonParseException(p, "Could not parse node as instant", e); } } InstantDeserializer(Converter<String, Instant> converter); @Override Instant deserialize(JsonParser p, DeserializationContext ctxt); }
InstantDeserializer extends StdScalarDeserializer<Instant> { @Override public Instant deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { try { String text = p.readValueAs(String.class); return text == null ? null : converter.convert(text); } catch (Exception e) { throw new JsonParseException(p, "Could not parse node as instant", e); } } InstantDeserializer(Converter<String, Instant> converter); @Override Instant deserialize(JsonParser p, DeserializationContext ctxt);  }