Package com.opencqrs.framework.command
Class CommandHandlingTestFixture.EventAsserter
java.lang.Object
com.opencqrs.framework.command.CommandHandlingTestFixture.EventAsserter
- Enclosing class:
CommandHandlingTestFixture<C extends Command>
Fluent API helper class for asserting a captured events.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionVerifies that the captured event was published for theCommand.getSubject().Asserts that the captured event meta-data is equal to the expected one.metaDataSatisfying(Consumer<Map<String, ?>> assertion) Verifies that the captured event meta-data asserts successfully using the given custom assertion.Verifies that no (aka empty) meta-data was published for the captured event.payload(E expected) Asserts that the captured event payload is equal to the expected one.payloadExtracting(Function<E, R> extractor, R expected) Asserts that the captured event's payload property from the given extractor function is equal to the expected one.payloadSatisfying(Consumer<E> assertion) Verifies that the captured event payload asserts successfully using the given custom assertion.payloadType(Class<?> type) Asserts that the captured event payload Class.isAssignableFrom(Class) is assignable to} the expected typeAsserts that the captured event subject is equal to the expected one.subjectSatisfying(Consumer<String> assertion) Verifies that the captured event subject asserts successfully using the given custom assertion.
-
Method Details
-
payloadType
Asserts that the captured event payload Class.isAssignableFrom(Class) is assignable to} the expected type- Parameters:
type- the assignable type- Returns:
thisfor further assertions
-
payload
Asserts that the captured event payload is equal to the expected one.- Type Parameters:
E- the generic payload type- Parameters:
expected- the expected event payload- Returns:
thisfor further assertions- Throws:
AssertionError- if the captured event payload is not equal to the expected one
-
payloadExtracting
public <E,R> CommandHandlingTestFixture.EventAsserter payloadExtracting(Function<E, R> extractor, R expected) throws AssertionErrorAsserts that the captured event's payload property from the given extractor function is equal to the expected one.- Type Parameters:
E- the generic payload typeR- the generic extraction result type- Parameters:
extractor- the extractor functionexpected- the expected event payload property, may benull- Returns:
thisfor further assertions- Throws:
AssertionError- if the extracted payload property is not equal to the expected value
-
payloadSatisfying
public <E> CommandHandlingTestFixture.EventAsserter payloadSatisfying(Consumer<E> assertion) throws AssertionError Verifies that the captured event payload asserts successfully using the given custom assertion.- Type Parameters:
E- the generic payload type- Parameters:
assertion- custom assertion- Returns:
thisfor further assertions- Throws:
AssertionError- if thrown by the custom assertion
-
metaData
public CommandHandlingTestFixture.EventAsserter metaData(Map<String, ?> expected) throws AssertionErrorAsserts that the captured event meta-data is equal to the expected one.- Parameters:
expected- the expected event meta-data- Returns:
thisfor further assertions- Throws:
AssertionError- if the meta-data of the event is not as expected
-
metaDataSatisfying
public CommandHandlingTestFixture.EventAsserter metaDataSatisfying(Consumer<Map<String, ?>> assertion) throws AssertionErrorVerifies that the captured event meta-data asserts successfully using the given custom assertion.- Parameters:
assertion- custom assertion- Returns:
thisfor further assertions- Throws:
AssertionError- if thrown by the custom assertion
-
noMetaData
Verifies that no (aka empty) meta-data was published for the captured event.- Returns:
thisfor further assertions- Throws:
AssertionError- if the meta-data is not empty
-
subject
Asserts that the captured event subject is equal to the expected one.- Parameters:
expected- the expected event subject- Returns:
thisfor further assertions- Throws:
AssertionError- if the event subject is not as expected
-
subjectSatisfying
public CommandHandlingTestFixture.EventAsserter subjectSatisfying(Consumer<String> assertion) throws AssertionError Verifies that the captured event subject asserts successfully using the given custom assertion.- Parameters:
assertion- custom assertion- Returns:
thisfor further assertions- Throws:
AssertionError- if thrown by the custom assertion
-
commandSubject
Verifies that the captured event was published for theCommand.getSubject().- Returns:
thisfor further assertions- Throws:
AssertionError- if the published event subject differs from the command's subject
-