@Test public void addBalanceListener() throws Exception { enqueueTransactionsResponses(); final CountDownLatch latch = new CountDownLatch(1); final List<Balance> actualResults = new ArrayList<>(); blockchainEvents.addBalanceListener(new EventListener<Balance>() { @Override public void onEvent(Balance data) { actualResults.add(data); if (actualResults.size() == 2) { latch.countDown(); } } }); assertTrue(latch.await(1, TimeUnit.SECONDS)); assertThat(actualResults.size(), equalTo(2)); Balance balance1 = actualResults.get(0); Balance balance2 = actualResults.get(1); assertThat(balance1, notNullValue()); assertThat(balance2, notNullValue()); assertThat(balance1.value(), equalTo(new BigDecimal("11549.998"))); assertThat(balance2.value(), equalTo(new BigDecimal("11299.997"))); }
ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); }
BlockchainEvents { ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } }
BlockchainEvents { ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } BlockchainEvents(Server server, String accountId); }
BlockchainEvents { ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } BlockchainEvents(Server server, String accountId);  }
BlockchainEvents { ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } BlockchainEvents(Server server, String accountId);   }