@Test public void timeoutTriggered_callbackAdded_callbackTriggered() { int delayInSec = 5; Object expectedData = new Object(); Date expectedTimeoutIn = new Date(clock.now().getTime() + TimeUnit.SECONDS.toMillis(delayInSec)); TimeoutExpired expiredCallback = mock(TimeoutExpired.class); sut.addExpiredCallback(expiredCallback); Timeout expected = Timeout.create(UUIDTimeoutId.generateNewId(), "theSagaId", "theTimeoutName", expectedTimeoutIn, expectedData); requestAndTriggerTimeout(expected.getSagaId(), expected.getName(), delayInSec, TimeUnit.SECONDS, expectedData); ArgumentCaptor<Timeout> captor = ArgumentCaptor.forClass(Timeout.class); verify(expiredCallback).expired(captor.capture()); assertThat("Saga id does not match.", captor.getValue().getSagaId(), equalTo(expected.getSagaId())); assertThat("Timeout name does not match.", captor.getValue().getName(), equalTo(expected.getName())); assertThat("Expiration time stamp does not match.", captor.getValue().getExpiredAt(), equalTo(expected.getExpiredAt())); assertThat("Data object does not match.", captor.getValue().getData(), sameInstance(expectedData)); }
@Override public void addExpiredCallback(final TimeoutExpired callback) { checkNotNull(callback, "Expired callback not allowed to be null."); callbacks.add(callback); }
InMemoryTimeoutManager implements TimeoutManager, AutoCloseable { @Override public void addExpiredCallback(final TimeoutExpired callback) { checkNotNull(callback, "Expired callback not allowed to be null."); callbacks.add(callback); } }
InMemoryTimeoutManager implements TimeoutManager, AutoCloseable { @Override public void addExpiredCallback(final TimeoutExpired callback) { checkNotNull(callback, "Expired callback not allowed to be null."); callbacks.add(callback); } InMemoryTimeoutManager();  InMemoryTimeoutManager(final int timerThreadPoolSize);  InMemoryTimeoutManager(final ScheduledExecutorService scheduledService, final Clock clock); }
InMemoryTimeoutManager implements TimeoutManager, AutoCloseable { @Override public void addExpiredCallback(final TimeoutExpired callback) { checkNotNull(callback, "Expired callback not allowed to be null."); callbacks.add(callback); } InMemoryTimeoutManager();  InMemoryTimeoutManager(final int timerThreadPoolSize);  InMemoryTimeoutManager(final ScheduledExecutorService scheduledService, final Clock clock); @Override void addExpiredCallback(final TimeoutExpired callback); @Override TimeoutId requestTimeout(final ExecutionContext context, final String sagaId, final long delay, final TimeUnit timeUnit, @Nullable final String name,
                               @Nullable final Object data); @Override void cancelTimeouts(final String sagaId); @Override void cancelTimeout(final TimeoutId id); @Override void close(); }
InMemoryTimeoutManager implements TimeoutManager, AutoCloseable { @Override public void addExpiredCallback(final TimeoutExpired callback) { checkNotNull(callback, "Expired callback not allowed to be null."); callbacks.add(callback); } InMemoryTimeoutManager();  InMemoryTimeoutManager(final int timerThreadPoolSize);  InMemoryTimeoutManager(final ScheduledExecutorService scheduledService, final Clock clock); @Override void addExpiredCallback(final TimeoutExpired callback); @Override TimeoutId requestTimeout(final ExecutionContext context, final String sagaId, final long delay, final TimeUnit timeUnit, @Nullable final String name,
                               @Nullable final Object data); @Override void cancelTimeouts(final String sagaId); @Override void cancelTimeout(final TimeoutId id); @Override void close();  }