@Test public void reflector_shouldHonorWithTypeAnnotationForParams() throws Exception { assertThat(reflector.anotherMethod("a", "b")).isEqualTo("a-b-c (anotherMethod)"); }
@Test public void reflector_defaultMethodsShouldWork() throws Exception { assertThat(reflector.defaultMethod("someMethod", "a", "b")).isEqualTo("a-b-c (someMethod)"); assertThat(reflector.defaultMethod("anotherMethod", "a", "b")) .isEqualTo("a-b-c (anotherMethod)"); }
private String methodBySavedReflector(_SomeClass_ reflector) { return reflector.someMethod("a", "b"); }
private String methodByReflector(SomeClass o) { _SomeClass_ accessor = reflector(_SomeClass_.class, o); return accessor.someMethod("a", "b"); }
@Test public void reflector_shouldCallPrivateMethod() throws Exception { assertThat(reflector.someMethod("a", "b")).isEqualTo("a-b-c (someMethod)"); }
@Test public void reflector_shouldUnboxReturnValues() throws Exception { assertThat(reflector.returnLong()).isEqualTo(1234L); }
@Test public void reflector_staticFieldAccessors() throws Exception { assertThat(reflector.getEStatic()).isEqualTo(null); reflector.setEStatic("eee!"); assertThat(reflector.getEStatic()).isEqualTo("eee!"); }
default String defaultMethod(String which, String a, String b) { switch (which) { case "someMethod": return someMethod(a, b); case "anotherMethod": return anotherMethod(a, b); default: throw new IllegalStateException(which); } }