Package org.axonframework.migration
Class MigrateAxonTestFixtureFluentApi
java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.MigrateAxonTestFixtureFluentApi
- All Implemented Interfaces:
Cloneable
public class MigrateAxonTestFixtureFluentApi
extends org.openrewrite.Recipe
Rewrites AF4
AggregateTestFixture test method bodies to the AF5
AxonTestFixture fluent given/when/then API.
AF5 split the flat AF4 fixture API (fixture.given(events).when(cmd).expectEvents(out))
into three sub-builders reached through no-arg phase methods:
fixture.given().events(events).when().command(cmd).then().events(out). The leaf method
names also changed (e.g. expectNoEvents → noEvents,
expectSuccessfulHandlerExecution → success).
This recipe handles the mechanical chain rewrite. Rewrites applied:
given(e…)→given().events(e…)givenCommands(c)→given().command(c)(single-arg);givenCommands(c1, c2…)→given().commands(c1, c2…)(multi-arg)givenNoPriorActivity()→given().noPriorActivity()when(cmd)/when(cmd, md)→when().command(cmd[, md])expectEvents(e…)→then().events(e…)expectNoEvents()→then().noEvents()expectException(X.class)→then().exception(X.class)expectException(X.class).expectExceptionMessage(m)→then().exception(X.class, m)expectSuccessfulHandlerExecution()→then().success()expectResultMessagePayload(p)→then().resultMessagePayload(p)
new AggregateTestFixture<>(...) →
AxonTestFixture.with(configurer), plus the @AfterEach fixture.stop() call)
stays manual: the AF5 fixture takes an ApplicationConfigurer, which is project-specific.
Hamcrest-matcher methods (expectEventsMatching, expectResultMessageMatching) are
also left alone — the AF4 matchers don't translate mechanically to AF5's
Consumer/Predicate-based eventsSatisfy / eventsMatch.- Since:
- 5.1.1
- Author:
- Mateusz Nowak
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openrewrite.Recipe
org.openrewrite.Recipe.Builder, org.openrewrite.Recipe.DelegatingRecipe -
Field Summary
Fields inherited from class org.openrewrite.Recipe
contributors, examples, PANIC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.openrewrite.TreeVisitor<?, org.openrewrite.ExecutionContext> Methods inherited from class org.openrewrite.Recipe
addDataTable, builder, buildRecipeList, causesAnotherCycle, clone, createRecipeDescriptor, equals, getContributors, getDataTableDescriptors, getDescriptor, getEstimatedEffortPerOccurrence, getExamples, getInstanceName, getInstanceNameSuffix, getJacksonPolymorphicTypeTag, getMaintainers, getName, getRecipeList, getTags, hashCode, maxCycles, noop, onComplete, run, run, run, setContributors, setExamples, validate, validate, validateAll, validateAll, withOptions
-
Constructor Details
-
MigrateAxonTestFixtureFluentApi
public MigrateAxonTestFixtureFluentApi()
-
-
Method Details
-
getDisplayName
- Specified by:
getDisplayNamein classorg.openrewrite.Recipe
-
getDescription
- Specified by:
getDescriptionin classorg.openrewrite.Recipe
-
getVisitor
public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()- Overrides:
getVisitorin classorg.openrewrite.Recipe
-