Class MarkAggregateTestFixtureDeadlineCalls

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

public class MarkAggregateTestFixtureDeadlineCalls extends org.openrewrite.Recipe
Leaves a // TODO(axon4to5): marker on the statements that use the deadline and time support of the Axon Framework 4 aggregate test fixture, keeping every call in place.

The Axon Framework 4 AggregateTestFixture ran a stub deadline manager on a simulated clock: tests asserted scheduled, cancelled and triggered deadlines (expectScheduledDeadline*, expectNoScheduledDeadline*, expectDeadlinesMet*, expectTriggeredDeadlines*), moved the clock (givenCurrentTime, andGivenCurrentTime, currentTime, whenTimeElapses, whenTimeAdvancesTo and their whenThen* and andThen* variants) and intercepted deadlines (registerDeadlineDispatchInterceptor, registerDeadlineHandlerInterceptor). The Axon Framework 5 AxonTestFixture the aggregate fixture migrates to has none of this: no deadline manager and no clock. The fluent rewrite of the surrounding chain therefore leaves these calls behind as code that does not compile, and how to test the deadline instead depends on what the test meant to verify.

The marker text depends on where the migrated application runs its deadlines. Free Axon Framework 5 has none. On Axoniq Framework, axoniq-legacy delivers a fired aggregate deadline as a command to the @CommandHandler its @DeadlineHandler became, so a test can send that command itself; set axoniqLegacy to say so. Both variants share the marker keys, so the free migration leaves a statement alone that the commercial one marked first.

Runs on the Axon Framework 4 types, before they are renamed. Java sources only. Idempotent.

Since:
5.4.0
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
    Creates the recipe, choosing the marker text for the platform the deadlines migrate to.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Boolean
    Returns whether the migrated application keeps its deadlines on axoniq-legacy.
     
     
    org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext>
     

    Methods inherited from class org.openrewrite.Recipe

    addDataTable, aggregateDataTableDescriptors, 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

    • MarkAggregateTestFixtureDeadlineCalls

      public MarkAggregateTestFixtureDeadlineCalls(@Nullable Boolean axoniqLegacy)
      Creates the recipe, choosing the marker text for the platform the deadlines migrate to.
      Parameters:
      axoniqLegacy - whether the deadlines keep running on axoniq-legacy; null means they do not
  • Method Details

    • getAxoniqLegacy

      public @Nullable Boolean getAxoniqLegacy()
      Returns whether the migrated application keeps its deadlines on axoniq-legacy.
      Returns:
      whether the deadlines keep running on axoniq-legacy, or null when not set
    • 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