T
- The type of Aggregate under testpublic interface ResultValidator<T>
TestExecutor
.
There are several things to validate:
void
return value, orModifier and Type | Method and Description |
---|---|
ResultValidator<T> |
expectDeadlinesMet(Object... expected)
Asserts that given
expected deadlines have been met (which have passed in time). |
ResultValidator<T> |
expectDeadlinesMetMatching(org.hamcrest.Matcher<? extends List<? super DeadlineMessage<?>>> matcher)
Asserts that deadlines match given
matcher have been met (which have passed in time) on this aggregate. |
ResultValidator<T> |
expectEvents(EventMessage... expectedEvents)
Expect the given set of events to have been published.
|
ResultValidator<T> |
expectEvents(Object... expectedEvents)
Expect the given set of events to have been published.
|
ResultValidator<T> |
expectEventsMatching(org.hamcrest.Matcher<? extends List<? super EventMessage<?>>> matcher)
Expect the published events to match the given
matcher . |
ResultValidator<T> |
expectException(Class<? extends Throwable> expectedException)
Expect the given
expectedException to occur during command handler execution. |
ResultValidator<T> |
expectException(org.hamcrest.Matcher<?> matcher)
Expect an exception to occur during command handler execution that matches with the given
matcher . |
ResultValidator<T> |
expectExceptionMessage(org.hamcrest.Matcher<?> matcher)
Expect an exception message to occur during command handler execution that matches with the given
matcher . |
ResultValidator<T> |
expectExceptionMessage(String exceptionMessage)
Expect the given
exceptionMessage to occur during command handler execution. |
default ResultValidator<T> |
expectNoEvents()
Expect no events to have been published from the command.
|
ResultValidator<T> |
expectNoScheduledDeadlines()
Asserts that no deadlines are scheduled.
|
ResultValidator<T> |
expectResultMessage(CommandResultMessage expectedResultMessage)
Expect the command handler to return the given
expectedResultMessage after execution. |
ResultValidator<T> |
expectResultMessageMatching(org.hamcrest.Matcher<? super CommandResultMessage<?>> matcher)
Expect the command handler to return a value that matches the given
matcher after execution. |
ResultValidator<T> |
expectResultMessagePayload(Object expectedPayload)
Expect the command handler to return the given
expectedPayload after execution. |
ResultValidator<T> |
expectResultMessagePayloadMatching(org.hamcrest.Matcher<?> matcher)
Expect the command handler to return a payload that matches the given
matcher after execution. |
ResultValidator<T> |
expectScheduledDeadline(Duration duration,
Object deadline)
Asserts that a deadline equal to the given
deadline has been scheduled after the given duration . |
ResultValidator<T> |
expectScheduledDeadline(Instant scheduledTime,
Object deadline)
Asserts that a deadline equal to the given
deadline has been scheduled at the given scheduledTime . |
ResultValidator<T> |
expectScheduledDeadlineMatching(Duration duration,
org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
Asserts that a deadline scheduled after given
duration matches the given matcher . |
ResultValidator<T> |
expectScheduledDeadlineMatching(Instant scheduledTime,
org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
Asserts that a deadline matching the given
matcher has been scheduled at the given scheduledTime . |
ResultValidator<T> |
expectScheduledDeadlineOfType(Duration duration,
Class<?> deadlineType)
Asserts that a deadline of the given
deadlineType has been scheduled after the given duration . |
ResultValidator<T> |
expectScheduledDeadlineOfType(Instant scheduledTime,
Class<?> deadlineType)
Asserts that a deadline of the given
deadlineType has been scheduled at the given scheduledTime . |
ResultValidator<T> |
expectState(Consumer<T> aggregateStateValidator)
Provides access the the state of the Aggregate as it was stored in the repository, allowing for validation of the
state of the aggregate, as it was left in the repository.
|
ResultValidator<T> |
expectSuccessfulHandlerExecution()
Expect a successful execution of the given command handler, regardless of the actual return value.
|
ResultValidator<T> expectEvents(Object... expectedEvents)
All events are compared for equality using a shallow equals comparison on all the fields of the events. This means that all assigned values on the events' fields should have a proper equals implementation.
Note that the event identifier is ignored in the comparison.
expectedEvents
- The expected events, in the exact order they are expected to be dispatched and stored.ResultValidator<T> expectEvents(EventMessage... expectedEvents)
All events are compared for equality using a shallow equals comparison on all the fields of the events. This
means that all assigned values on the events' fields should have a proper equals implementation.
Additionally the metadata will be compared too.
Note that the event identifier is ignored in the comparison.
expectedEvents
- The expected events, in the exact order they are expected to be dispatched and stored.default ResultValidator<T> expectNoEvents()
ResultValidator<T> expectEventsMatching(org.hamcrest.Matcher<? extends List<? super EventMessage<?>>> matcher)
matcher
.
Note: if no events were published, the matcher receives an empty List.
matcher
- The matcher to match with the actually published eventsResultValidator<T> expectResultMessagePayload(Object expectedPayload)
expectedPayload
after execution. The actual and
expected values are compared using their equals methods.expectedPayload
- The expected result message payload of the command executionResultValidator<T> expectResultMessagePayloadMatching(org.hamcrest.Matcher<?> matcher)
matcher
after execution.matcher
- The matcher to verify the actual return value againstResultValidator<T> expectResultMessage(CommandResultMessage expectedResultMessage)
expectedResultMessage
after execution. The actual and
expected values are compared using their equals methods.
Comparison is done on message payload and meta data.
expectedResultMessage
- The expected result message of the command executionResultValidator<T> expectResultMessageMatching(org.hamcrest.Matcher<? super CommandResultMessage<?>> matcher)
matcher
after execution.matcher
- The matcher to verify the actual result message againstResultValidator<T> expectExceptionMessage(org.hamcrest.Matcher<?> matcher)
matcher
.matcher
- The matcher to validate the actual exception messageResultValidator<T> expectExceptionMessage(String exceptionMessage)
exceptionMessage
to occur during command handler execution. The actual exception
message should be exactly the same as exceptionMessage
.exceptionMessage
- The exception message expected from the command handler executionResultValidator<T> expectException(Class<? extends Throwable> expectedException)
expectedException
to occur during command handler execution. The actual exception
should be exactly of that type, subclasses are not accepted.expectedException
- The type of exception expected from the command handler executionResultValidator<T> expectException(org.hamcrest.Matcher<?> matcher)
matcher
.matcher
- The matcher to validate the actual exceptionResultValidator<T> expectSuccessfulHandlerExecution()
ResultValidator<T> expectState(Consumer<T> aggregateStateValidator)
Note that validating state on Event Sourced Aggregate is highly discouraged. Event Sourced aggregates should measure behavior exclusively by measuring emitted events.
aggregateStateValidator
- a consumer that is provided with the aggregate instance, allowing it to make
assertions based on the aggregate's state.IllegalStateException
- when an error in Command execution caused the Unit of Work to be rolled back.ResultValidator<T> expectScheduledDeadlineMatching(Duration duration, org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
duration
matches the given matcher
.duration
- The delay expected before the deadline is metmatcher
- The matcher that must match with the deadline scheduled at the given timeResultValidator<T> expectScheduledDeadline(Duration duration, Object deadline)
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.duration
- The time to wait before the deadline should be metdeadline
- The expected deadlineResultValidator<T> expectScheduledDeadlineOfType(Duration duration, Class<?> deadlineType)
deadlineType
has been scheduled after the given duration
.duration
- The time to wait before the deadline is metdeadlineType
- The type of the expected deadlineResultValidator<T> expectScheduledDeadlineMatching(Instant scheduledTime, org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
matcher
has been scheduled at the given scheduledTime
.
If the scheduledTime
is calculated based on the "current time", use the TestExecutor.currentTime()
to get the time to use as "current time".scheduledTime
- The time at which the deadline should be metmatcher
- The matcher defining the deadline expectedResultValidator<T> expectScheduledDeadline(Instant scheduledTime, Object deadline)
deadline
has been scheduled at the given scheduledTime
.
If the scheduledTime
is calculated based on the "current time", use the TestExecutor.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.scheduledTime
- The time at which the deadline is scheduleddeadline
- The expected deadlineResultValidator<T> expectScheduledDeadlineOfType(Instant scheduledTime, Class<?> deadlineType)
deadlineType
has been scheduled at the given scheduledTime
.scheduledTime
- The time at which the deadline is scheduleddeadlineType
- The type of the expected deadlineResultValidator<T> expectNoScheduledDeadlines()
ResultValidator<T> expectDeadlinesMetMatching(org.hamcrest.Matcher<? extends List<? super DeadlineMessage<?>>> matcher)
matcher
have been met (which have passed in time) on this aggregate.matcher
- The matcher that defines the expected list of deadlinesResultValidator<T> expectDeadlinesMet(Object... expected)
expected
deadlines have been met (which have passed in time). Deadlines are compared
comparing their type and fields using "equals".expected
- The sequence of deadlines expected to be metCopyright © 2010–2019. All rights reserved.