Package org.axonframework.test.deadline
Class StubDeadlineManager
java.lang.Object
org.axonframework.test.deadline.StubDeadlineManager
- All Implemented Interfaces:
org.axonframework.deadline.DeadlineManager,org.axonframework.messaging.MessageDispatchInterceptorSupport<org.axonframework.deadline.DeadlineMessage<?>>,org.axonframework.messaging.MessageHandlerInterceptorSupport<org.axonframework.deadline.DeadlineMessage<?>>
public class StubDeadlineManager
extends Object
implements org.axonframework.deadline.DeadlineManager
Stub implementation of
DeadlineManager. Records all scheduled, canceled and met deadlines.- Since:
- 3.3
- Author:
- Milan Savic, Steven van Beelen
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes the manager withZonedDateTime.now()as current time.StubDeadlineManager(TemporalAccessor currentDateTime) Initializes the manager with providedcurrentDateTimeas current time. -
Method Summary
Modifier and TypeMethodDescriptionvoidadvanceTimeBy(Duration duration, DeadlineConsumer deadlineConsumer) Advances time by the givendurationand invokes the givendeadlineConsumerfor each deadline scheduled until that time.voidadvanceTimeTo(Instant newDateTime, DeadlineConsumer deadlineConsumer) Advances time to the givennewDateTimeand invokes the givendeadlineConsumerfor each deadline scheduled until that time.Advances the "current time" of the manager to the next scheduled deadline, and returns that deadline.voidvoidcancelAllWithinScope(String deadlineName, org.axonframework.messaging.ScopeDescriptor scope) voidcancelSchedule(String deadlineName, String scheduleId) Return the current date and time as anInstantas is being used by thisDeadlineManager.Deprecated.Return all scheduled deadlines which have not been met (yet).Return all triggered deadlines.voidinitializeAt(TemporalAccessor currentDateTime) Resets the initial "current time" of this manager.org.axonframework.common.RegistrationregisterDispatchInterceptor(org.axonframework.messaging.MessageDispatchInterceptor<? super org.axonframework.deadline.DeadlineMessage<?>> dispatchInterceptor) org.axonframework.common.RegistrationregisterHandlerInterceptor(org.axonframework.messaging.MessageHandlerInterceptor<? super org.axonframework.deadline.DeadlineMessage<?>> handlerInterceptor) schedule(Duration triggerDuration, String deadlineName, Object payloadOrMessage, org.axonframework.messaging.ScopeDescriptor deadlineScope) schedule(Instant triggerDateTime, String deadlineName, Object payloadOrMessage, org.axonframework.messaging.ScopeDescriptor deadlineScope) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.deadline.DeadlineManager
cancelAllWithinScope, schedule, schedule, schedule, schedule, shutdown
-
Constructor Details
-
StubDeadlineManager
public StubDeadlineManager()Initializes the manager withZonedDateTime.now()as current time. -
StubDeadlineManager
Initializes the manager with providedcurrentDateTimeas current time.- Parameters:
currentDateTime- The instance to use as current date and time
-
-
Method Details
-
initializeAt
Resets the initial "current time" of this manager. Must be called before any deadlines are scheduled.- Parameters:
currentDateTime- The instant to use as the current date and time- Throws:
IllegalStateException- when calling this method after deadlines are scheduled
-
schedule
@Nonnull public String schedule(@Nonnull Instant triggerDateTime, @Nonnull String deadlineName, Object payloadOrMessage, @Nonnull org.axonframework.messaging.ScopeDescriptor deadlineScope) - Specified by:
schedulein interfaceorg.axonframework.deadline.DeadlineManager
-
schedule
@Nonnull public String schedule(@Nonnull Duration triggerDuration, @Nonnull String deadlineName, Object payloadOrMessage, @Nonnull org.axonframework.messaging.ScopeDescriptor deadlineScope) - Specified by:
schedulein interfaceorg.axonframework.deadline.DeadlineManager
-
cancelSchedule
- Specified by:
cancelSchedulein interfaceorg.axonframework.deadline.DeadlineManager
-
cancelAll
- Specified by:
cancelAllin interfaceorg.axonframework.deadline.DeadlineManager
-
cancelAllWithinScope
public void cancelAllWithinScope(@Nonnull String deadlineName, @Nonnull org.axonframework.messaging.ScopeDescriptor scope) - Specified by:
cancelAllWithinScopein interfaceorg.axonframework.deadline.DeadlineManager
-
getScheduledDeadlines
Return all scheduled deadlines which have not been met (yet).- Returns:
- all scheduled deadlines which have not been met (yet)
-
getDeadlinesMet
Deprecated.in favor ofgetTriggeredDeadlines()Return all deadlines which have been met.- Returns:
- all deadlines which have been met
-
getTriggeredDeadlines
Return all triggered deadlines.- Returns:
- all triggered deadlines
-
getCurrentDateTime
Return the current date and time as anInstantas is being used by thisDeadlineManager.- Returns:
- the current date and time used by the manager
-
advanceToNextTrigger
Advances the "current time" of the manager to the next scheduled deadline, and returns that deadline. In theory, this may cause "current time" to move backwards.- Returns:
ScheduledDeadlineInfoof the first scheduled deadline
-
advanceTimeTo
Advances time to the givennewDateTimeand invokes the givendeadlineConsumerfor each deadline scheduled until that time.- Parameters:
newDateTime- the time to advance the "current time" of the manager todeadlineConsumer- the consumer to invoke for each deadline to trigger
-
advanceTimeBy
Advances time by the givendurationand invokes the givendeadlineConsumerfor each deadline scheduled until that time.- Parameters:
duration- the amount of time to advance the "current time" of the manager withdeadlineConsumer- the consumer to invoke for each deadline to trigger
-
registerDispatchInterceptor
@Nonnull public org.axonframework.common.Registration registerDispatchInterceptor(@Nonnull org.axonframework.messaging.MessageDispatchInterceptor<? super org.axonframework.deadline.DeadlineMessage<?>> dispatchInterceptor) - Specified by:
registerDispatchInterceptorin interfaceorg.axonframework.messaging.MessageDispatchInterceptorSupport<org.axonframework.deadline.DeadlineMessage<?>>
-
registerHandlerInterceptor
@Nonnull public org.axonframework.common.Registration registerHandlerInterceptor(@Nonnull org.axonframework.messaging.MessageHandlerInterceptor<? super org.axonframework.deadline.DeadlineMessage<?>> handlerInterceptor) - Specified by:
registerHandlerInterceptorin interfaceorg.axonframework.messaging.MessageHandlerInterceptorSupport<org.axonframework.deadline.DeadlineMessage<?>>
-
getTriggeredDeadlines()