Base16BigIntegerDeserializer extends JsonDeserializer<BigInteger> { @Override public BigInteger deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException { return IdUtil.fromString(p.getValueAsString()); }  @Override BigInteger deserialize(final JsonParser p,
                                  final DeserializationContext ctxt);  }
@Test public void testGenericConstructor() throws Exception { BigInteger id = IdUtil.next(); String idBody = String.format("\"%s\"", IdUtil.toString(id)); JsonFactory f = new JsonFactory(); JsonParser preloadedParser = f.createParser(idBody); preloadedParser.nextToken(); JsonDeserializer deserializer = new Base16BigIntegerDeserializer(); BigInteger deserializedId = (BigInteger) deserializer.deserialize(preloadedParser, mock(DeserializationContext.class)); assertEquals(id, deserializedId); }
@Test public void deserialize() throws Exception { BigInteger id = IdUtil.next(); String idBody = String.format("\"%s\"", IdUtil.toString(id)); JsonFactory f = new JsonFactory(); JsonParser preloadedParser = f.createParser(idBody); preloadedParser.nextToken(); Base16BigIntegerDeserializer deserializer = new Base16BigIntegerDeserializer(); BigInteger deserializedId = deserializer.deserialize(preloadedParser, mock(DeserializationContext.class)); assertEquals(id, deserializedId); }