Interface ExpectDsl.All

Enclosing interface:
ExpectDsl

public static interface ExpectDsl.All
Fluent API for asserting against all captured events. This interface provides methods that operate on the complete event list without maintaining cursor state.

Each method validates events against the entire captured event list and returns this for method chaining, allowing multiple assertions to be combined.

See Also:
  • Method Details

    • count

      ExpectDsl.All count(int count)
      Asserts that exactly the specified number of events were captured.
      Parameters:
      count - the expected number of events (must be non-negative)
      Returns:
      this for method chaining
      Throws:
      AssertionError - if the actual event count differs
      IllegalArgumentException - if count is negative
    • single

      Asserts that exactly one event was captured and that it matches the specified validation. The captured event stream must have length 1.

      To assert that exactly one event matches in a stream of any length, use once(Consumer). To combine an event-count check with single-event validation:

       .allEvents().count(1).single(e -> e.ofType(PaymentReceivedEvent.class));
       
      Parameters:
      consumer - a consumer that validates the event via ExpectDsl.EventValidator
      Returns:
      this for method chaining
      Throws:
      AssertionError - if the event count is not exactly 1 or the single event fails validation
    • once

      Asserts that exactly one event in the captured list matches the validation. The stream must not be empty and exactly one event must match — non-matching events are allowed.
      Parameters:
      consumer - a consumer that validates events via ExpectDsl.EventValidator
      Returns:
      this for method chaining
      Throws:
      AssertionError - if zero or more than one event matches, or the stream is empty
    • any

      Asserts that at least one event in the captured list matches the validation. The stream may have any length, but must contain at least one matching event (multiple matches are allowed).
      Parameters:
      consumer - a consumer that validates events via ExpectDsl.EventValidator
      Returns:
      this for method chaining
      Throws:
      AssertionError - if no event matches or the stream is empty
    • every

      Asserts that every captured event matches the validation. The stream must contain at least one event — an empty stream causes an assertion error (fail-fast).
      Parameters:
      consumer - a consumer that validates each event via ExpectDsl.EventValidator
      Returns:
      this for method chaining
      Throws:
      AssertionError - if any event fails validation or no events exist
    • none

      Asserts that no captured events match the validation.
      Parameters:
      consumer - a consumer that validates events via ExpectDsl.EventValidator
      Returns:
      this for method chaining
      Throws:
      AssertionError - if any event matches
    • exactly

      ExpectDsl.All exactly(Object... events)
      Asserts that the captured events match exactly the provided event payloads in order, using Object.equals(Object). Only payloads are compared — meta-data and subject are ignored. The number of captured events must equal the number of expected payloads — both too few and too many events cause an error.
      Parameters:
      events - the expected event payloads in order
      Returns:
      this for method chaining
      Throws:
      AssertionError - if the captured event count doesn't match or any payload differs
    • and

      Returns to the ExpectDsl.Succeeding interface to access result/state assertions or switch to a different event assertion mode (ExpectDsl.Succeeding.allEvents(), ExpectDsl.Succeeding.nextEvents()).
      Returns:
      a ExpectDsl.Succeeding interface