Interface ExpectDsl.EventValidator

Enclosing interface:
ExpectDsl

public static interface ExpectDsl.EventValidator
Fluent API interface for validating individual captured events. Instances are provided to consumers passed to methods like ExpectDsl.All.single(Consumer), ExpectDsl.All.any(Consumer) and similar.

All methods return this to allow chaining multiple validations on the same event.

  • Method Details

    • comparing

      ExpectDsl.EventValidator comparing(Object event)
      Asserts that the event payload equals the expected value using Object.equals(Object). This is a convenience method for simple equality checks.
      Parameters:
      event - the expected event payload
      Returns:
      this for further validations
      Throws:
      AssertionError - if the payloads are not equal
    • satisfying

      <E> ExpectDsl.EventValidator satisfying(Consumer<E> assertion)
      Asserts that the event payload satisfies custom assertions. The payload is passed directly to the consumer, cast to the specified type. Use this for payload-only assertions.

      Example: e.satisfying((MyEvent ev) -> assertThat(ev.name()).isEqualTo("test"))

      Type Parameters:
      E - the expected event payload type
      Parameters:
      assertion - a consumer receiving the event payload for custom assertions
      Returns:
      this for further validations
      Throws:
      AssertionError - if thrown by the consumer
      See Also:
    • asserting

      Asserts that the event satisfies custom assertions using the full EventAsserting API. Use this when you need to assert more than just the payload, such as meta-data or subject.

      Example: e.asserting(a -> a.payloadType(MyEvent.class).subject("my-subject"))

      Parameters:
      asserting - a consumer receiving an EventAsserting instance
      Returns:
      this for further validations
      Throws:
      AssertionError - if thrown by the consumer
      See Also:
    • ofType

      Asserts that the event payload is an instance of the specified type.
      Parameters:
      type - the expected event payload class
      Returns:
      this for further validations
      Throws:
      AssertionError - if the payload is not assignable to the expected type