Interface ExpectDsl.Next

Enclosing interface:
ExpectDsl

public static interface ExpectDsl.Next
Fluent API for asserting against events sequentially using a consuming cursor. This interface maintains position state, allowing navigation through events in order.

The cursor starts at position 0 (first event). There are two categories of methods:

All consuming matcher methods operate on the remaining events from the current cursor position.

See Also:
  • Method Details

    • skipping

      ExpectDsl.Next skipping(int num)
      Advances the cursor by the specified number of events. Subsequent assertions will operate on events starting from the new cursor position.
      Parameters:
      num - the number of events to skip (must be non-negative)
      Returns:
      this for method chaining
      Throws:
      AssertionError - if skipping would move past the end of the event list
    • noMore

      Asserts that no more events exist from the current cursor position.

      Example:

       .nextEvents()
           .skipping(2)
           .noMore()
           .havingResult(expectedId);
       
      Returns:
      a ExpectDsl.Succeeding interface for further assertions
      Throws:
      AssertionError - if events exist at or after the current cursor position
    • remaining

      ExpectDsl.Succeeding remaining(int count)
      Asserts that exactly the specified number of events remain from the current cursor position. This is a convenience shortcut for skipping(count).noMore().
      Parameters:
      count - the expected number of remaining events (must be non-negative)
      Returns:
      a ExpectDsl.Succeeding interface for further assertions
      Throws:
      AssertionError - if the remaining event count differs
    • single

      Asserts that exactly one event remains from the current cursor position and that it matches the validation. The remaining stream must have length 1, then the event is consumed.

      To assert that exactly one remaining event matches in a stream of any length, use once(Consumer).

      Example:

       .nextEvents().single(e -> e.ofType(OrderPlacedEvent.class));
       
      Parameters:
      consumer - a consumer that validates the event via ExpectDsl.EventValidator
      Returns:
      a ExpectDsl.Succeeding interface for further assertions
      Throws:
      AssertionError - if the remaining event count is not exactly 1 or the event fails validation
    • once

      Consumes all remaining events and asserts that exactly one of them matches the validation. The remaining stream may have any length.
      Parameters:
      consumer - a consumer that validates events via ExpectDsl.EventValidator
      Returns:
      a ExpectDsl.Succeeding interface for further assertions
      Throws:
      AssertionError - if zero or more than one remaining event matches
    • any

      Consumes all remaining events and asserts that at least one of them matches the validation. The remaining stream may have any length (multiple matches are allowed) but must contain at least one matching event.
      Parameters:
      consumer - a consumer that validates events via ExpectDsl.EventValidator
      Returns:
      a ExpectDsl.Succeeding interface for further assertions
      Throws:
      AssertionError - if no remaining event matches or the remaining stream is empty
    • every

      Consumes all remaining events and asserts that every one of them matches the validation. The remaining stream must contain at least one event — an empty remaining stream causes an assertion error (fail-fast).
      Parameters:
      consumer - a consumer that validates each event via ExpectDsl.EventValidator
      Returns:
      a ExpectDsl.Succeeding interface for further assertions
      Throws:
      AssertionError - if any remaining event fails validation or no remaining events exist
    • exactly

      ExpectDsl.Succeeding exactly(Object... events)
      Consumes all remaining events and asserts that the remaining event payloads match exactly the provided payloads in order, using Object.equals(Object). Only payloads are compared — meta-data and subject are ignored. The number of remaining events must equal the number of expected payloads.
      Parameters:
      events - the expected event payloads in order
      Returns:
      a ExpectDsl.Succeeding interface for further assertions
      Throws:
      AssertionError - if the remaining event count doesn't match or any payload differs
    • none

      Consumes all remaining events and asserts that none of them match the validation.
      Parameters:
      consumer - a consumer that validates events via ExpectDsl.EventValidator
      Returns:
      a ExpectDsl.Succeeding interface for further assertions
      Throws:
      AssertionError - if any remaining event matches
    • matches

      Consumes exactly one event at the current cursor position and validates it using the provided consumer. Advances the cursor by one. This is a navigating operation that returns ExpectDsl.Next for further chaining.
      Parameters:
      consumer - a consumer that validates the event via ExpectDsl.EventValidator
      Returns:
      this for further navigation
      Throws:
      AssertionError - if no more events remain at the current cursor position, or if the event fails validation
    • 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