Browse Source

Polish

pull/31867/head
Stéphane Nicoll 2 years ago
parent
commit
212346a86d
  1. 16
      spring-core-test/src/test/java/org/springframework/aot/agent/InstrumentedMethodTests.java

16
spring-core-test/src/test/java/org/springframework/aot/agent/InstrumentedMethodTests.java

@ -40,16 +40,16 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
class InstrumentedMethodTests { class InstrumentedMethodTests {
private RuntimeHints hints = new RuntimeHints(); private final RuntimeHints hints = new RuntimeHints();
@Nested @Nested
class ClassReflectionInstrumentationTests { class ClassReflectionInstrumentationTests {
RecordedInvocation stringGetClasses = RecordedInvocation.of(InstrumentedMethod.CLASS_GETCLASSES) final RecordedInvocation stringGetClasses = RecordedInvocation.of(InstrumentedMethod.CLASS_GETCLASSES)
.onInstance(String.class).returnValue(String.class.getClasses()).build(); .onInstance(String.class).returnValue(String.class.getClasses()).build();
RecordedInvocation stringGetDeclaredClasses = RecordedInvocation.of(InstrumentedMethod.CLASS_GETDECLAREDCLASSES) final RecordedInvocation stringGetDeclaredClasses = RecordedInvocation.of(InstrumentedMethod.CLASS_GETDECLAREDCLASSES)
.onInstance(String.class).returnValue(String.class.getDeclaredClasses()).build(); .onInstance(String.class).returnValue(String.class.getDeclaredClasses()).build();
@Test @Test
@ -106,12 +106,12 @@ class InstrumentedMethodTests {
RecordedInvocation stringGetConstructor; RecordedInvocation stringGetConstructor;
RecordedInvocation stringGetConstructors = RecordedInvocation.of(InstrumentedMethod.CLASS_GETCONSTRUCTORS) final RecordedInvocation stringGetConstructors = RecordedInvocation.of(InstrumentedMethod.CLASS_GETCONSTRUCTORS)
.onInstance(String.class).returnValue(String.class.getConstructors()).build(); .onInstance(String.class).returnValue(String.class.getConstructors()).build();
RecordedInvocation stringGetDeclaredConstructor; RecordedInvocation stringGetDeclaredConstructor;
RecordedInvocation stringGetDeclaredConstructors = RecordedInvocation.of(InstrumentedMethod.CLASS_GETDECLAREDCONSTRUCTORS) final RecordedInvocation stringGetDeclaredConstructors = RecordedInvocation.of(InstrumentedMethod.CLASS_GETDECLAREDCONSTRUCTORS)
.onInstance(String.class).returnValue(String.class.getDeclaredConstructors()).build(); .onInstance(String.class).returnValue(String.class.getDeclaredConstructors()).build();
@BeforeEach @BeforeEach
@ -434,7 +434,7 @@ class InstrumentedMethodTests {
} }
@Test @Test
void classGetMethodShouldNotMatchInstrospectPublicMethodsHintWhenPrivate() throws Exception { void classGetMethodShouldNotMatchInstrospectPublicMethodsHintWhenPrivate() {
hints.reflection().registerType(String.class, MemberCategory.INTROSPECT_PUBLIC_METHODS); hints.reflection().registerType(String.class, MemberCategory.INTROSPECT_PUBLIC_METHODS);
assertThatInvocationDoesNotMatch(InstrumentedMethod.CLASS_GETMETHOD, this.stringGetScaleMethod); assertThatInvocationDoesNotMatch(InstrumentedMethod.CLASS_GETMETHOD, this.stringGetScaleMethod);
} }
@ -556,7 +556,7 @@ class InstrumentedMethodTests {
} }
@Test @Test
void classGetFieldShouldNotMatchPublicFieldsHintWhenPrivate() throws NoSuchFieldException { void classGetFieldShouldNotMatchPublicFieldsHintWhenPrivate() {
RecordedInvocation invocation = RecordedInvocation.of(InstrumentedMethod.CLASS_GETFIELD) RecordedInvocation invocation = RecordedInvocation.of(InstrumentedMethod.CLASS_GETFIELD)
.onInstance(String.class).withArgument("value").returnValue(null).build(); .onInstance(String.class).withArgument("value").returnValue(null).build();
hints.reflection().registerType(String.class, MemberCategory.PUBLIC_FIELDS); hints.reflection().registerType(String.class, MemberCategory.PUBLIC_FIELDS);
@ -572,7 +572,7 @@ class InstrumentedMethodTests {
} }
@Test @Test
void classGetFieldShouldNotMatchForWrongType() throws Exception { void classGetFieldShouldNotMatchForWrongType() {
RecordedInvocation invocation = RecordedInvocation.of(InstrumentedMethod.CLASS_GETFIELD) RecordedInvocation invocation = RecordedInvocation.of(InstrumentedMethod.CLASS_GETFIELD)
.onInstance(String.class).withArgument("value").returnValue(null).build(); .onInstance(String.class).withArgument("value").returnValue(null).build();
hints.reflection().registerType(Integer.class, MemberCategory.DECLARED_FIELDS); hints.reflection().registerType(Integer.class, MemberCategory.DECLARED_FIELDS);

Loading…
Cancel
Save