QueryApiImpl extends AbstractApi implements QueryApi { @Override public Subscription<Block> subscribeBlock(final StreamObserver<Block> observer) { try { return getClient().getBlockOperation().subscribeBlock(observer); } catch (Exception e) { throw converter.convert(e); } }  @Override AccountState getAccountState(final AccountAddress accountAddress); @Override AccountAddress getNameOwner(final String name); @Override AccountAddress getNameOwner(final Name name); @Override AccountAddress getNameOwner(final String name, final long blockNumber); @Override AccountAddress getNameOwner(final Name name, final long blockNumber); @Override StakeInfo getStakingInfo(final AccountAddress accountAddress); @Override StakeInfo getStakeInfo(AccountAddress accountAddress); @Override List<ElectedCandidate> listElectedBps(final int showCount); @Override List<ElectedCandidate> listElected(final String voteId, final int showCount); @Override AccountTotalVote getVotesOf(final AccountAddress accountAddress); @Override BlockHash getBestBlockHash(); @Override long getBestBlockHeight(); @Override ChainIdHash getChainIdHash(); @Override BlockchainStatus getBlockchainStatus(); @Override ChainInfo getChainInfo(); @Override ChainStats getChainStats(); @Override List<Peer> listPeers(); @Override List<Peer> listPeers(final boolean showHidden, final boolean showSelf); @Override List<PeerMetric> listPeerMetrics(); @Override ServerInfo getServerInfo(final List<String> categories); @Override NodeStatus getNodeStatus(); @Override BlockMetadata getBlockMetadata(final BlockHash blockHash); @Override BlockMetadata getBlockMetadata(final long height); @Override List<BlockMetadata> listBlockMetadatas(final BlockHash blockHash, final int size); @Override List<BlockMetadata> listBlockMetadatas(final long height, final int size); @Override Block getBlock(final BlockHash blockHash); @Override Block getBlock(final long height); @Override Subscription<BlockMetadata> subscribeNewBlockMetadata(
      final StreamObserver<BlockMetadata> observer); @Override Subscription<Block> subscribeNewBlock(final StreamObserver<Block> observer); @Override Subscription<BlockMetadata> subscribeBlockMetadata(
      final StreamObserver<BlockMetadata> observer); @Override Subscription<Block> subscribeBlock(final StreamObserver<Block> observer); @Override Transaction getTransaction(final TxHash txHash); @Override TxReceipt getTxReceipt(final TxHash txHash); @Override ContractTxReceipt getContractTxReceipt(final TxHash contractTxHash); @Override ContractInterface getContractInterface(final ContractAddress contractAddress); @Override ContractResult query(final ContractInvocation contractInvocation); @Override ContractResult queryContract(ContractInvocation contractInvocation); @Override List<Event> listEvents(final EventFilter filter); @Override Subscription<Event> subscribeEvent(final EventFilter filter,
      final StreamObserver<Event> observer);  }
@SuppressWarnings("unchecked") @Test public void testSubscribeBlock() { final BlockOperation mockOperation = mock(BlockOperation.class); when(mockOperation.subscribeBlock(any(StreamObserver.class))) .thenReturn(mock(Subscription.class)); final AergoClient mockClient = mock(AergoClient.class); when(mockClient.getBlockOperation()).thenReturn(mockOperation); final ClientProvider mockClientProvider = mock(ClientProvider.class); when(mockClientProvider.getClient()).thenReturn(mockClient); final QueryApi queryApi = new QueryApiImpl(mockClientProvider); final StreamObserver<Block> observer = new StreamObserver<Block>() { @Override public void onNext(Block value) { } @Override public void onError(Throwable t) { } @Override public void onCompleted() { } }; assertNotNull(queryApi.subscribeNewBlock(observer)); assertNotNull(queryApi.subscribeBlock(observer)); }