Excavator: Migrate Groovy nebula test PalantirJavaFormatSpotlessPluginTest to the new Java Junit framework
#1482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
excavator is a bot for automating changes across repositories.
Changes produced by the roomba/migrate-gradle-testing-junit-framework check.
A formatted diff between the old and new test has been generated at test-migration-notes/PalantirJavaFormatSpotlessPluginTest.html)
To view the rendered diff, copy the branch name above, click here, and then replace the BRANCH_NAME part of the URL with the branch name.
🤖 🤖 This PR was created using Claude-code 🤖 🤖
Claude Execution Message
Claude finished running successfully.
Perfect! Let me now create a brief summary for the user:
Migration Complete! ✅
I've successfully migrated the test class from the Nebula/Spock framework to the new Java-based testing framework.
What Was Done
Added delineator comments to the original Groovy test file for easier review comparison
Created the migrated Java test at:
/repo/gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPluginTest.javagroovydirectory (notjava) because it needs to accessGradlewExecutor.javawhich is also thereKey migration changes:
@Unrollwithwhereclause to JUnit 5@ParameterizedTestwith@MethodSourceformats_with_spotless_when_spotless_is_appliedrootProject.settingsGradle().append(...), etc.)@BeforeEachwith parameter injectionCompilation verified: ✅ The test compiles successfully
Documentation Created
Important Notes
GradlewExecutor(not the standardGradleInvoker) because it needs special classpath handling to avoid loading formatter classes twicegradle.withArgs("wrapper").buildsSuccessfully()The migration is complete and ready for review! 🎉
Claude Code Metrics
Migration Notes
Test Migration Errors and Learnings
First Pass - Initial Migration
Error 1: Import Statement for Nested Class
Error:
package com.palantir.javaformat.gradle.GradlewExecutor does not existWhat I did:
com.palantir.javaformat.gradle.GradlewExecutor.GradlewExecutionResultwhich failedGradlewExecutionResultis a nested record inGradlewExecutorFix:
GradlewExecutor.GradlewExecutionResultinline in the codeError 2: Wrong Assertion Library
Error:
no suitable method found for assertThat(String)What I did:
com.palantir.gradle.testing.assertion.GradlePluginTestAssertions.assertThatFix:
import static org.assertj.core.api.Assertions.assertThat;Error 3: File Location - Java vs Groovy Source Directory
Error:
cannot find symbol: class GradlewExecutorWhat I did:
src/test/java/as specified in the instructionsGradlewExecutor.javais located insrc/test/groovy/src/test/java/before Groovy filessrc/test/java/cannot access Java classes insrc/test/groovy/Fix:
src/test/groovy/where it can access GradlewExecutor/repo/gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPluginTest.javaSecond Pass - Review Against Testing Guide
Improvement 1: Fluent API Chaining
Issue: Multiple calls to
rootProject.gradlePropertiesFile().append()could be chainedWhat I did:
Fix:
Note on Text Blocks
The testing guide recommends adding a newline after text blocks for clarity. In this migration, the text blocks are already well-formatted with proper indentation and the content flows naturally. The guide's recommendation is more about separating the text block from subsequent code, which is already achieved through the existing formatting.
Note on Helper Methods vs Variables
The instructions suggested converting string variables for Java files into helper methods. However, in this case:
validJavaFile()andinvalidJavaFile()are already implemented as static methods returning stringsTo enable or disable this check, please contact the maintainers of Excavator.