Interface FixtureExecutionResult


public interface FixtureExecutionResult
Interface towards an object that contains the results of a Saga test fixture execution. Assertions are made against the state of the Sagas and the messages they produced during the "when" phase.
Since:
1.1
Author:
Allard Buijze
  • Method Details

    • expectActiveSagas

      FixtureExecutionResult expectActiveSagas(int expected)
      Asserts that the repository contains the given expected amount of active Sagas.

      Counts every Saga in the store, whatever its type, as Axon Framework 4 did. That makes this assertion asymmetric with expectAssociationWith(String, Object), which does filter on the Saga type under test.

      Parameters:
      expected - the expected number of active Sagas in this fixture
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      AxonAssertionError - when the store holds another number of Sagas
    • expectAssociationWith

      FixtureExecutionResult expectAssociationWith(String associationKey, Object associationValue)
      Asserts that at least one of the active Sagas is associated with the given associationKey and associationValue.

      The associationValue is compared by its string representation, as Axon Framework 4 did.

      Parameters:
      associationKey - the key of the association
      associationValue - the value of the association
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      AxonAssertionError - when no Saga holds the association
    • expectNoAssociationWith

      FixtureExecutionResult expectNoAssociationWith(String associationKey, Object associationValue)
      Asserts that none of the active Sagas is associated with the given associationKey and associationValue.

      The associationValue is compared by its string representation, as Axon Framework 4 did.

      Parameters:
      associationKey - the key of the association
      associationValue - the value of the association
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      AxonAssertionError - when a Saga holds the association
    • expectDispatchedCommands

      FixtureExecutionResult expectDispatchedCommands(Object... commands)
      Asserts that the Sagas dispatched the given commands, in the exact sequence given.

      Each element is either a CommandMessage, in which case payload and metadata are both compared, or a payload, in which case only the payload is compared.

      Parameters:
      commands - the commands expected to have been dispatched
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      AxonAssertionError - when another set of commands was dispatched
    • expectDispatchedCommandsMatching

      FixtureExecutionResult expectDispatchedCommandsMatching(org.hamcrest.Matcher<? extends List<? super CommandMessage>> matcher)
      Asserts that the Sagas dispatched commands matching the given matcher.
      Parameters:
      matcher - the matcher validating the dispatched commands
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      AxonAssertionError - when the dispatched commands do not match
    • expectNoDispatchedCommands

      FixtureExecutionResult expectNoDispatchedCommands()
      Asserts that the Sagas dispatched no commands.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      AxonAssertionError - when any command was dispatched
    • expectPublishedEvents

      FixtureExecutionResult expectPublishedEvents(Object... expected)
      Asserts that the Sagas published the given events, in the exact sequence given.

      Each element is either an EventMessage or a payload; a message is unwrapped to its payload, so only payloads are compared and metadata is not, as in Axon Framework 4. The event that drove the "when" phase is not part of this set, since the test published it rather than the Saga.

      Parameters:
      expected - the events expected to have been published
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      AxonAssertionError - when another set of events was published
    • expectPublishedEventsMatching

      FixtureExecutionResult expectPublishedEventsMatching(org.hamcrest.Matcher<? extends List<? super EventMessage>> matcher)
      Asserts that the Sagas published events matching the given matcher.

      The event that drove the "when" phase is not part of the set the matcher sees, since the test published it rather than the Saga.

      Parameters:
      matcher - the matcher validating the published events
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      AxonAssertionError - when the published events do not match
    • expectSuccessfulHandlerExecution

      FixtureExecutionResult expectSuccessfulHandlerExecution()
      Asserts that the Saga handled the "when" event without failing.

      Unlike Axon Framework 4, a failing @SagaEventHandler propagates by default rather than being logged and swallowed, so this assertion holds unless the Saga threw. A Saga that suppresses its own failures with an @ExceptionHandler passes it, as it did in Axon Framework 4.

      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      AxonAssertionError - when handling the "when" event failed
    • expectScheduledEventMatching

      FixtureExecutionResult expectScheduledEventMatching(Duration duration, org.hamcrest.Matcher<? super EventMessage> matcher)
      Asserts that an event matching the given matcher is scheduled after the given duration.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectScheduledEvent

      FixtureExecutionResult expectScheduledEvent(Duration duration, Object applicationEvent)
      Asserts that the given applicationEvent is scheduled after the given duration.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectScheduledEventOfType

      FixtureExecutionResult expectScheduledEventOfType(Duration duration, Class<?> eventType)
      Asserts that an event of the given eventType is scheduled after the given duration.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectScheduledEventMatching

      FixtureExecutionResult expectScheduledEventMatching(Instant scheduledTime, org.hamcrest.Matcher<? super EventMessage> matcher)
      Asserts that an event matching the given matcher is scheduled at the given scheduledTime.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectScheduledEvent

      FixtureExecutionResult expectScheduledEvent(Instant scheduledTime, Object applicationEvent)
      Asserts that the given applicationEvent is scheduled at the given scheduledTime.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectScheduledEventOfType

      FixtureExecutionResult expectScheduledEventOfType(Instant scheduledTime, Class<?> eventType)
      Asserts that an event of the given eventType is scheduled at the given scheduledTime.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectNoScheduledEvents

      FixtureExecutionResult expectNoScheduledEvents()
      Asserts that no events are scheduled.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectNoScheduledEventMatching

      FixtureExecutionResult expectNoScheduledEventMatching(Duration durationToScheduledTime, org.hamcrest.Matcher<? super EventMessage> matcher)
      Asserts that no event matching the given matcher is scheduled after the given duration.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectNoScheduledEvent

      FixtureExecutionResult expectNoScheduledEvent(Duration durationToScheduledTime, Object event)
      Asserts that the given event is not scheduled after the given duration.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectNoScheduledEventOfType

      FixtureExecutionResult expectNoScheduledEventOfType(Duration durationToScheduledTime, Class<?> eventType)
      Asserts that no event of the given eventType is scheduled after the given duration.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectNoScheduledEventMatching

      FixtureExecutionResult expectNoScheduledEventMatching(Instant scheduledTime, org.hamcrest.Matcher<? super EventMessage> matcher)
      Asserts that no event matching the given matcher is scheduled at the given scheduledTime.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectNoScheduledEvent

      FixtureExecutionResult expectNoScheduledEvent(Instant scheduledTime, Object event)
      Asserts that the given event is not scheduled at the given scheduledTime.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectNoScheduledEventOfType

      FixtureExecutionResult expectNoScheduledEventOfType(Instant scheduledTime, Class<?> eventType)
      Asserts that no event of the given eventType is scheduled at the given scheduledTime.
      Returns:
      the FixtureExecutionResult for method chaining
      Throws:
      UnsupportedOperationException - always, as axoniq-legacy carries no event scheduler
    • expectScheduledDeadlineMatching

      FixtureExecutionResult expectScheduledDeadlineMatching(Duration duration, org.hamcrest.Matcher<? super DeadlineMessage> matcher)
      Asserts that a deadline scheduled after given duration matches the given matcher.
      Parameters:
      duration - the delay expected before the deadline is met
      matcher - the matcher that must match with the deadline scheduled at the given time
      Returns:
      the FixtureExecutionResult for method chaining
    • expectScheduledDeadline

      FixtureExecutionResult expectScheduledDeadline(Duration duration, Object deadline)
      Asserts that a deadline equal to the given deadline has been scheduled after the given duration.

      Note that the source attribute of the deadline is ignored when comparing deadlines. Deadlines are compared using an "equals" check on all fields in the deadlines.

      Parameters:
      duration - the time to wait before the deadline should be met
      deadline - the expected deadline
      Returns:
      the FixtureExecutionResult for method chaining
    • expectScheduledDeadlineOfType

      FixtureExecutionResult expectScheduledDeadlineOfType(Duration duration, Class<?> deadlineType)
      Asserts that a deadline of the given deadlineType has been scheduled after the given duration.
      Parameters:
      duration - the time to wait before the deadline is met
      deadlineType - the type of the expected deadline
      Returns:
      the FixtureExecutionResult for method chaining
    • expectScheduledDeadlineWithName

      FixtureExecutionResult expectScheduledDeadlineWithName(Duration duration, String deadlineName)
      Asserts that a deadline with the given deadlineName has been scheduled after the given duration.
      Parameters:
      duration - the time to wait before the deadline is met
      deadlineName - the name of the expected deadline
      Returns:
      the FixtureExecutionResult for method chaining
    • expectScheduledDeadlineMatching

      FixtureExecutionResult expectScheduledDeadlineMatching(Instant scheduledTime, org.hamcrest.Matcher<? super DeadlineMessage> matcher)
      Asserts that a deadline matching the given matcher has been scheduled at the given scheduledTime.

      If the scheduledTime is calculated based on the "current time", use the FixtureConfiguration.currentTime() to get the time to use as "current time".

      Parameters:
      scheduledTime - the time at which the deadline should be met
      matcher - the matcher defining the deadline expected
      Returns:
      the FixtureExecutionResult for method chaining
    • expectScheduledDeadline

      FixtureExecutionResult expectScheduledDeadline(Instant scheduledTime, Object deadline)
      Asserts that a deadline equal to the given deadline has been scheduled at the given scheduledTime.

      If the scheduledTime is calculated based on the "current time", use the FixtureConfiguration.currentTime() to get the time to use as "current time".

      Note that the source attribute of the deadline is ignored when comparing deadlines. Deadlines are compared using an "equals" check on all fields in the deadlines.

      Parameters:
      scheduledTime - the time at which the deadline is scheduled
      deadline - the expected deadline
      Returns:
      the FixtureExecutionResult for method chaining
    • expectScheduledDeadlineOfType

      FixtureExecutionResult expectScheduledDeadlineOfType(Instant scheduledTime, Class<?> deadlineType)
      Asserts that a deadline of the given deadlineType has been scheduled at the given scheduledTime.
      Parameters:
      scheduledTime - the time at which the deadline is scheduled
      deadlineType - the type of the expected deadline
      Returns:
      the FixtureExecutionResult for method chaining
    • expectScheduledDeadlineWithName

      FixtureExecutionResult expectScheduledDeadlineWithName(Instant scheduledTime, String deadlineName)
      Asserts that a deadline with the given deadlineName has been scheduled at the given scheduledTime.
      Parameters:
      scheduledTime - the time at which the deadline is scheduled
      deadlineName - the name of the expected deadline
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlines

      FixtureExecutionResult expectNoScheduledDeadlines()
      Asserts that no deadlines are scheduled. This means that either no deadlines were scheduled at all, all schedules have been cancelled or all scheduled deadlines have been met already.
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineMatching

      FixtureExecutionResult expectNoScheduledDeadlineMatching(org.hamcrest.Matcher<? super DeadlineMessage> matcher)
      Asserts that no deadline matching the given matcher is scheduled. Can be used to validate if a deadline has never been set or has been canceled.
      Parameters:
      matcher - the matcher defining the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineMatching

      FixtureExecutionResult expectNoScheduledDeadlineMatching(Duration durationToScheduledTime, org.hamcrest.Matcher<? super DeadlineMessage> matcher)
      Asserts that no deadline matching the given matcher should be scheduled after the given durationToScheduledTime. Can be used to validate if a deadline has never been set or has been canceled at an exact moment in time.
      Parameters:
      durationToScheduledTime - the time to wait until the trigger point of the deadline which should not be scheduled
      matcher - the matcher defining the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadline

      FixtureExecutionResult expectNoScheduledDeadline(Duration durationToScheduledTime, Object deadline)
      Asserts that no deadline equal to the given deadline has been scheduled after the given durationToScheduledTime. Can be used to validate if a deadline has never been set or has been canceled at an exact moment in time.

      Note that the source attribute of the deadline is ignored when comparing deadlines. Deadlines are compared using an "equals" check on all fields in the deadlines.

      Parameters:
      durationToScheduledTime - the time to wait until the trigger point of the deadline which should not be scheduled
      deadline - the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineOfType

      FixtureExecutionResult expectNoScheduledDeadlineOfType(Duration durationToScheduledTime, Class<?> deadlineType)
      Asserts that no deadline of the given deadlineType has been scheduled at the given durationToScheduledTime. Can be used to validate if a deadline has never been set or has been canceled at an exact moment in time.
      Parameters:
      durationToScheduledTime - the time to wait until the trigger point of the deadline which should not be scheduled
      deadlineType - the type of the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineWithName

      FixtureExecutionResult expectNoScheduledDeadlineWithName(Duration durationToScheduledTime, String deadlineName)
      Asserts that no deadline with the given deadlineName has been scheduled after the given durationToScheduledTime. Can be used to validate if a deadline has never been set or has been canceled at an exact moment in time.
      Parameters:
      durationToScheduledTime - the time to wait until the trigger point of the deadline which should not be scheduled
      deadlineName - the name of the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineMatching

      FixtureExecutionResult expectNoScheduledDeadlineMatching(Instant scheduledTime, org.hamcrest.Matcher<? super DeadlineMessage> matcher)
      Asserts that no deadline matching the given matcher has been scheduled at the given scheduledTime. Can be used to validate if a deadline has never been set or has been canceled at an exact moment in time.

      If the scheduledTime is calculated based on the "current time", use the FixtureConfiguration.currentTime() to get the time to use as "current time".

      Parameters:
      scheduledTime - the time at which no deadline matching the given matcher should be scheduled
      matcher - the matcher defining the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadline

      FixtureExecutionResult expectNoScheduledDeadline(Instant scheduledTime, Object deadline)
      Asserts that no deadline equal to the given deadline has been scheduled at the given scheduledTime. Can be used to validate if a deadline has never been set or has been canceled at an exact moment in time.

      If the scheduledTime is calculated based on the "current time", use the FixtureConfiguration.currentTime() to get the time to use as "current time".

      Note that the source attribute of the deadline is ignored when comparing deadlines. Deadlines are compared using an "equals" check on all fields in the deadlines.

      Parameters:
      scheduledTime - the time at which no deadline equal to the given deadline should be scheduled
      deadline - the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineOfType

      FixtureExecutionResult expectNoScheduledDeadlineOfType(Instant scheduledTime, Class<?> deadlineType)
      Asserts that no deadline with the given deadlineType has been scheduled at the given scheduledTime. Can be used to validate if a deadline has never been set or has been canceled at an exact moment in time.
      Parameters:
      scheduledTime - the time at which no deadline of deadlineType should be scheduled
      deadlineType - the type of the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineWithName

      FixtureExecutionResult expectNoScheduledDeadlineWithName(Instant scheduledTime, String deadlineName)
      Asserts that no deadline with the given deadlineName has been scheduled at the given scheduledTime. Can be used to validate if a deadline has never been set or has been canceled at an exact moment in time.
      Parameters:
      scheduledTime - the time at which no deadline of deadlineName should be scheduled
      deadlineName - the name of the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineMatching

      FixtureExecutionResult expectNoScheduledDeadlineMatching(Instant from, Instant to, org.hamcrest.Matcher<? super DeadlineMessage> matcher)
      Asserts that no deadline matching the given matcher has been scheduled between the to and from times, where to and from are inclusive. Can be used to validate if a deadline has never been set or has been canceled within a given timeframe.
      Parameters:
      from - the time from which no deadline equal to the given deadline should be scheduled (inclusive)
      to - the time until which no deadline equal to the given deadline should be scheduled (inclusive)
      matcher - the matcher defining the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadline

      FixtureExecutionResult expectNoScheduledDeadline(Instant from, Instant to, Object deadline)
      Asserts that no deadline equal to the given deadline has been scheduled between the to and from times, where to and from are inclusive. Can be used to validate if a deadline has never been set or has been canceled within a given timeframe.
      Parameters:
      from - the time from which no deadline equal to the given deadline should be scheduled (inclusive)
      to - the time until which no deadline equal to the given deadline should be scheduled (inclusive)
      deadline - the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineOfType

      FixtureExecutionResult expectNoScheduledDeadlineOfType(Instant from, Instant to, Class<?> deadlineType)
      Asserts that no deadline with the given deadlineType has been scheduled between the to and from times, where to and from are inclusive. Can be used to validate if a deadline has never been set or has been canceled within a given timeframe.
      Parameters:
      from - the time from which no deadline equal to the given deadline should be scheduled (inclusive)
      to - the time until which no deadline equal to the given deadline should be scheduled (inclusive)
      deadlineType - the type of the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectNoScheduledDeadlineWithName

      FixtureExecutionResult expectNoScheduledDeadlineWithName(Instant from, Instant to, String deadlineName)
      Asserts that no deadline with the given deadlineName has been scheduled between the to and from times, where to and from are inclusive. Can be used to validate if a deadline has never been set or has been canceled within a given timeframe.
      Parameters:
      from - the time from which no deadline equal to the given deadline should be scheduled (inclusive)
      to - the time until which no deadline equal to the given deadline should be scheduled (inclusive)
      deadlineName - the name of the deadline which should not be scheduled
      Returns:
      the FixtureExecutionResult for method chaining
    • expectDeadlinesMetMatching

      @Deprecated FixtureExecutionResult expectDeadlinesMetMatching(org.hamcrest.Matcher<? extends List<?>> matcher)
      Asserts that deadlines match given matcher have been met (which have passed in time) on this saga.
      Parameters:
      matcher - the matcher that defines the expected list of deadlines
      Returns:
      the FixtureExecutionResult for method chaining
    • expectTriggeredDeadlinesMatching

      FixtureExecutionResult expectTriggeredDeadlinesMatching(org.hamcrest.Matcher<? extends List<?>> matcher)
      Asserts that deadlines matching the given matcher have been triggered for this saga.

      The matcher is matched against the list of triggered DeadlineMessages. Axon Framework 4 typed it as a matcher of a list of a super type of DeadlineMessage, which Axon Framework 5's Matchers.payloadsMatching(Matcher) no longer satisfies, as it matches a list of a subtype of Message. The parameter therefore accepts a matcher of any list, so both compile.

      Parameters:
      matcher - the matcher that defines the expected list of deadlines
      Returns:
      the current FixtureExecutionResult for method chaining
    • expectDeadlinesMet

      @Deprecated FixtureExecutionResult expectDeadlinesMet(Object... expected)
      Deprecated.
      Asserts that given expected deadlines have been met (which have passed in time). Deadlines are compared comparing their type and fields using "equals".
      Parameters:
      expected - the sequence of deadlines expected to be met
      Returns:
      the FixtureExecutionResult for method chaining
    • expectTriggeredDeadlines

      FixtureExecutionResult expectTriggeredDeadlines(Object... expected)
      Asserts that given expected deadlines have been triggered. Deadlines are compared comparing their type and fields using "equals".
      Parameters:
      expected - the sequence of deadlines expected to have been triggered
      Returns:
      the current FixtureExecutionResult for method chaining
    • expectTriggeredDeadlinesWithName

      FixtureExecutionResult expectTriggeredDeadlinesWithName(String... expectedDeadlineNames)
      Asserts that the given expectedDeadlineNames have been triggered. Matches that the given names are complete, in the same order and match the triggered deadlines by validating with DeadlineMessage.getDeadlineName().
      Parameters:
      expectedDeadlineNames - the sequence of deadline names expected to have been triggered
      Returns:
      the current FixtureExecutionResult for method chaining
    • expectTriggeredDeadlinesOfType

      FixtureExecutionResult expectTriggeredDeadlinesOfType(Class<?>... expectedDeadlineTypes)
      Asserts that the given expectedDeadlineTypes have been triggered. Matches that the given types are complete, in the same order and match the triggered deadlines by validating with
      invalid reference
      DeadlineMessage#getPayloadType()
      .
      Parameters:
      expectedDeadlineTypes - the sequence of deadline types expected to have been triggered
      Returns:
      the current FixtureExecutionResult for method chaining