1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juneau.reflect;
18
19 import static java.lang.annotation.ElementType.*;
20 import static java.lang.annotation.RetentionPolicy.*;
21 import static org.apache.juneau.TestUtils.*;
22 import static org.apache.juneau.reflect.ReflectFlags.*;
23 import static org.junit.jupiter.api.Assertions.*;
24
25 import java.io.*;
26 import java.lang.annotation.*;
27 import java.util.*;
28 import java.util.function.*;
29 import java.util.stream.*;
30
31 import org.apache.juneau.*;
32 import org.apache.juneau.internal.*;
33 import org.junit.jupiter.api.*;
34
35 class ExecutableInfo_Test extends TestBase {
36
37 private static void check(String expected, Object o) {
38 assertEquals(expected, TO_STRING.apply(o));
39 }
40
41 private static final Function<Object,String> TO_STRING = new Function<>() {
42 @Override
43 public String apply(Object t) {
44 if (t == null)
45 return null;
46 if (t instanceof List)
47 return ((List<?>)t).stream().map(this).collect(Collectors.joining(","));
48 if (isArray(t))
49 return StreamSupport.stream(ArrayUtils.toList(t, Object.class).spliterator(), false).map(this).collect(Collectors.joining(","));
50 if (t instanceof Annotation)
51 return "@" + ((Annotation)t).annotationType().getSimpleName() + "()";
52 if (t instanceof Class)
53 return ((Class<?>)t).getSimpleName();
54 if (t instanceof ClassInfo)
55 return ((ClassInfo)t).getSimpleName();
56 if (t instanceof ConstructorInfo)
57 return ((ConstructorInfo)t).getShortName();
58 if (t instanceof ParamInfo)
59 return apply(((ParamInfo)t).toString());
60 return t.toString();
61 }
62 };
63
64
65
66
67
68 static class A {
69 public A() {}
70 public void foo() {}
71 }
72 static ClassInfo a = ClassInfo.of(A.class);
73
74 @Test void isConstructor() {
75 assertTrue(a.getPublicConstructor(ConstructorInfo::hasNoParams).isConstructor());
76 assertFalse(a.getPublicMethod(x -> x.hasName("foo")).isConstructor());
77 }
78
79 @Test void getDeclaringClass() {
80 check("A", a.getPublicConstructor(ConstructorInfo::hasNoParams).getDeclaringClass());
81 check("A", a.getPublicMethod(x -> x.hasName("foo")).getDeclaringClass());
82 }
83
84
85
86
87
88 static class B {
89 public B() {}
90 public B(String s) {}
91 public void m() {}
92 public int m(String s) { return 0; }
93 }
94 static ClassInfo b = ClassInfo.of(B.class);
95 static ExecutableInfo
96 b_c1 = b.getPublicConstructor(ConstructorInfo::hasNoParams),
97 b_c2 = b.getPublicConstructor(x -> x.hasParamTypes(String.class)),
98 b_m1 = b.getPublicMethod(x -> x.hasName("m") && x.hasNoParams()),
99 b_m2 = b.getPublicMethod(x -> x.hasName("m") && x.hasParamTypes(String.class))
100 ;
101
102 @Test void getParamCount() {
103 assertEquals(0, b_c1.getParamCount());
104 assertEquals(1, b_c2.getParamCount());
105 assertEquals(0, b_m1.getParamCount());
106 assertEquals(1, b_m2.getParamCount());
107 }
108
109 @Test void hasParams() {
110 assertEquals(false, b_c1.hasParams());
111 assertEquals(true, b_c2.hasParams());
112 assertEquals(false, b_m1.hasParams());
113 assertEquals(true, b_m2.hasParams());
114 }
115
116 @Test void hasNoParams() {
117 assertEquals(true, b_c1.hasNoParams());
118 assertEquals(false, b_c2.hasNoParams());
119 assertEquals(true, b_m1.hasNoParams());
120 assertEquals(false, b_m2.hasNoParams());
121 }
122
123 @Test void hasNumParams() {
124 assertEquals(false, b_c1.hasNumParams(1));
125 assertEquals(true, b_c2.hasNumParams(1));
126 assertEquals(false, b_m1.hasNumParams(1));
127 assertEquals(true, b_m2.hasNumParams(1));
128 }
129
130 @Test void getParams() {
131 check("", b_c1.getParams());
132 check("B[0]", b_c2.getParams());
133 check("", b_m1.getParams());
134 check("m[0]", b_m2.getParams());
135 }
136
137 @Test void getParams_twice() {
138 check("", b_c1.getParams());
139 check("", b_c1.getParams());
140 }
141
142 @Test void getParam() {
143 check("B[0]", b_c2.getParam(0));
144 check("m[0]", b_m2.getParam(0));
145 }
146
147 @Test void getParam_nocache() {
148 var b2 = ClassInfo.of(B.class);
149 check("B[0]", b2.getPublicConstructor(x -> x.hasParamTypes(String.class)).getParam(0));
150 check("m[0]", b2.getPublicMethod(x -> x.hasName("m") && x.hasParamTypes(String.class)).getParam(0));
151 }
152
153 @Test void getParam_indexOutOfBounds() {
154 assertThrowsWithMessage(IndexOutOfBoundsException.class, "Invalid index '0'. No parameters.", ()->b_c1.getParam(0));
155 assertThrowsWithMessage(IndexOutOfBoundsException.class, "Invalid index '-1'. Parameter count: 1", ()->b_c2.getParam(-1));
156 assertThrowsWithMessage(IndexOutOfBoundsException.class, "Invalid index '1'. Parameter count: 1", ()->b_c2.getParam(1));
157 }
158
159 @Test void getParam_indexOutOfBounds_noCache() {
160 var b2 = ClassInfo.of(B.class);
161 assertThrowsWithMessage(IndexOutOfBoundsException.class, "Invalid index '0'. No parameters.", ()->b2.getPublicConstructor(ConstructorInfo::hasNoParams).getParam(0));
162 assertThrowsWithMessage(IndexOutOfBoundsException.class, "Invalid index '-1'. Parameter count: 1", ()->b2.getPublicConstructor(x -> x.hasParamTypes(String.class)).getParam(-1));
163 assertThrowsWithMessage(IndexOutOfBoundsException.class, "Invalid index '1'. Parameter count: 1", ()->b2.getPublicConstructor(x -> x.hasParamTypes(String.class)).getParam(1));
164 }
165
166 @Test void getParamTypes() {
167 check("", b_c1.getParamTypes());
168 check("String", b_c2.getParamTypes());
169 check("", b_m1.getParamTypes());
170 check("String", b_m2.getParamTypes());
171 }
172
173 @Test void getParamTypes_twice() {
174 check("", b_c1.getParamTypes());
175 check("", b_c1.getParamTypes());
176 }
177
178 enum B1 {
179 FOO;
180 }
181
182 @Test void getParamTypes_enum() {
183 var b1 = ClassInfo.of(B1.class);
184 check("B1(String,int)", b1.getDeclaredConstructors());
185 check("String,int", b1.getDeclaredConstructors().get(0).getParamTypes());
186 }
187
188 @Test void getParamType() {
189 check("String", b_c2.getParamType(0));
190 check("String", b_m2.getParamType(0));
191 }
192
193 @Test void getRawParamTypes() {
194 check("", b_c1.getRawParamTypes());
195 check("String", b_c2.getRawParamTypes());
196 check("", b_m1.getRawParamTypes());
197 check("String", b_m2.getRawParamTypes());
198 }
199
200 @Test void getRawParamType() {
201 check("String", b_c2.getRawParamType(0));
202 check("String", b_m2.getRawParamType(0));
203 }
204
205 @Test void getRawGenericParamType() {
206 check("String", b_c2.getRawGenericParamType(0));
207 check("String", b_m2.getRawGenericParamType(0));
208 }
209
210 @Test void getRawGenericParamTypes() {
211 check("", b_c1.getRawGenericParamTypes());
212 check("String", b_c2.getRawGenericParamTypes());
213 check("", b_m1.getRawGenericParamTypes());
214 check("String", b_m2.getRawGenericParamTypes());
215 }
216
217 @Test void getRawParameters() {
218 check("", b_c1.getRawParameters());
219 assertTrue(b_c2.getRawParameters().get(0).toString().startsWith("java.lang.String "));
220 check("", b_m1.getRawParameters());
221 assertTrue(b_m2.getRawParameters().get(0).toString().startsWith("java.lang.String "));
222 }
223
224 @Test void getRawParameter() {
225 assertTrue(b_c2.getRawParameter(0).toString().startsWith("java.lang.String "));
226 assertTrue(b_m2.getRawParameter(0).toString().startsWith("java.lang.String "));
227 }
228
229
230
231
232
233 @Documented
234 @Target({PARAMETER,METHOD,CONSTRUCTOR})
235 @Retention(RUNTIME)
236 @Inherited
237 public static @interface CA {}
238
239 static class C {
240 public C() {}
241 public C(@CA String foo) {}
242 public @CA C(int bar) {}
243 public void m() {}
244 public void m(@CA String foo) {}
245 public @CA void m(int bar) {}
246 }
247 static ClassInfo c = ClassInfo.of(C.class);
248 static ConstructorInfo
249 c_c1=c.getPublicConstructor(ConstructorInfo::hasNoParams),
250 c_c2=c.getPublicConstructor(x -> x.hasParamTypes(String.class)),
251 c_c3=c.getPublicConstructor(x -> x.hasParamTypes(int.class))
252 ;
253 static MethodInfo
254 c_m1=c.getPublicMethod(x -> x.hasName("m") && x.hasNoParams()),
255 c_m2=c.getPublicMethod(x -> x.hasName("m") && x.hasParamTypes(String.class)),
256 c_m3=c.getPublicMethod(x -> x.hasName("m") && x.hasParamTypes(int.class))
257 ;
258
259 @Test void getParameterAnnotations() {
260 check("", c_c1._getParameterAnnotations());
261 check("@CA()", c_c2._getParameterAnnotations());
262 check("", c_c3._getParameterAnnotations());
263 check("", c_m1._getParameterAnnotations());
264 check("@CA()", c_m2._getParameterAnnotations());
265 check("", c_m3._getParameterAnnotations());
266 }
267
268 @Test void getParameterAnnotations_atIndex() {
269 check("@CA()", c_c2._getParameterAnnotations(0));
270 check("@CA()", c_m2._getParameterAnnotations(0));
271 }
272
273 @Test void hasAnnotation() {
274 assertFalse(c_c1.hasAnnotation(CA.class));
275 assertFalse(c_c2.hasAnnotation(CA.class));
276 assertTrue(c_c3.hasAnnotation(CA.class));
277 assertFalse(c_m1.hasAnnotation(CA.class));
278 assertFalse(c_m2.hasAnnotation(CA.class));
279 assertTrue(c_m3.hasAnnotation(CA.class));
280 }
281
282 @Test void getAnnotation() {
283 check(null, c_c2.getAnnotation(CA.class));
284 check("@CA()", c_c3.getAnnotation(CA.class));
285 check(null, c_m1.getAnnotation(CA.class));
286 check(null, c_m2.getAnnotation(CA.class));
287 check("@CA()", c_m3.getAnnotation(CA.class));
288 }
289
290 @Test void getAnnotation_nullArg() {
291 check(null, c_c3.getAnnotation(null));
292 }
293
294
295
296
297
298 @SuppressWarnings("unused")
299 static class D {
300 public D() throws IOException {}
301 public void m() throws IOException {}
302 }
303 static ClassInfo d = ClassInfo.of(D.class);
304 static ExecutableInfo
305 d_c=d.getPublicConstructor(ConstructorInfo::hasNoParams),
306 d_m=d.getPublicMethod(x -> x.hasName("m"))
307 ;
308
309 @Test void getExceptionTypes() {
310 check("IOException", d_c.getExceptionTypes());
311 check("IOException", d_m.getExceptionTypes());
312 }
313
314 @Test void getExceptionTypes_twice() {
315 check("IOException", d_c.getExceptionTypes());
316 check("IOException", d_c.getExceptionTypes());
317 }
318
319
320
321
322
323 abstract static class E {
324 @Deprecated public void deprecated() {}
325 public void notDeprecated() {}
326 public void hasParams(int foo) {}
327 public void hasStringParam(String foo) {}
328 public void hasNoParams() {}
329 public void isPublic() {}
330 protected void isNotPublic() {}
331 public static void isStatic() {}
332 public void isNotStatic() {}
333 public abstract void isAbstract();
334 public void isNotAbstract() {}
335 }
336 static ClassInfo e = ClassInfo.of(E.class);
337 static ExecutableInfo
338 e_deprecated = e.getPublicMethod(x -> x.hasName("deprecated")),
339 e_notDeprecated = e.getPublicMethod(x -> x.hasName("notDeprecated")),
340 e_hasParams = e.getPublicMethod(x -> x.hasName("hasParams")),
341 e_hasStringParam = e.getPublicMethod(x -> x.hasName("hasStringParam")),
342 e_hasNoParams = e.getPublicMethod(x -> x.hasName("hasNoParams")),
343 e_isPublic = e.getPublicMethod(x -> x.hasName("isPublic")),
344 e_isNotPublic = e.getMethod(x -> x.hasName("isNotPublic")),
345 e_isStatic = e.getPublicMethod(x -> x.hasName("isStatic")),
346 e_isNotStatic = e.getPublicMethod(x -> x.hasName("isNotStatic")),
347 e_isAbstract = e.getPublicMethod(x -> x.hasName("isAbstract")),
348 e_isNotAbstract = e.getPublicMethod(x -> x.hasName("isNotAbstract"))
349 ;
350
351 @Test void isAll() {
352 assertTrue(e_deprecated.isAll(DEPRECATED));
353 assertTrue(e_notDeprecated.isAll(NOT_DEPRECATED));
354 assertTrue(e_hasParams.isAll(HAS_PARAMS));
355 assertTrue(e_hasNoParams.isAll(HAS_NO_PARAMS));
356 assertTrue(e_isPublic.isAll(PUBLIC));
357 assertTrue(e_isNotPublic.isAll(NOT_PUBLIC));
358 assertTrue(e_isStatic.isAll(STATIC));
359 assertTrue(e_isNotStatic.isAll(NOT_STATIC));
360 assertTrue(e_isAbstract.isAll(ABSTRACT));
361 assertTrue(e_isNotAbstract.isAll(NOT_ABSTRACT));
362
363 assertFalse(e_deprecated.isAll(NOT_DEPRECATED));
364 assertFalse(e_notDeprecated.isAll(DEPRECATED));
365 assertFalse(e_hasParams.isAll(HAS_NO_PARAMS));
366 assertFalse(e_hasNoParams.isAll(HAS_PARAMS));
367 assertFalse(e_isPublic.isAll(NOT_PUBLIC));
368 assertFalse(e_isNotPublic.isAll(PUBLIC));
369 assertFalse(e_isStatic.isAll(NOT_STATIC));
370 assertFalse(e_isNotStatic.isAll(STATIC));
371 assertFalse(e_isAbstract.isAll(NOT_ABSTRACT));
372 assertFalse(e_isNotAbstract.isAll(ABSTRACT));
373 }
374
375 @Test void isAll_invalidFlag() {
376 assertThrowsWithMessage(BasicRuntimeException.class, "Invalid flag for executable: TRANSIENT", ()->e_deprecated.isAll(TRANSIENT));
377 }
378
379 @Test void isAny() {
380 assertTrue(e_deprecated.isAny(DEPRECATED));
381 assertTrue(e_notDeprecated.isAny(NOT_DEPRECATED));
382 assertTrue(e_hasParams.isAny(HAS_PARAMS));
383 assertTrue(e_hasNoParams.isAny(HAS_NO_PARAMS));
384 assertTrue(e_isPublic.isAny(PUBLIC));
385 assertTrue(e_isNotPublic.isAny(NOT_PUBLIC));
386 assertTrue(e_isStatic.isAny(STATIC));
387 assertTrue(e_isNotStatic.isAny(NOT_STATIC));
388 assertTrue(e_isAbstract.isAny(ABSTRACT));
389 assertTrue(e_isNotAbstract.isAny(NOT_ABSTRACT));
390
391 assertFalse(e_deprecated.isAny(NOT_DEPRECATED));
392 assertFalse(e_notDeprecated.isAny(DEPRECATED));
393 assertFalse(e_hasParams.isAny(HAS_NO_PARAMS));
394 assertFalse(e_hasNoParams.isAny(HAS_PARAMS));
395 assertFalse(e_isPublic.isAny(NOT_PUBLIC));
396 assertFalse(e_isNotPublic.isAny(PUBLIC));
397 assertFalse(e_isStatic.isAny(NOT_STATIC));
398 assertFalse(e_isNotStatic.isAny(STATIC));
399 assertFalse(e_isAbstract.isAny(NOT_ABSTRACT));
400 assertFalse(e_isNotAbstract.isAny(ABSTRACT));
401 }
402
403 @Test void isAny_invalidFlag() {
404 assertThrowsWithMessage(BasicRuntimeException.class, "Invalid flag for executable: TRANSIENT", ()->e_deprecated.isAny(TRANSIENT));
405 }
406
407 @Test void hasArgs() {
408 assertTrue(e_hasParams.hasParamTypes(int.class));
409 assertFalse(e_hasParams.hasParamTypes(new Class[0]));
410 assertFalse(e_hasParams.hasParamTypes(long.class));
411 assertTrue(e_hasNoParams.hasParamTypes(new Class[0]));
412 assertFalse(e_hasNoParams.hasParamTypes(long.class));
413 }
414
415 @Test void hasArgParents() {
416 assertTrue(e_hasStringParam.hasMatchingParamTypes(String.class));
417 assertFalse(e_hasStringParam.hasMatchingParamTypes(CharSequence.class));
418 assertFalse(e_hasStringParam.hasMatchingParamTypes(StringBuilder.class));
419 assertFalse(e_hasStringParam.hasMatchingParamTypes(new Class[0]));
420 assertFalse(e_hasStringParam.hasMatchingParamTypes(String.class, String.class));
421 assertFalse(e_hasStringParam.hasMatchingParamTypes(long.class));
422 }
423
424 @Test void hasFuzzyArgs() {
425 assertTrue(e_hasParams.hasFuzzyParamTypes(int.class));
426 assertTrue(e_hasParams.hasFuzzyParamTypes(int.class, long.class));
427 assertFalse(e_hasParams.hasFuzzyParamTypes(long.class));
428 assertTrue(e_hasNoParams.hasFuzzyParamTypes(new Class[0]));
429 assertTrue(e_hasNoParams.hasFuzzyParamTypes(long.class));
430 }
431
432 @Test void isDeprecated() {
433 assertTrue(e_deprecated.isDeprecated());
434 assertFalse(e_notDeprecated.isDeprecated());
435 }
436
437 @Test void isNotDeprecated() {
438 assertFalse(e_deprecated.isNotDeprecated());
439 assertTrue(e_notDeprecated.isNotDeprecated());
440 }
441
442 @Test void isAbstract() {
443 assertTrue(e_isAbstract.isAbstract());
444 assertFalse(e_isNotAbstract.isAbstract());
445 }
446
447 @Test void isNotAbstract() {
448 assertFalse(e_isAbstract.isNotAbstract());
449 assertTrue(e_isNotAbstract.isNotAbstract());
450 }
451
452 @Test void isPublic() {
453 assertTrue(e_isPublic.isPublic());
454 assertFalse(e_isNotPublic.isPublic());
455 }
456
457 @Test void isNotPublic() {
458 assertFalse(e_isPublic.isNotPublic());
459 assertTrue(e_isNotPublic.isNotPublic());
460 }
461
462 @Test void isStatic() {
463 assertTrue(e_isStatic.isStatic());
464 assertFalse(e_isNotStatic.isStatic());
465 }
466
467 @Test void isNotStatic() {
468 assertFalse(e_isStatic.isNotStatic());
469 assertTrue(e_isNotStatic.isNotStatic());
470 }
471
472
473
474
475
476 abstract static class F {
477 public void isPublic() {}
478 protected void isProtected() {}
479 @SuppressWarnings("unused")
480 private void isPrivate() {}
481 void isDefault() {}
482 }
483 static ClassInfo f = ClassInfo.of(F.class);
484 static ExecutableInfo
485 f_isPublic = f.getPublicMethod(x -> x.hasName("isPublic")),
486 f_isProtected = f.getMethod(x -> x.hasName("isProtected")),
487 f_isPrivate = f.getMethod(x -> x.hasName("isPrivate")),
488 f_isDefault = f.getMethod(x -> x.hasName("isDefault"));
489
490 @Test void setAccessible() {
491 assertDoesNotThrow(()->f_isPublic.accessible());
492 assertDoesNotThrow(()->f_isProtected.accessible());
493 assertDoesNotThrow(()->f_isPrivate.accessible());
494 assertDoesNotThrow(()->f_isDefault.accessible());
495 }
496
497 @Test void isVisible() {
498 assertTrue(f_isPublic.isVisible(Visibility.PUBLIC));
499 assertTrue(f_isPublic.isVisible(Visibility.PROTECTED));
500 assertTrue(f_isPublic.isVisible(Visibility.PRIVATE));
501 assertTrue(f_isPublic.isVisible(Visibility.DEFAULT));
502
503 assertFalse(f_isProtected.isVisible(Visibility.PUBLIC));
504 assertTrue(f_isProtected.isVisible(Visibility.PROTECTED));
505 assertTrue(f_isProtected.isVisible(Visibility.PRIVATE));
506 assertTrue(f_isProtected.isVisible(Visibility.DEFAULT));
507
508 assertFalse(f_isPrivate.isVisible(Visibility.PUBLIC));
509 assertFalse(f_isPrivate.isVisible(Visibility.PROTECTED));
510 assertTrue(f_isPrivate.isVisible(Visibility.PRIVATE));
511 assertFalse(f_isPrivate.isVisible(Visibility.DEFAULT));
512
513 assertFalse(f_isDefault.isVisible(Visibility.PUBLIC));
514 assertFalse(f_isDefault.isVisible(Visibility.PROTECTED));
515 assertTrue(f_isDefault.isVisible(Visibility.PRIVATE));
516 assertTrue(f_isDefault.isVisible(Visibility.DEFAULT));
517 }
518
519
520
521
522
523 static class X {
524 public X() {}
525 public X(String foo) {}
526 public X(Map<String,Object> foo) {}
527 public void foo(){}
528 public void foo(String foo){}
529 public void foo(Map<String,Object> foo){}
530 }
531 static ClassInfo x2 = ClassInfo.of(X.class);
532
533 @Test void getFullName_method() {
534 assertEquals("org.apache.juneau.reflect.ExecutableInfo_Test$X.foo()", x2.getPublicMethod(x -> x.hasName("foo") && x.hasNoParams()).getFullName());
535 assertEquals("org.apache.juneau.reflect.ExecutableInfo_Test$X.foo(java.lang.String)", x2.getPublicMethod(x -> x.hasName("foo") && x.hasParamTypes(String.class)).getFullName());
536 assertEquals("org.apache.juneau.reflect.ExecutableInfo_Test$X.foo(java.util.Map<java.lang.String,java.lang.Object>)", x2.getPublicMethod(x -> x.hasName("foo") && x.hasParamTypes(Map.class)).getFullName());
537 }
538
539 @Test void getFullName_constructor() {
540 assertEquals("org.apache.juneau.reflect.ExecutableInfo_Test$X()", x2.getPublicConstructor(ConstructorInfo::hasNoParams).getFullName());
541 assertEquals("org.apache.juneau.reflect.ExecutableInfo_Test$X(java.lang.String)", x2.getPublicConstructor(x -> x.hasParamTypes(String.class)).getFullName());
542 assertEquals("org.apache.juneau.reflect.ExecutableInfo_Test$X(java.util.Map<java.lang.String,java.lang.Object>)", x2.getPublicConstructor(x -> x.hasParamTypes(Map.class)).getFullName());
543 }
544
545 @Test void getShortName_method() {
546 assertEquals("foo()", x2.getPublicMethod(x -> x.hasName("foo") && x.hasNoParams()).getShortName());
547 assertEquals("foo(String)", x2.getPublicMethod(x -> x.hasName("foo") && x.hasParamTypes(String.class)).getShortName());
548 assertEquals("foo(Map)", x2.getPublicMethod(x -> x.hasName("foo") && x.hasParamTypes(Map.class)).getShortName());
549 }
550
551 @Test void getShortName_constructor() {
552 assertEquals("X()", x2.getPublicConstructor(ConstructorInfo::hasNoParams).getShortName());
553 assertEquals("X(String)", x2.getPublicConstructor(x -> x.hasParamTypes(String.class)).getShortName());
554 assertEquals("X(Map)", x2.getPublicConstructor(x -> x.hasParamTypes(Map.class)).getShortName());
555 }
556
557 @Test void getSimpleName_method() {
558 assertEquals("foo", x2.getPublicMethod(x -> x.hasName("foo") && x.hasNoParams()).getSimpleName());
559 assertEquals("foo", x2.getPublicMethod(x -> x.hasName("foo") && x.hasParamTypes(String.class)).getSimpleName());
560 assertEquals("foo", x2.getPublicMethod(x -> x.hasName("foo") && x.hasParamTypes(Map.class)).getSimpleName());
561 }
562
563 @Test void getSimpleName_constructor() {
564 assertEquals("X", x2.getPublicConstructor(ConstructorInfo::hasNoParams).getSimpleName());
565 assertEquals("X", x2.getPublicConstructor(x -> x.hasParamTypes(String.class)).getSimpleName());
566 assertEquals("X", x2.getPublicConstructor(x -> x.hasParamTypes(Map.class)).getSimpleName());
567 }
568 }