@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());
    //expected balances values are the ones encoded at transactions responses jsons (see enqueueTransactionsResponses)
    assertThat(balance1.value(), equalTo(new BigDecimal("11549.998")));
    assertThat(balance2.value(), equalTo(new BigDecimal("11299.997")));
}