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)
Deprecated.
in favor of
expectTriggeredDeadlines(Object...) |
ResultValidator<T> |
expectDeadlinesMetMatching(org.hamcrest.Matcher<? extends List<? super DeadlineMessage<?>>> matcher)
Deprecated.
in favor of
expectTriggeredDeadlinesMatching(Matcher) |
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> |
expectExceptionDetails(Class<?> exceptionDetails)
Expect the given
exceptionDetails type to occur during command handler execution. |
ResultValidator<T> |
expectExceptionDetails(org.hamcrest.Matcher<?> matcher)
Expect exception details to occur during command handler execution that matches with the given
matcher . |
ResultValidator<T> |
expectExceptionDetails(Object exceptionDetails)
Expect the given
exceptionDetails to occur during command handler execution. |
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. |
ResultValidator<T> |
expectMarkedDeleted()
Asserts that the Aggregate has been marked for deletion.
|
default ResultValidator<T> |
expectNoEvents()
Expect no events to have been published from the command.
|
ResultValidator<T> |
expectNoScheduledDeadline(Duration durationToScheduledTime,
Object deadline)
Asserts that no deadline equal to the given
deadline has been scheduled after the given durationToScheduledTime . |
ResultValidator<T> |
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. |
ResultValidator<T> |
expectNoScheduledDeadline(Instant scheduledTime,
Object deadline)
Asserts that no deadline equal to the given
deadline has been scheduled at the given scheduledTime . |
ResultValidator<T> |
expectNoScheduledDeadlineMatching(Duration durationToScheduledTime,
org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
Asserts that no deadline matching the given
matcher should be scheduled after the given durationToScheduledTime . |
ResultValidator<T> |
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. |
ResultValidator<T> |
expectNoScheduledDeadlineMatching(Instant scheduledTime,
org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
Asserts that no deadline matching the given
matcher has been scheduled at the given scheduledTime . |
ResultValidator<T> |
expectNoScheduledDeadlineMatching(org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
Asserts that no deadline matching the given
matcher is scheduled. |
ResultValidator<T> |
expectNoScheduledDeadlineOfType(Duration durationToScheduledTime,
Class<?> deadlineType)
Asserts that no deadline of the given
deadlineType has been scheduled after the given durationToScheduledTime . |
ResultValidator<T> |
expectNoScheduledDeadlineOfType(Instant scheduledTime,
Class<?> deadlineType)
Asserts that no deadline with the given
deadlineType has been scheduled at the given scheduledTime . |
ResultValidator<T> |
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. |
ResultValidator<T> |
expectNoScheduledDeadlines()
Asserts that no deadlines are scheduled.
|
ResultValidator<T> |
expectNoScheduledDeadlineWithName(Duration durationToScheduledTime,
String deadlineName)
Asserts that no deadline with the given
deadlineName has been scheduled after the given durationToScheduledTime . |
ResultValidator<T> |
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. |
ResultValidator<T> |
expectNoScheduledDeadlineWithName(Instant scheduledTime,
String deadlineName)
Asserts that no deadline with the given
deadlineName has been scheduled at the given scheduledTime . |
ResultValidator<T> |
expectNotMarkedDeleted()
Asserts that the Aggregate has NOT been marked for deletion.
|
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> |
expectScheduledDeadlineWithName(Duration duration,
String deadlineName)
Asserts that a deadline with the given
deadlineName has been scheduled after the given duration . |
ResultValidator<T> |
expectScheduledDeadlineWithName(Instant scheduledTime,
String deadlineName)
Asserts that a deadline with the given
deadlineName 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> |
expectTriggeredDeadlines(Object... expected)
Asserts that given
expected deadlines have been triggered. |
ResultValidator<T> |
expectTriggeredDeadlinesMatching(org.hamcrest.Matcher<? extends List<? super DeadlineMessage<?>>> matcher)
Asserts that deadlines matching the given
matcher have been triggered for this aggregate. |
ResultValidator<T> |
expectTriggeredDeadlinesOfType(Class<?>... expectedDeadlineTypes)
Asserts that the given
expectedDeadlineTypes have been triggered. |
ResultValidator<T> |
expectTriggeredDeadlinesWithName(String... expectedDeadlineNames)
Asserts that the given
expectedDeadlineNames have been triggered. |
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> expectExceptionDetails(Object exceptionDetails)
exceptionDetails
to occur during command handler execution. The actual exception details
should be exactly the same as exceptionDetails
.exceptionDetails
- The exception details expected from the command handler executionResultValidator<T> expectExceptionDetails(Class<?> exceptionDetails)
exceptionDetails
type to occur during command handler execution. The actual exception details
should be exactly of that type, subclasses are not accepted.exceptionDetails
- The type of exception details expected from the command handler executionResultValidator<T> expectExceptionDetails(org.hamcrest.Matcher<?> matcher)
matcher
.matcher
- The matcher to validate the actual exception detailsResultValidator<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> expectScheduledDeadlineWithName(Duration duration, String deadlineName)
deadlineName
has been scheduled after the given duration
.duration
- the time to wait before the deadline is metdeadlineName
- the name 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> expectScheduledDeadlineWithName(Instant scheduledTime, String deadlineName)
deadlineName
has been scheduled at the given scheduledTime
.scheduledTime
- the time at which the deadline is scheduleddeadlineName
- the name of the expected deadlineResultValidator<T> expectNoScheduledDeadlines()
ResultValidator<T> expectNoScheduledDeadlineMatching(org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
matcher
is scheduled. Can be used to validate if a
deadline has never been set or has been canceled.matcher
- the matcher defining the deadline which should not be scheduledResultValidator<T> expectNoScheduledDeadlineMatching(Duration durationToScheduledTime, org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
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.durationToScheduledTime
- the time to wait until the trigger point of the deadline which should not be
scheduledmatcher
- the matcher defining the deadline which should not be scheduledResultValidator<T> expectNoScheduledDeadline(Duration durationToScheduledTime, Object deadline)
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.durationToScheduledTime
- the time to wait until the trigger point of the deadline which should not be
scheduleddeadline
- the deadline which should not be scheduledResultValidator<T> expectNoScheduledDeadlineOfType(Duration durationToScheduledTime, Class<?> deadlineType)
deadlineType
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.durationToScheduledTime
- the time to wait until the trigger point of the deadline which should not be
scheduleddeadlineType
- the type of the deadline which should not be scheduledResultValidator<T> expectNoScheduledDeadlineWithName(Duration durationToScheduledTime, String deadlineName)
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.durationToScheduledTime
- the time to wait until the trigger point of the deadline which should not be
scheduleddeadlineName
- the name of the deadline which should not be scheduledResultValidator<T> expectNoScheduledDeadlineMatching(Instant scheduledTime, org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
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 TestExecutor.currentTime()
to get the time to use as "current time".scheduledTime
- the time at which no deadline matching the given matcher
should be scheduledmatcher
- the matcher defining the deadline which should not be scheduledResultValidator<T> expectNoScheduledDeadline(Instant scheduledTime, Object deadline)
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 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 no deadline equal to the given deadline
should be scheduleddeadline
- the deadline which should not be scheduledResultValidator<T> expectNoScheduledDeadlineOfType(Instant scheduledTime, Class<?> deadlineType)
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.scheduledTime
- the time at which no deadline of deadlineType
should be scheduleddeadlineType
- the type of the deadline which should not be scheduledResultValidator<T> expectNoScheduledDeadlineWithName(Instant scheduledTime, String deadlineName)
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.scheduledTime
- the time at which no deadline of deadlineName
should be scheduleddeadlineName
- the name of the deadline which should not be scheduledResultValidator<T> expectNoScheduledDeadlineMatching(Instant from, Instant to, org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
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.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 scheduledResultValidator<T> expectNoScheduledDeadline(Instant from, Instant to, Object deadline)
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.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 scheduledResultValidator<T> expectNoScheduledDeadlineOfType(Instant from, Instant to, Class<?> deadlineType)
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.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 scheduledResultValidator<T> expectNoScheduledDeadlineWithName(Instant from, Instant to, String deadlineName)
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.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@Deprecated ResultValidator<T> expectDeadlinesMetMatching(org.hamcrest.Matcher<? extends List<? super DeadlineMessage<?>>> matcher)
expectTriggeredDeadlinesMatching(Matcher)
matcher
have been met (which have passed in time) on this aggregate.matcher
- The matcher that defines the expected list of deadlinesResultValidator<T> expectTriggeredDeadlinesMatching(org.hamcrest.Matcher<? extends List<? super DeadlineMessage<?>>> matcher)
matcher
have been triggered for this aggregate.matcher
- the matcher that defines the expected list of deadlines@Deprecated ResultValidator<T> expectDeadlinesMet(Object... expected)
expectTriggeredDeadlines(Object...)
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 metResultValidator<T> expectTriggeredDeadlines(Object... expected)
expected
deadlines have been triggered. Deadlines are compared by their type
and fields using "equals".expected
- the sequence of deadlines expected to have been triggeredResultValidator<T> expectTriggeredDeadlinesWithName(String... expectedDeadlineNames)
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()
.expectedDeadlineNames
- the sequence of deadline names expected to have been triggeredResultValidator<T> expectTriggeredDeadlinesOfType(Class<?>... expectedDeadlineTypes)
expectedDeadlineTypes
have been triggered. Matches that the given types are
complete, in the same order and match the triggered deadlines by validating with Message.getPayloadType()
.expectedDeadlineTypes
- the sequence of deadline types expected to have been triggeredResultValidator<T> expectMarkedDeleted()
ResultValidator<T> expectNotMarkedDeleted()
Copyright © 2010–2023. All rights reserved.