Class EventValidator

java.lang.Object
org.axonframework.test.saga.EventValidator
All Implemented Interfaces:
EventMessageHandler, MessageHandler<EventMessage<?>>

public class EventValidator extends Object implements EventMessageHandler
Helper class for validating events published on a given EventBus.
Since:
1.1
Author:
Allard Buijze
  • Constructor Details

    • EventValidator

      public EventValidator(EventBus eventBus, FieldFilter fieldFilter)
      Initializes the event validator to monitor the given eventBus.
      Parameters:
      eventBus - the event bus to monitor
      fieldFilter - the filter describing the Fields to include in a comparison
  • Method Details

    • assertPublishedEventsMatching

      public void assertPublishedEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher)
      Asserts that events have been published matching the given matcher.
      Parameters:
      matcher - The matcher that will validate the actual events
    • assertPublishedEvents

      public void assertPublishedEvents(Object... expected)
      Assert that the given expected events have been published.
      Parameters:
      expected - the events that must have been published.
    • handle

      public Object handle(EventMessage<?> event)
      Description copied from interface: EventMessageHandler
      Process 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:
      handle in interface EventMessageHandler
      Specified by:
      handle in interface MessageHandler<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.