@@ -31,7 +31,7 @@ class MigrateToJspecifyTest implements RewriteTest {
31
31
public void defaults (RecipeSpec spec ) {
32
32
spec
33
33
.recipeFromResource ("/META-INF/rewrite/jspecify.yml" , "org.openrewrite.java.jspecify.MigrateToJspecify" )
34
- .parser (JavaParser .fromJavaVersion ().classpath ("jsr305" , "jakarta.annotation-api" , "annotations" ));
34
+ .parser (JavaParser .fromJavaVersion ().classpath ("jsr305" , "jakarta.annotation-api" , "annotations" , "spring-core" ));
35
35
}
36
36
37
37
@ DocumentExample
@@ -45,7 +45,7 @@ void migrateFromJavaxAnnotationApiToJspecify() {
45
45
"""
46
46
import javax.annotation.Nonnull;
47
47
import javax.annotation.Nullable;
48
-
48
+
49
49
public class Test {
50
50
@Nonnull
51
51
public String field1;
@@ -54,7 +54,7 @@ public class Test {
54
54
@Nullable
55
55
public Foo.Bar foobar;
56
56
}
57
-
57
+
58
58
interface Foo {
59
59
class Bar {
60
60
@Nonnull
@@ -65,16 +65,16 @@ class Bar {
65
65
"""
66
66
import org.jspecify.annotations.NonNull;
67
67
import org.jspecify.annotations.Nullable;
68
-
68
+
69
69
public class Test {
70
70
@NonNull
71
71
public String field1;
72
72
@Nullable
73
73
public String field2;
74
-
74
+
75
75
public Foo.@Nullable Bar foobar;
76
76
}
77
-
77
+
78
78
interface Foo {
79
79
class Bar {
80
80
@NonNull
@@ -308,4 +308,95 @@ class Bar {
308
308
)
309
309
);
310
310
}
311
+
312
+ @ Test
313
+ void migrateFromSpringFrameworkAnnotationsToJspecify () {
314
+ rewriteRun (
315
+ mavenProject ("foo" ,
316
+ //language=java
317
+ srcMainJava (
318
+ java (
319
+ """
320
+ import org.springframework.lang.NonNull;
321
+ import org.springframework.lang.Nullable;
322
+
323
+ public class Test {
324
+ @NonNull
325
+ public String field1;
326
+ @Nullable
327
+ public String field2;
328
+ @Nullable
329
+ public Foo.Bar foobar;
330
+ }
331
+
332
+ interface Foo {
333
+ class Bar {
334
+ @NonNull
335
+ public String barField;
336
+ }
337
+ }
338
+ """ ,
339
+ """
340
+ import org.jspecify.annotations.NonNull;
341
+ import org.jspecify.annotations.Nullable;
342
+
343
+ public class Test {
344
+ @NonNull
345
+ public String field1;
346
+ @Nullable
347
+ public String field2;
348
+
349
+ public Foo.@Nullable Bar foobar;
350
+ }
351
+
352
+ interface Foo {
353
+ class Bar {
354
+ @NonNull
355
+ public String barField;
356
+ }
357
+ }
358
+ """
359
+ )
360
+ ),
361
+ //language=xml
362
+ pomXml (
363
+ """
364
+ <project>
365
+ <modelVersion>4.0.0</modelVersion>
366
+ <groupId>com.example.foobar</groupId>
367
+ <artifactId>foobar-core</artifactId>
368
+ <version>1.0.0</version>
369
+ <dependencies>
370
+ <dependency>
371
+ <groupId>org.springframework</groupId>
372
+ <artifactId>spring-core</artifactId>
373
+ <version>6.1.13</version>
374
+ </dependency>
375
+ </dependencies>
376
+ </project>
377
+ """ ,
378
+ """
379
+ <project>
380
+ <modelVersion>4.0.0</modelVersion>
381
+ <groupId>com.example.foobar</groupId>
382
+ <artifactId>foobar-core</artifactId>
383
+ <version>1.0.0</version>
384
+ <dependencies>
385
+ <dependency>
386
+ <groupId>org.jspecify</groupId>
387
+ <artifactId>jspecify</artifactId>
388
+ <version>1.0.0</version>
389
+ </dependency>
390
+ <dependency>
391
+ <groupId>org.springframework</groupId>
392
+ <artifactId>spring-core</artifactId>
393
+ <version>6.1.13</version>
394
+ </dependency>
395
+ </dependencies>
396
+ </project>
397
+ """
398
+ )
399
+ )
400
+ );
401
+ }
311
402
}
0 commit comments