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> |
expectNoScheduledDeadlines()
Asserts that no deadlines are scheduled.
|
ResultValidator<T> |
expectReturnValue(Object expectedReturnValue)
Expect the command handler to return the given
expectedReturnValue after execution. |
ResultValidator<T> |
expectReturnValueMatching(org.hamcrest.Matcher<?> matcher)
Expect the command handler to return a value 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.
|
void |
onFailure(CommandMessage<?> commandMessage,
Throwable cause)
Invoked when command handling execution resulted in an error.
|
void |
onSuccess(CommandMessage<?> commandMessage,
Object result)
Invoked when command handling execution was successful.
|
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> 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> expectNoScheduledDeadlines()
ResultValidatorexpectNoScheduledDeadlines in interface ResultValidator<T>public 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> expectReturnValue(Object expectedReturnValue)
ResultValidatorexpectedReturnValue after execution. The actual and
expected values are compared using their equals methods.expectReturnValue in interface ResultValidator<T>expectedReturnValue - The expected return value of the command executionpublic ResultValidator<T> expectReturnValueMatching(org.hamcrest.Matcher<?> matcher)
ResultValidatormatcher after execution.expectReturnValueMatching in interface ResultValidator<T>matcher - The matcher to verify the actual return value 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 void onSuccess(CommandMessage<?> commandMessage, Object result)
CommandCallbackonSuccess in interface CommandCallback<Object,Object>commandMessage - The message that was dispatchedresult - The result of the command handling execution, if any.public void onFailure(CommandMessage<?> commandMessage, Throwable cause)
CommandCallbackonFailure in interface CommandCallback<Object,Object>commandMessage - The message that was dispatchedcause - The exception raised during command handlingpublic void assertValidRecording()
Copyright © 2010–2018. All rights reserved.