Class EventValidator

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

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

    Constructors
    Constructor
    Description
    EventValidator(org.axonframework.eventhandling.EventBus eventBus, FieldFilter fieldFilter)
    Initializes the event validator to monitor the given eventBus.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Assert that the given expected events have been published.
    void
    assertPublishedEventsMatching(org.hamcrest.Matcher<? extends Iterable<?>> matcher)
    Asserts that events have been published matching the given matcher.
    handle(org.axonframework.eventhandling.EventMessage<?> event)
     
    void
    Starts recording event published by the event bus.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.axonframework.eventhandling.EventMessageHandler

    prepareReset, prepareReset, supportsReset

    Methods inherited from interface org.axonframework.messaging.MessageHandler

    canHandle, canHandleType, getTargetType
  • Constructor Details

    • EventValidator

      public EventValidator(org.axonframework.eventhandling.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(org.axonframework.eventhandling.EventMessage<?> event)
      Specified by:
      handle in interface org.axonframework.eventhandling.EventMessageHandler
      Specified by:
      handle in interface org.axonframework.messaging.MessageHandler<org.axonframework.eventhandling.EventMessage<?>>
    • startRecording

      public void startRecording()
      Starts recording event published by the event bus.