test_class.declarator: DEFAULT_HEADER = HeaderName.forName("defaultHeaderName")
test_class.modifier: private static final
test_class.original_string: private static final HeaderName<String> DEFAULT_HEADER = HeaderName.forName("defaultHeaderName");
test_class.type: HeaderName<String>
test_class.var_name: DEFAULT_HEADER
test_class.declarator: DEFAULT_HEADER_VALUE = "ContextHeaderValue"
test_class.modifier: private static final
test_class.original_string: private static final String DEFAULT_HEADER_VALUE = "ContextHeaderValue";
test_class.type: String
test_class.var_name: DEFAULT_HEADER_VALUE
test_class.declarator: sut
test_class.modifier: private
test_class.original_string: private InMemoryTimeoutManager sut;
test_class.type: InMemoryTimeoutManager
test_class.var_name: sut
test_class.declarator: executor
test_class.modifier: private
test_class.original_string: private ScheduledExecutorService executor;
test_class.type: ScheduledExecutorService
test_class.var_name: executor
test_class.declarator: clock
test_class.modifier: private
test_class.original_string: private Clock clock;
test_class.type: Clock
test_class.var_name: clock
test_class.file: saga-lib/src/test/java/com/codebullets/sagalib/timeout/InMemoryTimeoutManagerTest.java
test_class.identifier: InMemoryTimeoutManagerTest
test_case.body: @Test
      public void timeoutTriggered_callbackAdded_callbackTriggered() {
          // given
          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);
  
          // when
          requestAndTriggerTimeout(expected.getSagaId(), expected.getName(), delayInSec, TimeUnit.SECONDS, expectedData);
  
          // then
          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));
      }
