GRPCClient implements HLAPI { @Override public HLAPITransaction getTransaction(TID hash) throws HLAPIException { try { ByteString result = query("getTran", Collections.singletonList(hash.toUuidString())); byte[] resultStr = result.toByteArray(); if (resultStr.length == 0) return null; Transaction t = Transaction.fromByteArray(resultStr); if (!hash.equals(t.getID())) return null; return new HLAPITransaction(t, BID.INVALID); } catch (StatusRuntimeException e) { if (e.getMessage().contains("ledger: resource not found")) { return null; } else { throw e; } } catch (IOException e) { throw new HLAPIException(e); } } GRPCClient(String host, int port, int observerPort); @Override String getClientVersion(); @Override String getServerVersion(); @Override long ping(long nonce); @Override void addAlertListener(AlertListener listener); @Override void removeAlertListener(AlertListener listener); @Override int getChainHeight(); @Override HLAPIHeader getBlockHeader(BID hash); @Override HLAPIBlock getBlock(BID hash); @Override HLAPITransaction getTransaction(TID hash); @Override void sendTransaction(Transaction transaction); @Override void registerRejectListener(RejectListener rejectListener); @Override void removeRejectListener(RejectListener rejectListener); @Override void sendBlock(Block block); @Override void registerTransactionListener(TransactionListener listener); @Override void removeTransactionListener(TransactionListener listener); @Override void registerTrunkListener(TrunkListener listener); @Override void removeTrunkListener(TrunkListener listener); @Override void catchUp(List<BID> inventory, int limit, boolean headers, TrunkListener listener);  }
@Test public void getNonExistingTransaction() throws HLAPIException { assertNull(client.getTransaction(TID.INVALID)); }