TimerInstanceState { public long findTimersWithDueDateBefore(final long timestamp, final TimerVisitor consumer) { nextDueDate = -1L; dueDateColumnFamily.whileTrue( (key, nil) -> { final DbLong dueDate = key.getFirst(); boolean consumed = false; if (dueDate.getValue() <= timestamp) { final DbCompositeKey<DbLong, DbLong> elementAndTimerKey = key.getSecond(); final TimerInstance timerInstance = timerInstanceColumnFamily.get(elementAndTimerKey); consumed = consumer.visit(timerInstance); } if (!consumed) { nextDueDate = dueDate.getValue(); } return consumed; }); return nextDueDate; } TimerInstanceState(final ZeebeDb<ZbColumnFamilies> zeebeDb, final DbContext dbContext); void put(final TimerInstance timer); long findTimersWithDueDateBefore(final long timestamp, final TimerVisitor consumer); void forEachTimerForElementInstance(
      final long elementInstanceKey, final Consumer<TimerInstance> action); TimerInstance get(final long elementInstanceKey, final long timerKey); void remove(final TimerInstance timer);  }
@Test public void shouldReturnNegativeDueDateIfEmpty() { final long nextDueDate = state.findTimersWithDueDateBefore(2000L, t -> true); assertThat(nextDueDate).isEqualTo(-1L); }