Interface ExpectDsl.Succeeding

Enclosing interface:
ExpectDsl

public static interface ExpectDsl.Succeeding
Fluent API for assertions after successful command execution. Succeeding is the central hub of the assertion API — it can be reached from ExpectDsl.Outcome.succeeds(), from ExpectDsl.All.and(), from ExpectDsl.Next.and(), or from any terminal method on ExpectDsl.Next.

All assertion methods return Succeeding to allow free chaining between result/state assertions and event assertions:

 .succeeds()
     .havingResult(expectedResult)
     .nextEvents()
     .matches(e -> e.ofType(OrderPlacedEvent.class))
     .noMore()
     .allEvents()
     .count(1)
     .and()
     .havingState(expectedState);
 
  • Method Details

    • withoutEvents

      ExpectDsl.Succeeding withoutEvents()
      Asserts that no events were published by the command handler.
      Returns:
      this for method chaining
      Throws:
      AssertionError - if any events were published
    • havingResult

      ExpectDsl.Succeeding havingResult(@Nullable Object expected)
      Asserts that the command handler returned the expected result using Object.equals(Object). The result is the value returned by the CommandHandler implementation.
      Parameters:
      expected - the expected result value (may be null)
      Returns:
      this for method chaining
      Throws:
      AssertionError - if the results are not equal
    • resultSatisfying

      ExpectDsl.Succeeding resultSatisfying(Consumer<@Nullable Object> assertion)
      Asserts that the command result satisfies custom assertions.

      Example:

       .succeeds()
           .resultSatisfying(result -> assertThat(result).isInstanceOf(OrderId.class));
       
      Parameters:
      assertion - a consumer receiving the command result for custom assertions
      Returns:
      this for method chaining
      Throws:
      AssertionError - if thrown by the consumer
    • havingState

      ExpectDsl.Succeeding havingState(@Nullable Object state)
      Asserts that the final instance state equals the expected state using Object.equals(Object). The state is captured after all published events have been processed by the StateRebuildingHandlerDefinitions.
      Parameters:
      state - the expected final state
      Returns:
      this for method chaining
      Throws:
      AssertionError - if the states are not equal or no state was captured
    • stateSatisfying

      ExpectDsl.Succeeding stateSatisfying(Consumer<@Nullable Object> assertion)
      Asserts that the final instance state satisfies custom assertions.

      Example:

       .succeeds()
           .stateSatisfying(state -> {
               OrderState order = (OrderState) state;
               assertThat(order.status()).isEqualTo(OrderStatus.CONFIRMED);
           });
       
      Parameters:
      assertion - a consumer receiving the final state for custom assertions
      Returns:
      this for method chaining
      Throws:
      AssertionError - if thrown by the consumer
    • stateExtracting

      <T> ExpectDsl.Succeeding stateExtracting(Function<@Nullable Object,T> extractor, T expected)
      Extracts a value from the final instance state and asserts it equals the expected value. Useful for verifying specific state fields without matching the entire state object.

      Example:

       .succeeds()
           .stateExtracting(state -> ((OrderState) state).status(), OrderStatus.CONFIRMED);
       
      Type Parameters:
      T - the extracted value type
      Parameters:
      extractor - function to extract a value from the state
      expected - the expected extracted value (may be null)
      Returns:
      this for method chaining
      Throws:
      AssertionError - if the extracted values are not equal or no state was captured
    • allEvents

      ExpectDsl.All allEvents()
      Returns an interface for asserting against all captured events as a whole. Use this when you need to verify the complete set of events without cursor-based navigation. Each call operates on the full event list.
      Returns:
      an ExpectDsl.All interface for event assertions
      See Also:
    • nextEvents

      ExpectDsl.Next nextEvents()
      Returns an interface for asserting against events sequentially using a cursor. Each call creates a fresh cursor starting at position 0. Use this when you need to navigate through events in order, skip events, or verify that no more events exist after a certain point.

      Navigation methods (ExpectDsl.Next.skipping(int), ExpectDsl.Next.matches(Consumer)) advance the cursor and return ExpectDsl.Next for further navigation. Consuming methods (ExpectDsl.Next.single(Consumer), ExpectDsl.Next.once(Consumer), ExpectDsl.Next.any(Consumer), ExpectDsl.Next.every(Consumer), ExpectDsl.Next.none(Consumer), ExpectDsl.Next.exactly(Object...), ExpectDsl.Next.noMore(), ExpectDsl.Next.remaining(int)) consume remaining events and return ExpectDsl.Succeeding.

      Example:

       .succeeds()
           .nextEvents()
           .matches(e -> e.ofType(OrderPlacedEvent.class))
           .skipping(1)
           .noMore()
           .havingResult(expectedId);
       
      Returns:
      a ExpectDsl.Next interface for sequential event assertions
      See Also: