public class ResultValidatorImpl<T> extends Object implements ResultValidator<T>, CommandCallback<Object,Object>
| Constructor and Description |
|---|
ResultValidatorImpl(List<EventMessage<?>> publishedEvents,
FieldFilter fieldFilter,
Supplier<Aggregate<T>> aggregateState,
StubDeadlineManager stubDeadlineManager)
Initialize the ResultValidatorImpl with the given
storedEvents and publishedEvents. |
| Modifier and Type | Method and Description |
|---|---|
void |
assertValidRecording()
Makes sure the execution phase has finishes without any Errors ir FixtureExecutionExceptions.
|
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<?> exceptionMessageMatcher)
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.
|
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 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 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> |
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 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.
|
void |
onResult(CommandMessage<?> commandMessage,
CommandResultMessage<?> commandResultMessage)
Invoked when command handling execution is completed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexpectNoEventspublic ResultValidatorImpl(List<EventMessage<?>> publishedEvents, FieldFilter fieldFilter, Supplier<Aggregate<T>> aggregateState, StubDeadlineManager stubDeadlineManager)
storedEvents and publishedEvents.publishedEvents - The events that were published during command executionfieldFilter - The filter describing which fields to include in the comparisonpublic ResultValidator<T> expectEvents(Object... expectedEvents)
ResultValidatorAll 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.
expectEvents in interface ResultValidator<T>expectedEvents - The expected events, in the exact order they are expected to be dispatched and stored.public ResultValidator<T> expectEvents(EventMessage<?>... expectedEvents)
ResultValidator
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.
expectEvents in interface ResultValidator<T>expectedEvents - The expected events, in the exact order they are expected to be dispatched and stored.public ResultValidator<T> expectEventsMatching(org.hamcrest.Matcher<? extends List<? super EventMessage<?>>> matcher)
ResultValidatormatcher.
Note: if no events were published, the matcher receives an empty List.
expectEventsMatching in interface ResultValidator<T>matcher - The matcher to match with the actually published eventspublic ResultValidator<T> expectSuccessfulHandlerExecution()
ResultValidatorexpectSuccessfulHandlerExecution in interface ResultValidator<T>public ResultValidator<T> expectState(Consumer<T> aggregateStateValidator)
ResultValidatorNote that validating state on Event Sourced Aggregate is highly discouraged. Event Sourced aggregates should measure behavior exclusively by measuring emitted events.
expectState in interface ResultValidator<T>aggregateStateValidator - a consumer that is provided with the aggregate instance, allowing it to make
assertions based on the aggregate's state.public ResultValidator<T> expectScheduledDeadlineMatching(Duration duration, org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
ResultValidatorduration matches the given matcher.expectScheduledDeadlineMatching in interface ResultValidator<T>duration - the delay expected before the deadline is metmatcher - the matcher that must match with the deadline scheduled at the given timepublic ResultValidator<T> expectScheduledDeadline(Duration duration, Object deadline)
ResultValidatordeadline 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.expectScheduledDeadline in interface ResultValidator<T>duration - the time to wait before the deadline should be metdeadline - the expected deadlinepublic ResultValidator<T> expectScheduledDeadlineOfType(Duration duration, Class<?> deadlineType)
ResultValidatordeadlineType has been scheduled after the given duration.expectScheduledDeadlineOfType in interface ResultValidator<T>duration - the time to wait before the deadline is metdeadlineType - the type of the expected deadlinepublic ResultValidator<T> expectScheduledDeadlineWithName(Duration duration, String deadlineName)
ResultValidatordeadlineName has been scheduled after the given duration.expectScheduledDeadlineWithName in interface ResultValidator<T>duration - the time to wait before the deadline is metdeadlineName - the name of the expected deadlinepublic ResultValidator<T> expectScheduledDeadlineMatching(Instant scheduledTime, org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
ResultValidatormatcher 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".expectScheduledDeadlineMatching in interface ResultValidator<T>scheduledTime - the time at which the deadline should be metmatcher - the matcher defining the deadline expectedpublic ResultValidator<T> expectScheduledDeadline(Instant scheduledTime, Object deadline)
ResultValidatordeadline 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.expectScheduledDeadline in interface ResultValidator<T>scheduledTime - the time at which the deadline is scheduleddeadline - the expected deadlinepublic ResultValidator<T> expectScheduledDeadlineOfType(Instant scheduledTime, Class<?> deadlineType)
ResultValidatordeadlineType has been scheduled at the given scheduledTime.expectScheduledDeadlineOfType in interface ResultValidator<T>scheduledTime - the time at which the deadline is scheduleddeadlineType - the type of the expected deadlinepublic ResultValidator<T> expectScheduledDeadlineWithName(Instant scheduledTime, String deadlineName)
ResultValidatordeadlineName has been scheduled at the given scheduledTime.expectScheduledDeadlineWithName in interface ResultValidator<T>scheduledTime - the time at which the deadline is scheduleddeadlineName - the name of the expected deadlinepublic ResultValidator<T> expectNoScheduledDeadlines()
ResultValidatorexpectNoScheduledDeadlines in interface ResultValidator<T>public ResultValidator<T> expectNoScheduledDeadlineMatching(org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
ResultValidatormatcher is scheduled. Can be used to validate if a
deadline has never been set or has been canceled.expectNoScheduledDeadlineMatching in interface ResultValidator<T>matcher - the matcher defining the deadline which should not be scheduledpublic ResultValidator<T> expectNoScheduledDeadlineMatching(Duration durationToScheduledTime, org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
ResultValidatormatcher 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.expectNoScheduledDeadlineMatching in interface ResultValidator<T>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 scheduledpublic ResultValidator<T> expectNoScheduledDeadline(Duration durationToScheduledTime, Object deadline)
ResultValidatordeadline 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.expectNoScheduledDeadline in interface ResultValidator<T>durationToScheduledTime - the time to wait until the trigger point of the deadline which should not be
scheduleddeadline - the deadline which should not be scheduledpublic ResultValidator<T> expectNoScheduledDeadlineOfType(Duration durationToScheduledTime, Class<?> deadlineType)
ResultValidatordeadlineType 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.expectNoScheduledDeadlineOfType in interface ResultValidator<T>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 scheduledpublic ResultValidator<T> expectNoScheduledDeadlineWithName(Duration durationToScheduledTime, String deadlineName)
ResultValidatordeadlineName 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.expectNoScheduledDeadlineWithName in interface ResultValidator<T>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 scheduledpublic ResultValidator<T> expectNoScheduledDeadlineMatching(Instant scheduledTime, org.hamcrest.Matcher<? super DeadlineMessage<?>> matcher)
ResultValidatormatcher 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".expectNoScheduledDeadlineMatching in interface ResultValidator<T>scheduledTime - the time at which no deadline matching the given matcher should be scheduledmatcher - the matcher defining the deadline which should not be scheduledpublic ResultValidator<T> expectNoScheduledDeadline(Instant scheduledTime, Object deadline)
ResultValidatordeadline 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.expectNoScheduledDeadline in interface ResultValidator<T>scheduledTime - the time at which no deadline equal to the given deadline should be scheduleddeadline - the deadline which should not be scheduledpublic ResultValidator<T> expectNoScheduledDeadlineOfType(Instant scheduledTime, Class<?> deadlineType)
ResultValidatordeadlineType 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.expectNoScheduledDeadlineOfType in interface ResultValidator<T>scheduledTime - the time at which no deadline of deadlineType should be scheduleddeadlineType - the type of the deadline which should not be scheduledpublic ResultValidator<T> expectNoScheduledDeadlineWithName(Instant scheduledTime, String deadlineName)
ResultValidatordeadlineName 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.expectNoScheduledDeadlineWithName in interface ResultValidator<T>scheduledTime - the time at which no deadline of deadlineName should be scheduleddeadlineName - the name of the deadline which should not be scheduledpublic ResultValidator<T> expectDeadlinesMetMatching(org.hamcrest.Matcher<? extends List<? super DeadlineMessage<?>>> matcher)
ResultValidatormatcher have been met (which have passed in time) on this aggregate.expectDeadlinesMetMatching in interface ResultValidator<T>matcher - The matcher that defines the expected list of deadlinespublic ResultValidator<T> expectDeadlinesMet(Object... expected)
ResultValidatorexpected deadlines have been met (which have passed in time). Deadlines are compared
comparing their type and fields using "equals".expectDeadlinesMet in interface ResultValidator<T>expected - The sequence of deadlines expected to be metpublic ResultValidator<T> expectResultMessagePayload(Object expectedPayload)
ResultValidatorexpectedPayload after execution. The actual and expected
values are compared using their equals methods.expectResultMessagePayload in interface ResultValidator<T>expectedPayload - The expected result message payload of the command executionpublic ResultValidator<T> expectResultMessagePayloadMatching(org.hamcrest.Matcher<?> matcher)
ResultValidatormatcher after execution.expectResultMessagePayloadMatching in interface ResultValidator<T>matcher - The matcher to verify the actual return value againstpublic ResultValidator<T> expectResultMessage(CommandResultMessage<?> expectedResultMessage)
ResultValidatorexpectedResultMessage after execution. The actual and
expected values are compared using their equals methods.
Comparison is done on message payload and meta data.
expectResultMessage in interface ResultValidator<T>expectedResultMessage - The expected result message of the command executionpublic ResultValidator<T> expectResultMessageMatching(org.hamcrest.Matcher<? super CommandResultMessage<?>> matcher)
ResultValidatormatcher after execution.expectResultMessageMatching in interface ResultValidator<T>matcher - The matcher to verify the actual result message againstpublic ResultValidator<T> expectExceptionMessage(org.hamcrest.Matcher<?> exceptionMessageMatcher)
ResultValidatormatcher.expectExceptionMessage in interface ResultValidator<T>exceptionMessageMatcher - The matcher to validate the actual exception messagepublic ResultValidator<T> expectExceptionMessage(String exceptionMessage)
ResultValidatorexceptionMessage to occur during command handler execution. The actual exception message
should be exactly the same as exceptionMessage.expectExceptionMessage in interface ResultValidator<T>exceptionMessage - The exception message expected from the command handler executionpublic ResultValidator<T> expectException(Class<? extends Throwable> expectedException)
ResultValidatorexpectedException to occur during command handler execution. The actual exception should
be exactly of that type, subclasses are not accepted.expectException in interface ResultValidator<T>expectedException - The type of exception expected from the command handler executionpublic ResultValidator<T> expectException(org.hamcrest.Matcher<?> matcher)
ResultValidatormatcher.expectException in interface ResultValidator<T>matcher - The matcher to validate the actual exceptionpublic ResultValidator<T> expectMarkedDeleted()
ResultValidatorexpectMarkedDeleted in interface ResultValidator<T>public ResultValidator<T> expectNotMarkedDeleted()
ResultValidatorexpectNotMarkedDeleted in interface ResultValidator<T>public void onResult(CommandMessage<?> commandMessage, CommandResultMessage<?> commandResultMessage)
CommandCallbackonResult in interface CommandCallback<Object,Object>commandMessage - the CommandMessage that was dispatchedcommandResultMessage - the CommandResultMessage of the command handling executionpublic void assertValidRecording()
Copyright © 2010–2020. All rights reserved.