@Test
public void zeroCountDownTriggersCallback() {

    final AtomicInteger timesCalled = new AtomicInteger(0);
    final CallbackCountDownLatch latch = new CallbackCountDownLatch(2, timesCalled::getAndIncrement);
    assertThat(timesCalled).hasValue(0);
    latch.countDown();
    assertThat(timesCalled).hasValue(0);
    latch.countDown();
    assertThat(timesCalled).hasValue(1);
    // only called once
    latch.countDown();
    assertThat(timesCalled).hasValue(1);
}