JsonConverterJEE implements JsonConverter { @Override public <T> RpcResponse<T> responseFromJson(String json, Class<T> resultClass) { ParameterizedType parameterizedType = new ResolvedParameterizedType(RpcResponse.class, new Type[]{resultClass}); return jsonb().fromJson(json, parameterizedType); }  @Override void addAdapter(Type type, Object adapter); @Override JsonConverterJEE configure(Properties properties); @Override RpcErrorResponse errorFromJson(String json); @Override RpcResponse<T> responseFromJson(String json, Class<T> resultClass); @Override T fromJson(String json, Class<T> resultClass); @Override String prettyPrint(String json); @Override String toRpcJson(Object input); @Override String toGenericJson(Object object, Type runtimeType); @Override String getName(); static final String NAME; }
@Test public void testRespFromJson() { RpcResponse<DirectoryBlockResponse> response = CONV.responseFromJson(DIRECTORY_BLOCK_RESP, DirectoryBlockResponse.class); Assert.assertNotNull(response); Assert.assertEquals("2.0", response.getJsonrpc()); Assert.assertEquals(3, response.getId()); Assert.assertNotNull(response.getResult()); DirectoryBlockResponse.Header header = response.getResult().getHeader(); Assert.assertNotNull(header); Assert.assertEquals("7d15d82e70201e960655ce3e7cf475c9da593dfb82c6dca6377349bd148bf001", header.getPreviousBlockKeyMR()); Assert.assertEquals(72497, header.getSequenceNumber()); Assert.assertEquals(1484858820, header.getTimestamp()); List<DirectoryBlockResponse.Entry> entries = response.getResult().getEntryblockList(); Assert.assertNotNull(entries); Assert.assertEquals(3, entries.size()); DirectoryBlockResponse.Entry entry = entries.get(1); Assert.assertEquals("000000000000000000000000000000000000000000000000000000000000000c", entry.getChainId()); Assert.assertEquals("5f8c98930a1874a46b47b65b9376a02fbff65b760f6866519799d69e2bc019ee", entry.getKeyMR()); }
@Test public void testReservedRespFromJson() { RpcResponse<AddressResponse> response = CONV.responseFromJson(ADDRESS_RESP, AddressResponse.class); Assert.assertNotNull(response); Assert.assertEquals("2.0", response.getJsonrpc()); Assert.assertEquals(6, response.getId()); Assert.assertNotNull(response.getResult()); Assert.assertEquals("FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q", response.getResult().getPublicAddress()); Assert.assertEquals("Fs3E9gV6DXsYzf7Fqx1fVBQPQXV695eP3k5XbmHEZVRLkMdD9qCK", response.getResult().getSecret()); RpcResponse<WalletBackupResponse> backupResponse = CONV.responseFromJson(WALLET_BACKUP_RESP, WalletBackupResponse.class); Assert.assertNotNull(backupResponse); Assert.assertEquals("2.0", backupResponse.getJsonrpc()); Assert.assertEquals(0, backupResponse.getId()); Assert.assertNotNull(backupResponse.getResult()); Assert.assertEquals("yellow yellow yellow yellow yellow yellow yellow yellow yellow yellow yellow yellow", backupResponse.getResult().getWalletSeed()); }