File tree Expand file tree Collapse file tree 2 files changed +125
-0
lines changed
rewrite-java-test/src/test/java/org/openrewrite/java
rewrite-maven/src/test/java/org/openrewrite/maven Expand file tree Collapse file tree 2 files changed +125
-0
lines changed Original file line number Diff line number Diff line change @@ -536,6 +536,43 @@ public class A {
536
536
);
537
537
}
538
538
539
+ @ Test
540
+ void arrayInAnnotationValueAttribute () {
541
+ rewriteRun (
542
+ spec -> spec .recipe (new AddOrUpdateAnnotationAttribute (
543
+ "org.example.Foo" ,
544
+ null ,
545
+ "newTest" ,
546
+ null ,
547
+ false ,
548
+ false )),
549
+ java (
550
+ """
551
+ package org.example;
552
+ public @interface Foo {
553
+ String[] value() default {};
554
+ }
555
+ """
556
+ ),
557
+ java (
558
+ """
559
+ import org.example.Foo;
560
+
561
+ @Foo({"oldTest"})
562
+ public class A {
563
+ }
564
+ """ ,
565
+ """
566
+ import org.example.Foo;
567
+
568
+ @Foo({"newTest"})
569
+ public class A {
570
+ }
571
+ """
572
+ )
573
+ );
574
+ }
575
+
539
576
@ Test
540
577
void arrayInputMoreThanOneInAnnotationAttribute () {
541
578
rewriteRun (
@@ -573,6 +610,43 @@ public class A {
573
610
);
574
611
}
575
612
613
+ @ Test
614
+ void arrayInputMoreThanOneInAnnotationValueAttribute () {
615
+ rewriteRun (
616
+ spec -> spec .recipe (new AddOrUpdateAnnotationAttribute (
617
+ "org.example.Foo" ,
618
+ null ,
619
+ "newTest1,newTest2" ,
620
+ null ,
621
+ false ,
622
+ false )),
623
+ java (
624
+ """
625
+ package org.example;
626
+ public @interface Foo {
627
+ String[] value() default {};
628
+ }
629
+ """
630
+ ),
631
+ java (
632
+ """
633
+ import org.example.Foo;
634
+
635
+ @Foo({"oldTest"})
636
+ public class A {
637
+ }
638
+ """ ,
639
+ """
640
+ import org.example.Foo;
641
+
642
+ @Foo({"newTest1", "newTest2"})
643
+ public class A {
644
+ }
645
+ """
646
+ )
647
+ );
648
+ }
649
+
576
650
@ Test
577
651
void addArrayInputInAnnotationAttribute () {
578
652
rewriteRun (
Original file line number Diff line number Diff line change @@ -257,6 +257,57 @@ void keepsUsedProperty() {
257
257
);
258
258
}
259
259
260
+ @ Test
261
+ void checkPlugin () {
262
+ rewriteRun (
263
+ pomXml (
264
+ """
265
+ <?xml version="1.0" encoding="UTF-8"?>
266
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
267
+ <modelVersion>4.0.0</modelVersion>
268
+ <groupId>org.sample</groupId>
269
+ <artifactId>sample</artifactId>
270
+ <version>1.0.0</version>
271
+
272
+ <properties>
273
+ <versionx>6.0.0</versionx>
274
+ <bar>xyz</bar>
275
+ </properties>
276
+
277
+ <plugins>
278
+ <plugin>
279
+ <groupId>org.openrewrite.maven</groupId>
280
+ <artifactId>rewrite-maven-plugin</artifactId>
281
+ <version>${versionx}</version>
282
+ </plugin>
283
+ </plugins>
284
+ </project>
285
+ """ ,
286
+ """
287
+ <?xml version="1.0" encoding="UTF-8"?>
288
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
289
+ <modelVersion>4.0.0</modelVersion>
290
+ <groupId>org.sample</groupId>
291
+ <artifactId>sample</artifactId>
292
+ <version>1.0.0</version>
293
+
294
+ <properties>
295
+ <versionx>6.0.0</versionx>
296
+ </properties>
297
+
298
+ <plugins>
299
+ <plugin>
300
+ <groupId>org.openrewrite.maven</groupId>
301
+ <artifactId>rewrite-maven-plugin</artifactId>
302
+ <version>${versionx}</version>
303
+ </plugin>
304
+ </plugins>
305
+ </project>
306
+ """
307
+ )
308
+ );
309
+ }
310
+
260
311
@ Test
261
312
void catchesMultiplePropertyUsagesInSameElement () {
262
313
rewriteRun (
You can’t perform that action at this time.
0 commit comments