Class AggregateTestFixture<T>

java.lang.Object
org.axonframework.test.aggregate.AggregateTestFixture<T>
Type Parameters:
T - The type of Aggregate tested in this Fixture
All Implemented Interfaces:
FixtureConfiguration<T>, TestExecutor<T>

public class AggregateTestFixture<T> extends Object implements FixtureConfiguration<T>, TestExecutor<T>
A test fixture that allows the execution of given-when-then style test cases. For detailed usage information, see FixtureConfiguration.
Since:
0.6
Author:
Allard Buijze
  • Constructor Details

    • AggregateTestFixture

      public AggregateTestFixture(Class<T> aggregateType)
      Initializes a new given-when-then style test fixture for the given aggregateType.
      Parameters:
      aggregateType - the aggregate to initialize the test fixture for
  • Method Details

    • withSubtypes

      @SafeVarargs public final FixtureConfiguration<T> withSubtypes(Class<? extends T>... subtypes)
      Description copied from interface: FixtureConfiguration
      Registers subtypes of this aggregate to support aggregate polymorphism. Command Handlers defined on this subtype will be considered part of this aggregate's handlers.
      Specified by:
      withSubtypes in interface FixtureConfiguration<T>
      Parameters:
      subtypes - subtypes in this polymorphic hierarchy
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • useStateStorage

      public FixtureConfiguration<T> useStateStorage()
      Description copied from interface: FixtureConfiguration
      Configures the fixture for state stored aggregates. This will register an in-memory
      invalid reference
      org.axonframework.commandhandling.model.Repository
      with this fixture. Should be used before calling FixtureConfiguration.givenState(Supplier) or FixtureConfiguration.givenCommands(List) (Supplier)}.
      Specified by:
      useStateStorage in interface FixtureConfiguration<T>
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerRepository

      public FixtureConfiguration<T> registerRepository(Repository<T> repository)
      Description copied from interface: FixtureConfiguration
      Registers an arbitrary repository with the fixture. The repository must be wired with the Event Store of this test fixture.

      Should not be used in combination with FixtureConfiguration.registerAggregateFactory(org.axonframework.eventsourcing.AggregateFactory), as that will overwrite any repository previously registered.

      Specified by:
      registerRepository in interface FixtureConfiguration<T>
      Parameters:
      repository - The repository to use in the test case
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerRepositoryProvider

      public FixtureConfiguration<T> registerRepositoryProvider(RepositoryProvider repositoryProvider)
      Description copied from interface: FixtureConfiguration
      Registers repository provider with the fixture. If an aggregate being tested spawns new aggregates, this provider should be registered. Otherwise, it is not going to be invoked.
      Specified by:
      registerRepositoryProvider in interface FixtureConfiguration<T>
      Parameters:
      repositoryProvider - provides repositories for specified aggregate types
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerAggregateFactory

      public FixtureConfiguration<T> registerAggregateFactory(AggregateFactory<T> aggregateFactory)
      Description copied from interface: FixtureConfiguration
      Registers the given aggregateFactory with the fixture. The repository used by the fixture will use the given factory to create new aggregate instances. Defaults to an Aggregate Factory that uses the no-arg constructor to create new instances.

      Should not be used in combination with FixtureConfiguration.registerRepository(Repository), as that will overwrite any aggregate factory previously registered.

      Specified by:
      registerAggregateFactory in interface FixtureConfiguration<T>
      Parameters:
      aggregateFactory - The Aggregate Factory to create empty aggregates with
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerAnnotatedCommandHandler

      public FixtureConfiguration<T> registerAnnotatedCommandHandler(Object annotatedCommandHandler)
      Description copied from interface: FixtureConfiguration
      Registers an annotatedCommandHandler with this fixture. This will register this command handler with the command bus used in this fixture.
      Specified by:
      registerAnnotatedCommandHandler in interface FixtureConfiguration<T>
      Parameters:
      annotatedCommandHandler - The command handler to register for this test
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerCommandHandler

      public FixtureConfiguration<T> registerCommandHandler(Class<?> payloadType, MessageHandler<CommandMessage<?>> commandHandler)
      Description copied from interface: FixtureConfiguration
      Registers a commandHandler to handle commands of the given commandType with the command bus used by this fixture.
      Specified by:
      registerCommandHandler in interface FixtureConfiguration<T>
      Parameters:
      payloadType - The type of command to register the handler for
      commandHandler - The handler to register
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerCommandHandler

      public FixtureConfiguration<T> registerCommandHandler(String commandName, MessageHandler<CommandMessage<?>> commandHandler)
      Description copied from interface: FixtureConfiguration
      Registers a commandHandler to handle commands of the given commandType with the command bus used by this fixture.
      Specified by:
      registerCommandHandler in interface FixtureConfiguration<T>
      Parameters:
      commandName - The name of the command to register the handler for
      commandHandler - The handler to register
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerInjectableResource

      public FixtureConfiguration<T> registerInjectableResource(Object resource)
      Description copied from interface: FixtureConfiguration
      Registers a resource that is eligible for injection in handler method (e.g. methods annotated with @CommandHandler, @EventSourcingHandler and EventHandler. These resource must be registered before registering any command handler.
      Specified by:
      registerInjectableResource in interface FixtureConfiguration<T>
      Parameters:
      resource - the resource eligible for injection
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerParameterResolverFactory

      public FixtureConfiguration<T> registerParameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
      Description copied from interface: FixtureConfiguration
      Registers a ParameterResolverFactory within this fixture. The given parameterResolverFactory will be added to the other parameter resolver factories introduced through ClasspathParameterResolverFactory.forClass(Class) and the SimpleResourceParameterResolverFactory adding the registered resources (with FixtureConfiguration.registerInjectableResource(Object). The generic T is used as input for the ClasspathParameterResolverFactory#forClass(Class) operation.
      Specified by:
      registerParameterResolverFactory in interface FixtureConfiguration<T>
      Parameters:
      parameterResolverFactory - the ParameterResolver to register within this fixture
      Returns:
      the current FixtureConfiguration, for fluent interfacing
      See Also:
    • registerCommandDispatchInterceptor

      public FixtureConfiguration<T> registerCommandDispatchInterceptor(MessageDispatchInterceptor<? super CommandMessage<?>> commandDispatchInterceptor)
      Description copied from interface: FixtureConfiguration
      Register a MessageDispatchInterceptor for CommandMessages which will be invoked before any command is dispatched on the CommandBus to perform a task specified in the interceptor. For example by adding MetaData or throwing an exception based on the command.
      Specified by:
      registerCommandDispatchInterceptor in interface FixtureConfiguration<T>
      Parameters:
      commandDispatchInterceptor - the MessageDispatchInterceptor for CommandMessages to be added to this fixture's CommandBus
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerCommandHandlerInterceptor

      public FixtureConfiguration<T> registerCommandHandlerInterceptor(MessageHandlerInterceptor<? super CommandMessage<?>> commandHandlerInterceptor)
      Description copied from interface: FixtureConfiguration
      Register a MessageHandlerInterceptor for CommandMessages which will be invoked before or after the command has been dispatched on the CommandBus to perform a task specified in the interceptor. It could for example block the command for security reasons or add auditing to the command bus
      Specified by:
      registerCommandHandlerInterceptor in interface FixtureConfiguration<T>
      Parameters:
      commandHandlerInterceptor - the MessageHandlerInterceptor for CommandMessages to be added to this fixture's CommandBus
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerDeadlineDispatchInterceptor

      public FixtureConfiguration<T> registerDeadlineDispatchInterceptor(MessageDispatchInterceptor<? super DeadlineMessage<?>> deadlineDispatchInterceptor)
      Description copied from interface: FixtureConfiguration
      Registers a deadline dispatch interceptor which will always be invoked before a deadline is dispatched (scheduled) on the DeadlineManager to perform a task specified in the interceptor.
      Specified by:
      registerDeadlineDispatchInterceptor in interface FixtureConfiguration<T>
      Parameters:
      deadlineDispatchInterceptor - the interceptor for dispatching (scheduling) deadlines
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerDeadlineHandlerInterceptor

      public FixtureConfiguration<T> registerDeadlineHandlerInterceptor(MessageHandlerInterceptor<? super DeadlineMessage<?>> deadlineHandlerInterceptor)
      Description copied from interface: FixtureConfiguration
      Registers a deadline handler interceptor which will always be invoked before a deadline is handled to perform a task specified in the interceptor.
      Specified by:
      registerDeadlineHandlerInterceptor in interface FixtureConfiguration<T>
      Parameters:
      deadlineHandlerInterceptor - the interceptor for handling deadlines
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerFieldFilter

      public FixtureConfiguration<T> registerFieldFilter(FieldFilter fieldFilter)
      Description copied from interface: FixtureConfiguration
      Registers the given fieldFilter, which is used to define which Fields are used when comparing objects. The ResultValidator.expectEvents(Object...) and ResultValidator.expectResultMessagePayload(Object), for example, use this filter.

      When multiple filters are registered, a Field must be accepted by all registered filters in order to be accepted.

      By default, all Fields are included in the comparison.

      Specified by:
      registerFieldFilter in interface FixtureConfiguration<T>
      Parameters:
      fieldFilter - The FieldFilter that defines which fields to include in the comparison
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerIgnoredField

      public FixtureConfiguration<T> registerIgnoredField(Class<?> declaringClass, String fieldName)
      Description copied from interface: FixtureConfiguration
      Indicates that a field with given fieldName, which is declared in given declaringClass is ignored when performing deep equality checks.
      Specified by:
      registerIgnoredField in interface FixtureConfiguration<T>
      Parameters:
      declaringClass - The class declaring the field
      fieldName - The name of the field
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerHandlerDefinition

      public FixtureConfiguration<T> registerHandlerDefinition(HandlerDefinition handlerDefinition)
      Description copied from interface: FixtureConfiguration
      Registers a HandlerDefinition within this fixture. The given handlerDefinition is added to the handler definitions introduced through ClasspathHandlerDefinition.forClass(Class). The generic T is used as input for the ClasspathHandlerDefinition#forClass(Class) operation.
      Specified by:
      registerHandlerDefinition in interface FixtureConfiguration<T>
      Parameters:
      handlerDefinition - used to create concrete handlers
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerHandlerEnhancerDefinition

      public FixtureConfiguration<T> registerHandlerEnhancerDefinition(HandlerEnhancerDefinition handlerEnhancerDefinition)
      Description copied from interface: FixtureConfiguration
      Registers a HandlerEnhancerDefinition within this fixture. This given handlerEnhancerDefinition is added to the handler enhancer definitions introduced through ClasspathHandlerEnhancerDefinition.forClass(Class). The generic T is used as input for the ClasspathHandlerEnhancerDefinition#forClass(Class) operation.
      Specified by:
      registerHandlerEnhancerDefinition in interface FixtureConfiguration<T>
      Parameters:
      handlerEnhancerDefinition - the HandlerEnhancerDefinition to register within this fixture
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • registerCommandTargetResolver

      public FixtureConfiguration<T> registerCommandTargetResolver(CommandTargetResolver commandTargetResolver)
      Description copied from interface: FixtureConfiguration
      Registers the CommandTargetResolver within this fixture. The commandTargetResolver will replace the default implementation (defined by the AggregateAnnotationCommandHandler within this fixture.
      Specified by:
      registerCommandTargetResolver in interface FixtureConfiguration<T>
      Parameters:
      commandTargetResolver - the CommandTargetResolver used to resolve an Aggregate for a given command
      Returns:
      the current FixtureConfiguration, for fluent interfacing
    • given

      public TestExecutor<T> given(Object... domainEvents)
      Description copied from interface: FixtureConfiguration
      Configures the given domainEvents as the "given" events. These are the events returned by the event store when an aggregate is loaded.

      If an item in the given domainEvents implements Message, the payload and MetaData from that Message are copied into a newly created DomainEventMessage. Otherwise, a DomainEventMessage with the item as payload and empty MetaData is created.

      Note that transitioning to the returned TestExecutor will clear any previously defined "given" state to ensure the fixture can run a clean test environment.

      Specified by:
      given in interface FixtureConfiguration<T>
      Parameters:
      domainEvents - The domain events the event store should return.
      Returns:
      A TestExecutor instance that can execute the test with this configuration.
    • andGiven

      public TestExecutor<T> andGiven(Object... domainEvents)
      Description copied from interface: TestExecutor
      Configures the given domainEvents as the "given" events. These are the events returned by the event store when an aggregate is loaded.

      If an item in the given domainEvents implements Message, the payload and meta-data from that message are copied into a newly created Domain Event Message. Otherwise, a Domain Event Message with the item as payload and empty meta-data is created.

      Specified by:
      andGiven in interface TestExecutor<T>
      Parameters:
      domainEvents - the domain events the event store should return
      Returns:
      a TestExecutor instance that can execute the test with this configuration
    • givenNoPriorActivity

      public TestExecutor<T> givenNoPriorActivity()
      Description copied from interface: FixtureConfiguration
      Indicates that no relevant activities like commands or events have occurred in the past. This also means that no previous state is present in the repository.
      Specified by:
      givenNoPriorActivity in interface FixtureConfiguration<T>
      Returns:
      A TestExecutor instance that can execute the test with this configuration.
    • givenState

      public TestExecutor<T> givenState(Supplier<T> aggregate)
      Description copied from interface: FixtureConfiguration
      Sets the aggregate instance as supplied by given aggregateState as the initial state for a test case.

      Usage of this method is highly discouraged for event sourced aggregates. In that case, use FixtureConfiguration.given(Object...) to specify historic events.

      Note that transitioning to the returned TestExecutor will clear any previously defined "given" state to ensure the fixture can run a clean test environment.

      Specified by:
      givenState in interface FixtureConfiguration<T>
      Parameters:
      aggregate - A Supplier providing the state to use as starting point for this fixture.
      Returns:
      A TestExecutor instance that can execute the test with this configuration.
    • given

      public TestExecutor<T> given(List<?> domainEvents)
      Description copied from interface: FixtureConfiguration
      Configures the given domainEvents as the "given" events. These are the events returned by the event store when an aggregate is loaded.

      If an item in the list implements Message, the payload and MetaData from that Message are copied into a newly created DomainEventMessage. Otherwise, a DomainEventMessage with the item as payload and empty MetaData is created.

      Note that transitioning to the returned TestExecutor will clear any previously defined "given" state to ensure the fixture can run a clean test environment.

      Specified by:
      given in interface FixtureConfiguration<T>
      Parameters:
      domainEvents - The domain events the event store should return.
      Returns:
      A TestExecutor instance that can execute the test with this configuration.
    • andGiven

      public TestExecutor<T> andGiven(List<?> domainEvents)
      Description copied from interface: TestExecutor
      Configures the given domainEvents as the "given" events. These are the events returned by the event store when an aggregate is loaded.

      If an item in the list implements Message, the payload and meta-data from that message are copied into a newly created Domain Event Message. Otherwise, a Domain Event Message with the item as payload and empty meta-data is created.

      Specified by:
      andGiven in interface TestExecutor<T>
      Parameters:
      domainEvents - the domain events the event store should return
      Returns:
      a TestExecutor instance that can execute the test with this configuration
    • givenCommands

      public TestExecutor<T> givenCommands(Object... commands)
      Description copied from interface: FixtureConfiguration
      Configures the given commands as to execute against the aggregate under test to initiate the given-phase. The commands are executed, and the resulting stored events are captured.

      Note that transitioning to the returned TestExecutor will clear any previously defined "given" state to ensure the fixture can run a clean test environment.

      Specified by:
      givenCommands in interface FixtureConfiguration<T>
      Parameters:
      commands - The commands to execute against the aggregate under test to initiate the given-phase.
      Returns:
      A TestExecutor instance that can execute the test with this configuration.
    • andGivenCommands

      public TestExecutor<T> andGivenCommands(Object... commands)
      Description copied from interface: TestExecutor
      Configures the given commands as the command that will provide the "given" events. The commands are executed, and the resulting stored events are captured.
      Specified by:
      andGivenCommands in interface TestExecutor<T>
      Parameters:
      commands - the domain events the event store should return
      Returns:
      a TestExecutor instance that can execute the test with this configuration
    • givenCommands

      public TestExecutor<T> givenCommands(List<?> commands)
      Description copied from interface: FixtureConfiguration
      Configures the given commands as to execute against the aggregate under test to initiate the given-phase. The commands are executed, and the resulting stored events are captured.

      Note that transitioning to the returned TestExecutor will clear any previously defined "given" state to ensure the fixture can run a clean test environment.

      Specified by:
      givenCommands in interface FixtureConfiguration<T>
      Parameters:
      commands - The commands to execute against the aggregate under test to initiate the given-phase.
      Returns:
      A TestExecutor instance that can execute the test with this configuration.
    • andGivenCommands

      public TestExecutor<T> andGivenCommands(List<?> commands)
      Description copied from interface: TestExecutor
      Configures the given commands as the command that will provide the "given" events. The commands are executed, and the resulting stored events are captured.
      Specified by:
      andGivenCommands in interface TestExecutor<T>
      Parameters:
      commands - the domain events the event store should return
      Returns:
      a TestExecutor instance that can execute the test with this configuration
    • givenCurrentTime

      public TestExecutor<T> givenCurrentTime(Instant currentTime)
      Description copied from interface: FixtureConfiguration
      Use this method to indicate a specific moment as the initial current time "known" by the fixture at the start of the given state.

      Note that transitioning to the returned TestExecutor will clear any previously defined "given" state to ensure the fixture can run a clean test environment.

      Specified by:
      givenCurrentTime in interface FixtureConfiguration<T>
      Parameters:
      currentTime - An Instant defining the simulated "current time" at which the given state is initialized.
      Returns:
      A TestExecutor instance that can execute the test with this configuration.
    • andGivenCurrentTime

      public TestExecutor<T> andGivenCurrentTime(Instant currentTime)
      Description copied from interface: TestExecutor
      Use this method to indicate a specific moment as the initial current time "known" by the fixture at the start of the given state.
      Specified by:
      andGivenCurrentTime in interface TestExecutor<T>
      Parameters:
      currentTime - The simulated "current time" at which the given state is initialized
      Returns:
      a TestExecutor instance that can execute the test with this configuration
    • currentTime

      public Instant currentTime()
      Description copied from interface: TestExecutor
      Returns the time as "known" by the fixture. This is the time at which the fixture was created, plus the amount of time the fixture was told to simulate a "wait".
      Specified by:
      currentTime in interface TestExecutor<T>
      Returns:
      the simulated "current time" of the fixture.
    • whenTimeElapses

      public ResultValidator<T> whenTimeElapses(Duration elapsedTime)
      Description copied from interface: TestExecutor
      Simulates the time elapsing in the current given state using a Duration as the unit of time. This can be useful when the time between given events is of importance, for example when leveraging the DeadlineManager to schedule deadlines in the context of a given Aggregate.

      Note: As this method is added to the interface as a replacement for the deprecated TestExecutor.whenThenTimeAdvancesTo(Instant) method, and in case there are other implementations by 3rd party libraries, this method is changed to a default method that rely on the deprecated method so that there is no breaking changes in the API in case an external implementation of this interface. Nevertheless, the recommended approach is to override this implementation.

      Specified by:
      whenTimeElapses in interface TestExecutor<T>
      Parameters:
      elapsedTime - a Duration specifying the amount of time that will elapse
      Returns:
      a ResultValidator that can be used to validate the resulting actions of the command execution
    • whenThenTimeElapses

      @Deprecated public ResultValidator<T> whenThenTimeElapses(Duration elapsedTime)
      Deprecated.
      Description copied from interface: TestExecutor
      Simulates the time elapsing in the current given state using a Duration as the unit of time. This can be useful when the time between given events is of importance, for example when leveraging the DeadlineManager to schedule deadlines in the context of a given Aggregate.
      Specified by:
      whenThenTimeElapses in interface TestExecutor<T>
      Parameters:
      elapsedTime - a Duration specifying the amount of time that will elapse
      Returns:
      a ResultValidator that can be used to validate the resulting actions of the command execution
    • whenTimeAdvancesTo

      public ResultValidator<T> whenTimeAdvancesTo(Instant newPointInTime)
      Description copied from interface: TestExecutor
      Simulates the time advancing in the current given state using an Instant as the unit of time. This can be useful when the time between given events is of importance, for example when leveraging the DeadlineManager to schedule deadlines in the context of a given Aggregate.

      Note: As this method is added to the interface as a replacement for the deprecated TestExecutor.whenThenTimeAdvancesTo(Instant) method, and in case there are other implementations by 3rd party libraries, this method is changed to a default method that rely on the deprecated method so that there is no breaking changes in the API in case an external implementation of this interface. Nevertheless, the recommended approach is to override this implementation.

      Specified by:
      whenTimeAdvancesTo in interface TestExecutor<T>
      Parameters:
      newPointInTime - an Instant specifying the amount of time to advance the clock to
      Returns:
      a ResultValidator that can be used to validate the resulting actions of the command execution
    • whenThenTimeAdvancesTo

      @Deprecated public ResultValidator<T> whenThenTimeAdvancesTo(Instant newPointInTime)
      Deprecated.
      Description copied from interface: TestExecutor
      Simulates the time advancing in the current given state using an Instant as the unit of time. This can be useful when the time between given events is of importance, for example when leveraging the DeadlineManager to schedule deadlines in the context of a given Aggregate.
      Specified by:
      whenThenTimeAdvancesTo in interface TestExecutor<T>
      Parameters:
      newPointInTime - an Instant specifying the amount of time to advance the clock to
      Returns:
      a ResultValidator that can be used to validate the resulting actions of the command execution
    • when

      public ResultValidator<T> when(Object command)
      Description copied from interface: TestExecutor
      Dispatches the given command to the appropriate command handler and records all activity in the fixture for result validation. If the given command is a CommandMessage instance, it will be dispatched as-is. Any other object will cause the given command to be wrapped in a CommandMessage as its payload.
      Specified by:
      when in interface TestExecutor<T>
      Parameters:
      command - The command to execute
      Returns:
      a ResultValidator that can be used to validate the resulting actions of the command execution
    • when

      public ResultValidator<T> when(Object command, Map<String,?> metaData)
      Description copied from interface: TestExecutor
      Dispatches the given command and meta-data to the appropriate command handler and records all activity in the fixture for result validation. If the given command is a CommandMessage instance, it will be dispatched as-is, with given additional metaData. Any other object will cause the given command to be wrapped in a CommandMessage as its payload.
      Specified by:
      when in interface TestExecutor<T>
      Parameters:
      command - The command to execute
      metaData - The meta-data to attach to the
      Returns:
      a ResultValidator that can be used to validate the resulting actions of the command execution
    • whenConstructing

      public ResultValidator<T> whenConstructing(Callable<T> aggregateFactory)
      Description copied from interface: TestExecutor
      Invokes the given aggregateFactory expecting an aggregate instance of type T to be returned.

      All activity is recorded in the fixture for result validation. The aggregateFactory typically refers to one of the aggregate's constructors.

      You should use this when-phase operation whenever you do not use the CommandHandler annotation on the aggregate's methods, nor have registered an external command handler invoking the Repository.

      Specified by:
      whenConstructing in interface TestExecutor<T>
      Parameters:
      aggregateFactory - A callable operation expecting an aggregate instance of type T to be returned. This typically is an aggregate constructor invocation.
      Returns:
      a ResultValidator that can be used to validate the resulting actions of executing the given aggregateFactory.
    • whenInvoking

      public ResultValidator<T> whenInvoking(String aggregateId, Consumer<T> aggregateSupplier)
      Description copied from interface: TestExecutor
      Invokes the given aggregateConsumer after loading an aggregate of type T based on the given aggregateIdentifier.

      All activity is recorded in the fixture for result validation.

      You should use this when-phase operation whenever you do not use the CommandHandler annotation on the aggregate's methods, nor have registered an external command handler invoking the Repository.

      Specified by:
      whenInvoking in interface TestExecutor<T>
      Parameters:
      aggregateId - The identifier of the aggregate to Repository.load(String).
      aggregateSupplier - A lambda providing an aggregate instance of type T based on the given aggregateIdentifier.
      Returns:
      a ResultValidator that can be used to validate the resulting actions of executing the given aggregateConsumer.
    • handleDeadline

      protected void handleDeadline(ScopeDescriptor aggregateDescriptor, DeadlineMessage<?> deadlineMessage) throws Exception
      Handles the given deadlineMessage in the aggregate described by the given aggregateDescriptor. Deadline message is handled in the scope of a UnitOfWork. If handling the deadline results in an exception, the exception will be wrapped in a FixtureExecutionException.
      Parameters:
      aggregateDescriptor - A ScopeDescriptor describing the aggregate under test
      deadlineMessage - The DeadlineMessage to be handled
      Throws:
      Exception
    • setReportIllegalStateChange

      public void setReportIllegalStateChange(boolean reportIllegalStateChange)
      Description copied from interface: FixtureConfiguration
      Sets whether or not the fixture should detect and report state changes that occur outside of Event Handler methods.
      Specified by:
      setReportIllegalStateChange in interface FixtureConfiguration<T>
      Parameters:
      reportIllegalStateChange - whether or not to detect and report state changes outside of Event Handler methods.
    • getCommandBus

      public CommandBus getCommandBus()
      Description copied from interface: FixtureConfiguration
      Returns the command bus used by this fixture. The command bus is provided for wiring purposes only, for example to support composite commands (a single command that causes the execution of one or more others).
      Specified by:
      getCommandBus in interface FixtureConfiguration<T>
      Returns:
      the command bus used by this fixture
    • getEventBus

      public EventBus getEventBus()
      Description copied from interface: FixtureConfiguration
      Returns the event bus used by this fixture. The event bus is provided for wiring purposes only, for example to allow command handlers to publish events other than Domain Events. Events published on the returned event bus are recorded an evaluated in the ResultValidator operations.
      Specified by:
      getEventBus in interface FixtureConfiguration<T>
      Returns:
      the event bus used by this fixture
    • getEventStore

      public EventStore getEventStore()
      Description copied from interface: FixtureConfiguration
      Returns the event store used by this fixture. This event store is provided for wiring purposes only.
      Specified by:
      getEventStore in interface FixtureConfiguration<T>
      Returns:
      the event store used by this fixture
    • getRepository

      public Repository<T> getRepository()
      Description copied from interface: FixtureConfiguration
      Returns the repository used by this fixture. This repository is provided for wiring purposes only. The repository is configured to use the fixture's event store to load events.
      Specified by:
      getRepository in interface FixtureConfiguration<T>
      Returns:
      the repository used by this fixture