Check for markDeleted in AggregateTestFixture

Hi Vilmos,

The Test Fixtures do indeed use the EventSourcingRepository internally, granted that you have written your Aggregate to utilize Event Sourcing.

If you take the State-Stored Aggregate route, the used repository will become a InMemoryRepository, which will be triggered if you use the FixtureConfiguration#givenState(Supplier<T>) method.

It’s the storage mechanism, the EventStore which is of a specific type called the RecordingEventStore.

Thus your assumption on the fact the Test Fixtures use ‘some special implementations’ is correct, just not on every component. :slight_smile:

Added, the stack trace you’ve shared point out an ‘illegal state change’ was detected after the when operation was performed.
As you are Event Sourcing your Aggregate, it is a strict requirement to not perform any state changes on handling a command.

Adjusting the Aggregate to be deleted through the AggregateLifecycle#markDeleted() method is however a state change, which thus should be performed in an Event Sourcing Handler.

If this was not enforced you could have the scenario that on another Command coming in for the given Aggregate that was marked deleted, that it would be Sourced from it’s Events without knowing it was actually marked as deleted.

Hope this clarifies some things Vilmos.

Cheers,
Steven