Skip to content

Commit 9b2d256

Browse files
authored
Migrating Groovy to Java call site instrumentation plugin (#10462)
[G2J] call site instrumentation plugin Migration from Groovy to Java for unit tests restore before migration Moving groovy to java to keep history restore migrated files Add script to move groovy files as java ones address comments address comments add claude skill remove script modified SKILL fix test Co-authored-by: jean-philippe.bempel <jean-philippe.bempel@datadoghq.com>
1 parent e4e2d01 commit 9b2d256

24 files changed

Lines changed: 2880 additions & 2526 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: migrate-groovy-to-java
3+
description: migrate test groovy files to java
4+
---
5+
6+
Migrate test Groovy files to Java using JUnit 5
7+
8+
1. List all groovy files of the current gradle module
9+
2. convert groovy files to Java using Junit 5
10+
3. make sure the tests are still passing after migration
11+
4. remove groovy files
12+
13+
When converting groovy code to java code make sure that:
14+
- the Java code generated is compatible with JDK 8
15+
- when translating Spock test, favor using `@CsvSource` with `|` delimiters
16+
- when using a `@MethodSource`, use the test method name, and suffix it with `_arguments`
17+
- when converting tuples, create light dedicated structure instead to keep the typing system
18+
- Instead of checking a state and throwing an exception, use JUnit asserts
19+
- Do not wrap checked exception and throwing a Runtime exception, prefer adding a throws clause at method declaration
20+
- Do not mark local variables `final`

buildSrc/call-site-instrumentation-plugin/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
java
3-
groovy
43
id("com.diffplug.spotless") version "8.2.1"
54
id("com.gradleup.shadow") version "8.3.9"
65
}
@@ -34,8 +33,9 @@ dependencies {
3433
implementation(libs.javaparser.symbol.solver)
3534

3635
testImplementation(libs.bytebuddy)
37-
testImplementation(libs.bundles.groovy)
38-
testImplementation(libs.bundles.spock)
36+
testImplementation(libs.bundles.junit5)
37+
testRuntimeOnly(libs.junit.platform.launcher)
38+
testImplementation(libs.bundles.mockito)
3939
testImplementation("javax.servlet", "javax.servlet-api", "3.0.1")
4040
testImplementation(libs.spotbugs.annotations)
4141
}

0 commit comments

Comments
 (0)