test_case.class_method_signature: InMemoryTimeoutManagerTest.timeoutTriggered_callbackAdded_callbackTriggered()
test_case.full_signature: @Test public void timeoutTriggered_callbackAdded_callbackTriggered()
test_case.identifier: timeoutTriggered_callbackAdded_callbackTriggered
test_case.invocations: getTime now toMillis mock addExpiredCallback create generateNewId requestAndTriggerTimeout getSagaId getName forClass expired verify capture assertThat getSagaId getValue equalTo getSagaId assertThat getName getValue equalTo getName assertThat getExpiredAt getValue equalTo getExpiredAt assertThat getData getValue sameInstance
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void timeoutTriggered_callbackAdded_callbackTriggered()
focal_class.declarator: LOG = LoggerFactory.getLogger(InMemoryTimeoutManager.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(InMemoryTimeoutManager.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: TIMER_THREAD_POOL_SIZE = 2
focal_class.modifier: private static final
focal_class.original_string: private static final int TIMER_THREAD_POOL_SIZE = 2;
focal_class.type: int
focal_class.var_name: TIMER_THREAD_POOL_SIZE
focal_class.declarator: sync = new Object()
focal_class.modifier: private final
focal_class.original_string: private final Object sync = new Object();
focal_class.type: Object
focal_class.var_name: sync
focal_class.declarator: callbacks = Collections.synchronizedCollection(new ArrayList<>())
focal_class.modifier: private final
focal_class.original_string: private final Collection<TimeoutExpired> callbacks = Collections.synchronizedCollection(new ArrayList<>());
focal_class.type: Collection<TimeoutExpired>
focal_class.var_name: callbacks
focal_class.declarator: openTimeouts = HashBasedTable.create()
focal_class.modifier: private final
focal_class.original_string: private final Table<TimeoutId, String, ScheduledFuture> openTimeouts = HashBasedTable.create();
focal_class.type: Table<TimeoutId, String, ScheduledFuture>
focal_class.var_name: openTimeouts
focal_class.declarator: scheduledService
focal_class.modifier: private final
focal_class.original_string: private final ScheduledExecutorService scheduledService;
focal_class.type: ScheduledExecutorService
focal_class.var_name: scheduledService
focal_class.declarator: clock
focal_class.modifier: private final
focal_class.original_string: private final Clock clock;
focal_class.type: Clock
focal_class.var_name: clock
focal_class.file: saga-lib/src/main/java/com/codebullets/sagalib/timeout/InMemoryTimeoutManager.java
focal_class.identifier: InMemoryTimeoutManager
focal_class.interfaces: implements TimeoutManager, AutoCloseable
focal_class.class_method_signature: InMemoryTimeoutManager.InMemoryTimeoutManager()
focal_class.full_signature: public  InMemoryTimeoutManager()
focal_class.identifier: InMemoryTimeoutManager
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  InMemoryTimeoutManager()
focal_class.class_method_signature: InMemoryTimeoutManager.InMemoryTimeoutManager(final int timerThreadPoolSize)
focal_class.full_signature: public  InMemoryTimeoutManager(final int timerThreadPoolSize)
focal_class.identifier: InMemoryTimeoutManager
focal_class.modifiers: public
focal_class.parameters: (final int timerThreadPoolSize)
focal_class.signature:  InMemoryTimeoutManager(final int timerThreadPoolSize)
focal_class.class_method_signature: InMemoryTimeoutManager.InMemoryTimeoutManager(final ScheduledExecutorService scheduledService, final Clock clock)
focal_class.full_signature: public  InMemoryTimeoutManager(final ScheduledExecutorService scheduledService, final Clock clock)
focal_class.identifier: InMemoryTimeoutManager
focal_class.modifiers: public
focal_class.parameters: (final ScheduledExecutorService scheduledService, final Clock clock)
focal_class.signature:  InMemoryTimeoutManager(final ScheduledExecutorService scheduledService, final Clock clock)
focal_class.class_method_signature: InMemoryTimeoutManager.addExpiredCallback(final TimeoutExpired callback)
focal_class.full_signature: @Override public void addExpiredCallback(final TimeoutExpired callback)
focal_class.identifier: addExpiredCallback
focal_class.modifiers: @Override public
focal_class.parameters: (final TimeoutExpired callback)
focal_class.return: void
focal_class.signature: void addExpiredCallback(final TimeoutExpired callback)
focal_class.class_method_signature: InMemoryTimeoutManager.requestTimeout(final ExecutionContext context, final String sagaId, final long delay, final TimeUnit timeUnit, @Nullable final String name,
                                 @Nullable final Object data)
focal_class.full_signature: @Override public TimeoutId requestTimeout(final ExecutionContext context, final String sagaId, final long delay, final TimeUnit timeUnit, @Nullable final String name,
                                 @Nullable final Object data)
focal_class.identifier: requestTimeout
focal_class.modifiers: @Override public
focal_class.parameters: (final ExecutionContext context, final String sagaId, final long delay, final TimeUnit timeUnit, @Nullable final String name,
                                 @Nullable final Object data)
focal_class.return: TimeoutId
focal_class.signature: TimeoutId requestTimeout(final ExecutionContext context, final String sagaId, final long delay, final TimeUnit timeUnit, @Nullable final String name,
                                 @Nullable final Object data)
focal_class.class_method_signature: InMemoryTimeoutManager.cancelTimeouts(final String sagaId)
focal_class.full_signature: @Override public void cancelTimeouts(final String sagaId)
focal_class.identifier: cancelTimeouts
focal_class.modifiers: @Override public
focal_class.parameters: (final String sagaId)
focal_class.return: void
focal_class.signature: void cancelTimeouts(final String sagaId)
focal_class.class_method_signature: InMemoryTimeoutManager.cancelTimeout(final TimeoutId id)
focal_class.full_signature: @Override public void cancelTimeout(final TimeoutId id)
focal_class.identifier: cancelTimeout
focal_class.modifiers: @Override public
focal_class.parameters: (final TimeoutId id)
focal_class.return: void
focal_class.signature: void cancelTimeout(final TimeoutId id)
focal_class.class_method_signature: InMemoryTimeoutManager.timeoutExpired(final Timeout timeout, final TimeoutContext context)
focal_class.full_signature: private void timeoutExpired(final Timeout timeout, final TimeoutContext context)
focal_class.identifier: timeoutExpired
focal_class.modifiers: private
focal_class.parameters: (final Timeout timeout, final TimeoutContext context)
focal_class.return: void
focal_class.signature: void timeoutExpired(final Timeout timeout, final TimeoutContext context)
focal_class.class_method_signature: InMemoryTimeoutManager.removeExpiredTimeout(final Timeout timeout)
focal_class.full_signature: private void removeExpiredTimeout(final Timeout timeout)
focal_class.identifier: removeExpiredTimeout
focal_class.modifiers: private
focal_class.parameters: (final Timeout timeout)
focal_class.return: void
focal_class.signature: void removeExpiredTimeout(final Timeout timeout)
focal_class.class_method_signature: InMemoryTimeoutManager.close()
focal_class.full_signature: @Override public void close()
focal_class.identifier: close
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_method.body: @Override
      public void addExpiredCallback(final TimeoutExpired callback) {
          checkNotNull(callback, "Expired callback not allowed to be null.");
  
          callbacks.add(callback);
      }
focal_method.class_method_signature: InMemoryTimeoutManager.addExpiredCallback(final TimeoutExpired callback)
focal_method.full_signature: @Override public void addExpiredCallback(final TimeoutExpired callback)
focal_method.identifier: addExpiredCallback
focal_method.invocations: checkNotNull add
focal_method.modifiers: @Override public
focal_method.parameters: (final TimeoutExpired callback)
focal_method.return: void
focal_method.signature: void addExpiredCallback(final TimeoutExpired callback)