Package org.axonframework.test.saga
Class EventValidator
java.lang.Object
org.axonframework.test.saga.EventValidator
- All Implemented Interfaces:
EventMessageHandler,MessageHandler<EventMessage<?>>
Helper class for validating events published on a given EventBus.
- Since:
- 1.1
- Author:
- Allard Buijze
-
Constructor Summary
ConstructorsConstructorDescriptionEventValidator(EventBus eventBus, FieldFilter fieldFilter) Initializes the event validator to monitor the giveneventBus. -
Method Summary
Modifier and TypeMethodDescriptionvoidassertPublishedEvents(Object... expected) Assert that the givenexpectedevents have been published.voidassertPublishedEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher) Asserts that events have been published matching the givenmatcher.handle(EventMessage<?> event) Process the given event.voidStarts recording event published by the event bus.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.eventhandling.EventMessageHandler
prepareReset, prepareReset, supportsResetMethods inherited from interface org.axonframework.messaging.MessageHandler
canHandle, canHandleType, getTargetType
-
Constructor Details
-
EventValidator
Initializes the event validator to monitor the giveneventBus.- Parameters:
eventBus- the event bus to monitorfieldFilter- the filter describing the Fields to include in a comparison
-
-
Method Details
-
assertPublishedEventsMatching
Asserts that events have been published matching the givenmatcher.- Parameters:
matcher- The matcher that will validate the actual events
-
assertPublishedEvents
Assert that the givenexpectedevents have been published.- Parameters:
expected- the events that must have been published.
-
handle
Description copied from interface:EventMessageHandlerProcess the given event. The implementation may decide to process or skip the given event. It is highly unrecommended to throw any exception during the event handling process.- Specified by:
handlein interfaceEventMessageHandler- Specified by:
handlein interfaceMessageHandler<EventMessage<?>>- Parameters:
event- the event to handle- Returns:
- the result of the event handler invocation. Is generally ignored
-
startRecording
public void startRecording()Starts recording event published by the event bus.
-