public class ResultValidatorImpl extends Object implements ResultValidator, CommandCallback<Object,Object>
| Constructor and Description |
|---|
ResultValidatorImpl(List<EventMessage<?>> publishedEvents,
FieldFilter fieldFilter)
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 |
expectEvents(Object... expectedEvents)
Expect the given set of events to have been published.
|
ResultValidator |
expectEventsMatching(org.hamcrest.Matcher<? extends List<? super EventMessage<?>>> matcher)
Expect the published events to match the given
matcher. |
ResultValidator |
expectException(Class<? extends Throwable> expectedException)
Expect the given
expectedException to occur during command handler execution. |
ResultValidator |
expectException(org.hamcrest.Matcher<?> matcher)
Expect an exception to occur during command handler execution that matches with the given
matcher. |
ResultValidator |
expectReturnValue(Object expectedReturnValue)
Expect the command handler to return the given
expectedReturnValue after execution. |
ResultValidator |
expectReturnValueMatching(org.hamcrest.Matcher<?> matcher)
Expect the command handler to return a value that matches the given
matcher after execution. |
ResultValidator |
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)
storedEvents and publishedEvents.publishedEvents - The events that were published during command executionfieldFilter - The filter describing which fields to include in the comparisonpublic ResultValidator 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 ResultValidatorexpectedEvents - The expected events, in the exact order they are expected to be dispatched and stored.public ResultValidator 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 ResultValidatormatcher - The matcher to match with the actually published eventspublic ResultValidator expectSuccessfulHandlerExecution()
ResultValidatorexpectSuccessfulHandlerExecution in interface ResultValidatorpublic ResultValidator expectReturnValue(Object expectedReturnValue)
ResultValidatorexpectedReturnValue after execution. The actual and
expected values are compared using their equals methods.expectReturnValue in interface ResultValidatorexpectedReturnValue - The expected return value of the command executionpublic ResultValidator expectReturnValueMatching(org.hamcrest.Matcher<?> matcher)
ResultValidatormatcher after execution.expectReturnValueMatching in interface ResultValidatormatcher - The matcher to verify the actual return value againstpublic ResultValidator 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 ResultValidatorexpectedException - The type of exception expected from the command handler executionpublic ResultValidator expectException(org.hamcrest.Matcher<?> matcher)
ResultValidatormatcher.expectException in interface ResultValidatormatcher - 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–2017. All rights reserved.