Class MigrateAggregateTestFixtureSetup

java.lang.Object
org.openrewrite.Recipe
org.axonframework.migration.MigrateAggregateTestFixtureSetup
All Implemented Interfaces:
Cloneable

public class MigrateAggregateTestFixtureSetup extends org.openrewrite.Recipe
Rewrites the AF4 aggregate-fixture constructor expression new AggregateTestFixture<X>(X.class) (or its diamond form) to the AF5 fluent factory:

 AxonTestFixture.with(
         EventSourcingConfigurer.create()
                                .registerEntity(
                                        EventSourcedEntityModule.autodetected(
                                                <IdType>.class,
                                                X.class)))
 

The aggregate type X is read from the constructor's class literal argument. The <IdType> is looked up in the cross-recipe map populated by AddEventTagAnnotation (under AddEventTagAnnotation.SHARED_ID_TYPES_KEY) while @AggregateIdentifier is still on the source. When the id type is unavailable (no annotated field, or an unresolvable type), the recipe falls back to Object.class with a TODO(axon4to5): comment so the developer notices and supplies the correct type manually — same shape as ConfigureEventSourcedAnnotation.

Only the AF4 AggregateTestFixture FQN is matched, so SagaTestFixture setups are left for manual migration. The recipe targets the new ... expression itself, so callers in field initializers or @BeforeEach bodies are both handled.

When to run: before ChangeType AggregateTestFixture → AxonTestFixture. Once the type is renamed, the AF4-specific match disappears and the recipe is a no-op.

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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    org.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

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MigrateAggregateTestFixtureSetup

      public MigrateAggregateTestFixtureSetup()
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in class org.openrewrite.Recipe
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in class org.openrewrite.Recipe
    • getVisitor

      public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()
      Overrides:
      getVisitor in class org.openrewrite.Recipe