Package com.opencqrs.framework.command
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 Summary
Modifier and TypeMethodDescriptionand()Returns to theExpectDsl.Succeedinginterface to access result/state assertions or switch to a different event assertion mode (ExpectDsl.Succeeding.allEvents(),ExpectDsl.Succeeding.nextEvents()).any(Consumer<ExpectDsl.EventValidator> consumer) Asserts that at least one event in the captured list matches the validation.count(int count) Asserts that exactly the specified number of events were captured.every(Consumer<ExpectDsl.EventValidator> consumer) Asserts that every captured event matches the validation.Asserts that the captured events match exactly the provided event payloads in order, usingObject.equals(Object).none(Consumer<ExpectDsl.EventValidator> consumer) Asserts that no captured events match the validation.once(Consumer<ExpectDsl.EventValidator> consumer) Asserts that exactly one event in the captured list matches the validation.single(Consumer<ExpectDsl.EventValidator> consumer) Asserts that exactly one event was captured and that it matches the specified validation.
-
Method Details
-
count
Asserts that exactly the specified number of events were captured.- Parameters:
count- the expected number of events (must be non-negative)- Returns:
thisfor method chaining- Throws:
AssertionError- if the actual event count differsIllegalArgumentException- 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 viaExpectDsl.EventValidator- Returns:
thisfor 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 viaExpectDsl.EventValidator- Returns:
thisfor 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 viaExpectDsl.EventValidator- Returns:
thisfor 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 viaExpectDsl.EventValidator- Returns:
thisfor 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 viaExpectDsl.EventValidator- Returns:
thisfor method chaining- Throws:
AssertionError- if any event matches
-
exactly
Asserts that the captured events match exactly the provided event payloads in order, usingObject.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:
thisfor method chaining- Throws:
AssertionError- if the captured event count doesn't match or any payload differs
-
and
ExpectDsl.Succeeding and()Returns to theExpectDsl.Succeedinginterface to access result/state assertions or switch to a different event assertion mode (ExpectDsl.Succeeding.allEvents(),ExpectDsl.Succeeding.nextEvents()).- Returns:
- a
ExpectDsl.Succeedinginterface
-