org.axonframework.test
Interface ResultValidator

All Known Implementing Classes:
ResultValidatorImpl

public interface ResultValidator

Interface describing the operations available on the "validate result" (a.k.a. "then") stage of the test execution. The underlying fixture expects a test to have been executed succesfully using a TestExecutor.

There are several things to validate:

Since:
0.6
Author:
Allard Buijze

Method Summary
 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.
 

Method Detail

expectEvents

ResultValidator expectEvents(Object... expectedEvents)
Expect the given set of events to have been stored and published. Note that this assertion will fail if events were published but not saved. If you expect events (e.g. Application Events) to have been dispatched, use the expectPublishedEvents(Object...) and 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.

Parameters:
expectedEvents - The expected events, in the exact order they are expected to be dispatched and stored.
Returns:
the current ResultValidator, for fluent interfacing

expectEventsMatching

ResultValidator expectEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher)
Expect the published events to match the given matcher. 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.

Parameters:
matcher - The matcher to match with the actually published events
Returns:
the current ResultValidator, for fluent interfacing

expectPublishedEvents

ResultValidator expectPublishedEvents(Object... expectedEvents)
Expect the given set of events to have been published on the events bus. If you expect the same events to be stored, too, consider using the 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.

Parameters:
expectedEvents - The expected events, in the exact order they are expected to be dispatched.
Returns:
the current ResultValidator, for fluent interfacing

expectPublishedEventsMatching

ResultValidator expectPublishedEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher)
Expect the list of published event to match the given matcher. 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.

Parameters:
matcher - The matcher which validates the actual list of published events.
Returns:
the current ResultValidator, for fluent interfacing

expectStoredEvents

ResultValidator expectStoredEvents(Object... expectedEvents)
Expect the given set of events to have been stored in the event store. If you expect the same events to be published, too, consider using the 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.

Parameters:
expectedEvents - The expected events, in the exact order they are expected to be stored.
Returns:
the current ResultValidator, for fluent interfacing

expectStoredEventsMatching

ResultValidator expectStoredEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher)
Expect the list of stored event to match the given matcher. 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.

Parameters:
matcher - The matcher which validates the actual list of stored events.
Returns:
the current ResultValidator, for fluent interfacing

expectReturnValue

ResultValidator expectReturnValue(Object expectedReturnValue)
Expect the command handler to return the given expectedReturnValue after execution. The actual and expected values are compared using their equals methods.

Parameters:
expectedReturnValue - The expected return value of the command execution
Returns:
the current ResultValidator, for fluent interfacing

expectReturnValue

ResultValidator expectReturnValue(org.hamcrest.Matcher<?> matcher)
Expect the command handler to return a value that matches the given matcher after execution.

Parameters:
matcher - The matcher to verify the actual return value against
Returns:
the current ResultValidator, for fluent interfacing

expectException

ResultValidator expectException(Class<? extends Throwable> expectedException)
Expect the given expectedException to occur during command handler execution. The actual exception should be exactly of that type, subclasses are not accepted.

Parameters:
expectedException - The type of exception expected from the command handler execution
Returns:
the current ResultValidator, for fluent interfacing

expectException

ResultValidator expectException(org.hamcrest.Matcher<?> matcher)
Expect an exception to occur during command handler execution that matches with the given matcher.

Parameters:
matcher - The matcher to validate the actual exception
Returns:
the current ResultValidator, for fluent interfacing

expectVoidReturnType

ResultValidator expectVoidReturnType()
Explicitly expect a void 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.

Returns:
the current ResultValidator, for fluent interfacing


Copyright © 2010-2016. All Rights Reserved.