public interface ResultValidator
TestExecutor
.
There are several things to validate:
void
return value, orModifier and Type | Method and Description |
---|---|
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 . |
default ResultValidator |
expectNoEvents()
Expect no events to have been published from the command.
|
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.
|
ResultValidator 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.default ResultValidator expectNoEvents()
ResultValidator 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 expectReturnValue(Object expectedReturnValue)
expectedReturnValue
after execution. The actual and
expected values are compared using their equals methods.expectedReturnValue
- The expected return value of the command executionResultValidator expectReturnValueMatching(org.hamcrest.Matcher<?> matcher)
matcher
after execution.matcher
- The matcher to verify the actual return value againstResultValidator 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 expectException(org.hamcrest.Matcher<?> matcher)
matcher
.matcher
- The matcher to validate the actual exceptionResultValidator expectSuccessfulHandlerExecution()
Copyright © 2010–2017. All rights reserved.