@@ -42,15 +42,15 @@ void templateError() {
42
42
java (
43
43
"""
44
44
import java.util.*;
45
-
45
+
46
46
interface ConnectionListener {
47
47
void onCreate();
48
48
}
49
-
49
+
50
50
class A {
51
51
public void setConnectionListeners(List<? extends ConnectionListener> listeners) {
52
52
}
53
-
53
+
54
54
public void test() {
55
55
setConnectionListeners(Collections.singletonList(new ConnectionListener() {
56
56
@Override
@@ -62,15 +62,15 @@ public void onCreate() {
62
62
""" ,
63
63
"""
64
64
import java.util.List;
65
-
65
+
66
66
interface ConnectionListener {
67
67
void onCreate();
68
68
}
69
-
69
+
70
70
class A {
71
71
public void setConnectionListeners(List<? extends ConnectionListener> listeners) {
72
72
}
73
-
73
+
74
74
public void test() {
75
75
setConnectionListeners(List.of(new ConnectionListener() {
76
76
@Override
@@ -93,14 +93,14 @@ void singletonList() {
93
93
java (
94
94
"""
95
95
import java.util.*;
96
-
96
+
97
97
class Test {
98
98
List<String> list = Collections.singletonList("ABC");
99
99
}
100
100
""" ,
101
101
"""
102
102
import java.util.List;
103
-
103
+
104
104
class Test {
105
105
List<String> list = List.of("ABC");
106
106
}
@@ -118,14 +118,14 @@ void singletonListStaticImport() {
118
118
"""
119
119
import java.util.*;
120
120
import static java.util.Collections.singletonList;
121
-
121
+
122
122
class Test {
123
123
List<String> list = singletonList("ABC");
124
124
}
125
125
""" ,
126
126
"""
127
127
import java.util.List;
128
-
128
+
129
129
class Test {
130
130
List<String> list = List.of("ABC");
131
131
}
@@ -143,15 +143,15 @@ void singletonListCustomType() {
143
143
"""
144
144
import java.util.*;
145
145
import java.time.LocalDate;
146
-
146
+
147
147
class Test {
148
148
List<LocalDate> list = Collections.singletonList(LocalDate.now());
149
149
}
150
150
""" ,
151
151
"""
152
152
import java.util.List;
153
153
import java.time.LocalDate;
154
-
154
+
155
155
class Test {
156
156
List<LocalDate> list = List.of(LocalDate.now());
157
157
}
@@ -164,27 +164,40 @@ class Test {
164
164
@ Test
165
165
void lombokAllArgsConstructor () {
166
166
rewriteRun (
167
- spec -> spec .parser (JavaParser .fromJavaVersion ().classpath ("lombok" ))
168
- .typeValidationOptions (TypeValidation .builder ().constructorInvocations (false ).build ()),
167
+ spec -> spec .parser (JavaParser .fromJavaVersion ().classpath ("lombok" )),
169
168
//language=java
170
169
java (
171
170
"""
172
171
import lombok.AllArgsConstructor;
173
172
import java.util.List;
174
-
173
+
175
174
import static java.util.Collections.singletonList;
176
-
175
+
177
176
enum FooEnum {
178
177
FOO, BAR;
179
-
178
+
180
179
@AllArgsConstructor
181
180
public enum BarEnum {
182
181
foobar(singletonList(FOO));
183
-
182
+
184
183
private final List<FooEnum> expectedStates;
185
184
}
186
185
}
187
- """
186
+ """ ,
187
+ """
188
+ import lombok.AllArgsConstructor;
189
+ import java.util.List;
190
+
191
+ enum FooEnum {
192
+ FOO, BAR;
193
+
194
+ @AllArgsConstructor
195
+ public enum BarEnum {
196
+ foobar(List.of(FOO));
197
+
198
+ private final List<FooEnum> expectedStates;
199
+ }
200
+ }"""
188
201
)
189
202
);
190
203
}
@@ -197,7 +210,7 @@ void shouldNotConvertLiteralNull() {
197
210
java (
198
211
"""
199
212
import java.util.*;
200
-
213
+
201
214
class Test {
202
215
List<String> list = Collections.singletonList(null);
203
216
}
0 commit comments