public class ResultValidatorImpl extends Object implements ResultValidator, CommandCallback<Object>
| Constructor and Description |
|---|
ResultValidatorImpl(Collection<DomainEventMessage> storedEvents,
Collection<EventMessage> publishedEvents)
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 stored and published.
|
ResultValidator |
expectEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> 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 |
expectPublishedEvents(Object... expectedEvents)
Expect the given set of events to have been published on the events bus.
|
ResultValidator |
expectPublishedEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher)
Expect the list of published event to match the given
matcher. |
ResultValidator |
expectReturnValue(org.hamcrest.Matcher<?> matcher)
Expect the command handler to return a value that matches the given
matcher after execution. |
ResultValidator |
expectReturnValue(Object expectedReturnValue)
Expect the command handler to return the given
expectedReturnValue after execution. |
ResultValidator |
expectStoredEvents(Object... expectedEvents)
Expect the given set of events to have been stored in the event store.
|
ResultValidator |
expectStoredEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher)
Expect the list of stored event to match the given
matcher. |
ResultValidator |
expectVoidReturnType()
Explicitly expect a
void return type on the given command handler. |
void |
onFailure(Throwable cause)
Invoked when command handling execution resulted in an error.
|
void |
onSuccess(Object result)
Invoked when command handling execution was successful.
|
public ResultValidatorImpl(Collection<DomainEventMessage> storedEvents, Collection<EventMessage> publishedEvents)
storedEvents and publishedEvents.storedEvents - The events that were stored during command executionpublishedEvents - The events that were published during command executionpublic ResultValidator expectEvents(Object... expectedEvents)
ResultValidatorResultValidator.expectPublishedEvents(Object...) and ResultValidator.expectStoredEvents(Object...) methods instead.
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.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 Iterable<?>> matcher)
ResultValidatormatcher. Note that this assertion will fail if
events
were published but not saved.
Note: if no events were published or stored, the matcher receives an empty List.expectEventsMatching in interface ResultValidatormatcher - The matcher to match with the actually published eventspublic ResultValidator expectPublishedEvents(Object... expectedEvents)
ResultValidatorResultValidator.expectEvents(Object...) instead.
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. For Application and System events, however, the
source of the events must be equal, too.expectPublishedEvents in interface ResultValidatorexpectedEvents - The expected events, in the exact order they are expected to be dispatched.public ResultValidator expectPublishedEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher)
ResultValidatormatcher. This method will only take into
account the events that have been published. Stored events that have not been published to the event bus are
ignored.
Note: if no events were published, the matcher receives an empty List.expectPublishedEventsMatching in interface ResultValidatormatcher - The matcher which validates the actual list of published events.public ResultValidator expectStoredEvents(Object... expectedEvents)
ResultValidatorResultValidator.expectEvents(Object...) instead.
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. For Application and System events, however, the
source of the events must be equal, too.expectStoredEvents in interface ResultValidatorexpectedEvents - The expected events, in the exact order they are expected to be stored.public ResultValidator expectStoredEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher)
ResultValidatormatcher. This method will only take into account
the events that have been stored. Stored events that have not been stored in the event store are ignored.
Note: if no events were stored, the matcher receives an empty List.expectStoredEventsMatching in interface ResultValidatormatcher - The matcher which validates the actual list of stored events.public ResultValidator expectVoidReturnType()
ResultValidatorvoid return type on the given command handler. void is the
recommended return value for all command handlers as they allow for a more scalable architecture.expectVoidReturnType 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 expectReturnValue(org.hamcrest.Matcher<?> matcher)
ResultValidatormatcher after execution.expectReturnValue 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(Object result)
CommandCallbackonSuccess in interface CommandCallback<Object>result - The result of the command handling execution, if any.public void onFailure(Throwable cause)
CommandCallbackonFailure in interface CommandCallback<Object>cause - The exception raised during command handlingpublic void assertValidRecording()
Copyright © 2010-2014. All Rights Reserved.