Package com.opencqrs.framework.command
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 Summary
Modifier and TypeMethodDescriptionasserting(Consumer<EventAsserting> asserting) Asserts that the event satisfies custom assertions using the fullEventAssertingAPI.Asserts that the event payload equals the expected value usingObject.equals(Object).Asserts that the event payload is an instance of the specified type.satisfying(Consumer<E> assertion) Asserts that the event payload satisfies custom assertions.
-
Method Details
-
comparing
Asserts that the event payload equals the expected value usingObject.equals(Object). This is a convenience method for simple equality checks.- Parameters:
event- the expected event payload- Returns:
thisfor further validations- Throws:
AssertionError- if the payloads are not equal
-
satisfying
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:
thisfor further validations- Throws:
AssertionError- if thrown by the consumer- See Also:
-
asserting
Asserts that the event satisfies custom assertions using the fullEventAssertingAPI. 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 anEventAssertinginstance- Returns:
thisfor 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:
thisfor further validations- Throws:
AssertionError- if the payload is not assignable to the expected type
-