Use TypeReference consistently in hints writer

Closes gh-28606
This commit is contained in:
Stephane Nicoll
2022-06-10 15:27:21 +02:00
parent 405e5921a6
commit 100ce9642a
4 changed files with 56 additions and 12 deletions

View File

@@ -63,6 +63,16 @@ public class ProxyHintsWriterTests {
]""", hints);
}
@Test
void shouldWriteInnerClass() throws JSONException {
ProxyHints hints = new ProxyHints();
hints.registerJdkProxy(Inner.class);
assertEquals("""
[
{ "interfaces": [ "org.springframework.aot.nativex.ProxyHintsWriterTests$Inner" ] }
]""", hints);
}
@Test
void shouldWriteCondition() throws JSONException {
ProxyHints hints = new ProxyHints();
@@ -81,4 +91,8 @@ public class ProxyHintsWriterTests {
JSONAssert.assertEquals(expectedString, out.toString(), JSONCompareMode.NON_EXTENSIBLE);
}
interface Inner {
}
}

View File

@@ -158,6 +158,27 @@ public class ReflectionHintsWriterTests {
""", hints);
}
@Test
void methodWithInnerClassParameter() throws JSONException {
ReflectionHints hints = new ReflectionHints();
hints.registerType(Integer.class, builder -> builder.withMethod("test", List.of(TypeReference.of(Inner.class)),
b -> b.withMode(ExecutableMode.INVOKE)));
assertEquals("""
[
{
"name": "java.lang.Integer",
"methods": [
{
"name": "test",
"parameterTypes": ["org.springframework.aot.nativex.ReflectionHintsWriterTests$Inner"]
}
]
}
]
""", hints);
}
@Test
void methodAndQueriedMethods() throws JSONException {
ReflectionHints hints = new ReflectionHints();
@@ -194,4 +215,9 @@ public class ReflectionHintsWriterTests {
JSONAssert.assertEquals(expectedString, out.toString(), JSONCompareMode.NON_EXTENSIBLE);
}
static class Inner {
}
}