Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openrewrite/rewrite-testing-frameworks
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.31.0
Choose a base ref
...
head repository: openrewrite/rewrite-testing-frameworks
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.32.0
Choose a head ref
  • 4 commits
  • 15 files changed
  • 2 contributors

Commits on Mar 26, 2026

  1. Fix Mockito1to3Migration not adding runner after removing PowerMockRu…

    …nner (#942)
    
    ReplacePowerMockito was ordered after AddMockitoExtensionIfAnnotationsUsed,
    so the latter would see @RunWith(PowerMockRunner.class) and skip the class.
    Then ReplacePowerMockito would remove it, leaving @mock fields uninitialized.
    
    Move ReplacePowerMockito before AddMockitoExtensionIfAnnotationsUsed so the
    runner gap is detected and filled with MockitoJUnitRunner or MockitoExtension.
    bmuschko authored Mar 26, 2026
    Configuration menu
    Copy the full SHA
    a72d7b1 View commit details
    Browse the repository at this point in the history
  2. Refactor PowerMockito recipes for clarity and single responsibility (#…

    …943)
    
    * Refactor PowerMockitoMockStaticToMockito for clarity and single responsibility
    
    Extract independent responsibilities from the monolithic 557-line recipe:
    
    - Extract `RemovePowerMockClassExtensions` recipe for removing
      `extends PowerMockConfiguration` and `extends PowerMockTestCase`
    - Fold `@RunWith(PowerMockRunner.class)` removal (with and without
      delegate) into `PowerMockRunnerDelegateToRunWith`
    - Replace 8 mutable instance fields with a `TestFramework` enum
    - Add early returns throughout to reduce nesting and improve readability
    
    * Clean up PowerMockitoMockStaticToMockito visitor
    
    - Consolidate isStaticMockAlreadyClosed/isStaticMockAlreadyOpened into
      single hasMatchingInvocation method parameterized by MethodMatcher
    - Restructure visitMethodInvocation with early returns for clarity
    - Fix double getTestGroupsAsString() call in maybeAddTearDownMethodBody
    - Simplify mockStatic tracking to use direct list access instead of
      Optional stream
    
    * Improve PowerMockRunnerDelegateToRunWith per review feedback
    
    - Use service(AnnotationService.class) instead of manual stream check
    - Extract findDelegateRunnerArg method to avoid finalDelegateRunnerArg
    - Move shared maybeRemoveImport(POWER_MOCK_RUNNER) above if/else so
      each branch can return immediately
    
    * Move import removal before withLeadingAnnotations for immediate returns
    
    * Update src/main/java/org/openrewrite/java/testing/mockito/PowerMockRunnerDelegateToRunWith.java
    timtebeek authored Mar 26, 2026
    Configuration menu
    Copy the full SHA
    43acae3 View commit details
    Browse the repository at this point in the history

Commits on Mar 27, 2026

  1. Add PowerMockWhiteboxToJavaReflection recipe (#944)

    * Add PowerMockWhiteboxToJavaReflection recipe
    
    Replace `org.powermock.reflect.Whitebox` calls with plain Java
    reflection as part of the ReplacePowerMockito recipe chain.
    
    Handles setInternalState, getInternalState, and invokeMethod by
    expanding each call into getDeclaredField/getDeclaredMethod +
    setAccessible + get/set/invoke. Uses VariableNameUtils to avoid
    name collisions when multiple Whitebox calls target the same field.
    
    * Regenerate recipes.csv to include PowerMockWhiteboxToJavaReflection
    
    * Add powermock-reflect-1.6.5 classpath JAR for type resolution
    
    * Regenerate classpath type table to include powermock-reflect
    
    The classpath.tsv.gz type table is what CI uses for type resolution
    in tests. The previously committed JAR is unnecessary when the type
    table includes the artifact.
    
    * Address review feedback on PowerMockWhiteboxToJavaReflection
    
    - Inline the named WhiteboxVisitor into an anonymous class
    - Use immediate return for maybeAutoFormat
    - Remove unnecessary powermock-reflect-1 classpath from integration test
    
    * Fix template type attribution by using #{any(java.lang.Object)}
    
    Untyped #{any()} placeholders caused the template parser to infer the
    argument's actual type (e.g. MyService), which is not on the template
    parser's classpath. This broke type resolution for the entire method
    chain (.getClass(), .getDeclaredField(), .setAccessible(), etc.).
    
    Using #{any(java.lang.Object)} ensures the substitution always resolves
    against a JDK type, fixing type attribution. Also inlines the JAVA_PARSER
    field and removes the now-unnecessary methodInvocations(false) from the
    unit test.
    
    ---------
    
    Co-authored-by: Tim te Beek <[email protected]>
    bmuschko and timtebeek authored Mar 27, 2026
    Configuration menu
    Copy the full SHA
    e679ace View commit details
    Browse the repository at this point in the history
  2. Use declared parameter types for Whitebox.invokeMethod reflection (#945)

    Resolve the target method's declared parameter types from the AST
    instead of using arg.getClass() which returns the runtime concrete
    class and fails when the method parameter is an interface/parent type.
    
    Three-tier resolution strategy:
    1. Resolve the target method declaration and use its parameter types
    2. Fall back to the argument's compile-time type
    3. Fall back to arg.getClass() when no type info is available
    bmuschko authored Mar 27, 2026
    Configuration menu
    Copy the full SHA
    cf368d7 View commit details
    Browse the repository at this point in the history
Loading