Lines 182-188
Link Here
|
182 |
disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION); |
182 |
disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION); |
183 |
enable(CleanUpConstants.USE_LAMBDA); |
183 |
enable(CleanUpConstants.USE_LAMBDA); |
184 |
|
184 |
|
185 |
assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original }); |
185 |
buf= new StringBuffer(); |
|
|
186 |
buf.append("package test;\n"); |
187 |
buf.append("import java.util.*;\n"); |
188 |
buf.append("public class E {\n"); |
189 |
buf.append(" void foo(Integer[] ints){\n"); |
190 |
buf.append(" Arrays.sort(ints, (Comparator<Integer>) (i1, i2) -> i1 - i2);\n"); |
191 |
buf.append(" Comparator<?> cw = (Comparator<Object>) (w1, w2) -> 0;\n"); |
192 |
buf.append(" Comparator cr = (r1, r2) -> 0;\n"); |
193 |
buf.append(" Comparator<? extends Number> ce = (Comparator<Number>) (n1, n2) -> -0;\n"); |
194 |
buf.append(" };\n"); |
195 |
buf.append("}\n"); |
196 |
String expected2= buf.toString(); |
197 |
|
198 |
assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected2 }); |
186 |
} |
199 |
} |
187 |
|
200 |
|
188 |
public void testConvertToAnonymous_andBack_WithWildcards1() throws Exception { |
201 |
public void testConvertToAnonymous_andBack_WithWildcards1() throws Exception { |
Lines 226-232
Link Here
|
226 |
disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION); |
239 |
disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION); |
227 |
enable(CleanUpConstants.USE_LAMBDA); |
240 |
enable(CleanUpConstants.USE_LAMBDA); |
228 |
|
241 |
|
229 |
assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original }); |
242 |
buf= new StringBuffer(); |
|
|
243 |
buf.append("package test;\n"); |
244 |
buf.append("\n"); |
245 |
buf.append("interface I<M> {\n"); |
246 |
buf.append(" M run(M x);\n"); |
247 |
buf.append("}\n"); |
248 |
buf.append("\n"); |
249 |
buf.append("class Test {\n"); |
250 |
buf.append(" I<?> li = (I<Object>) s -> null;\n"); |
251 |
buf.append("}\n"); |
252 |
String expected2= buf.toString(); |
253 |
|
254 |
assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected2 }); |
230 |
} |
255 |
} |
231 |
|
256 |
|
232 |
public void testConvertToAnonymous_andBack_WithJoinedSAM() throws Exception { |
257 |
public void testConvertToAnonymous_andBack_WithJoinedSAM() throws Exception { |
Lines 302-311
Link Here
|
302 |
|
327 |
|
303 |
buf= new StringBuffer(); |
328 |
buf= new StringBuffer(); |
304 |
buf.append("package test;\n"); |
329 |
buf.append("package test;\n"); |
|
|
330 |
buf.append("import java.util.concurrent.Callable;\n"); |
305 |
buf.append("import java.util.concurrent.Executors;\n"); |
331 |
buf.append("import java.util.concurrent.Executors;\n"); |
306 |
buf.append("public class E {\n"); |
332 |
buf.append("public class E {\n"); |
307 |
buf.append(" void foo() {\n"); |
333 |
buf.append(" void foo() {\n"); |
308 |
buf.append(" new Thread(() -> Executors.newSingleThreadExecutor().submit(() -> \"hi\"));\n"); |
334 |
buf.append(" new Thread(() -> Executors.newSingleThreadExecutor().submit((Callable<String>) () -> \"hi\"));\n"); |
309 |
buf.append(" }\n"); |
335 |
buf.append(" }\n"); |
310 |
buf.append("}\n"); |
336 |
buf.append("}\n"); |
311 |
String expected1= buf.toString(); |
337 |
String expected1= buf.toString(); |