@SuppressWarnings("unchecked")
@Test
public void testSubscribeBlockMetadata() {

  // given
  final BlockOperation mockOperation = mock(BlockOperation.class);
  when(mockOperation.subscribeBlockMetadata(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);
  // then
  final QueryApi queryApi = new QueryApiImpl(mockClientProvider);
  final StreamObserver<BlockMetadata> observer = new StreamObserver<BlockMetadata>() {
    @Override
    public void onNext(BlockMetadata value) {
    }
    @Override
    public void onError(Throwable t) {
    }
    @Override
    public void onCompleted() {
    }
  };
  assertNotNull(queryApi.subscribeNewBlockMetadata(observer));
  assertNotNull(queryApi.subscribeBlockMetadata(observer));
}