Polishing

This commit is contained in:
Sam Brannen
2026-03-25 12:12:29 +01:00
parent 0f4ee906de
commit bcc9e27dd0
2 changed files with 14 additions and 13 deletions
@@ -45,8 +45,8 @@ class ParameterResolutionTests {
@Test @Test
void isAutowirablePreconditions() { void isAutowirablePreconditions() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException()
ParameterResolutionDelegate.isAutowirable(null, 0)) .isThrownBy(() -> ParameterResolutionDelegate.isAutowirable(null, 0))
.withMessageContaining("Parameter must not be null"); .withMessageContaining("Parameter must not be null");
} }
@@ -87,7 +87,8 @@ class ParameterResolutionTests {
Parameter[] parameters = notAutowirableConstructor.getParameters(); Parameter[] parameters = notAutowirableConstructor.getParameters();
for (int parameterIndex = 0; parameterIndex < parameters.length; parameterIndex++) { for (int parameterIndex = 0; parameterIndex < parameters.length; parameterIndex++) {
Parameter parameter = parameters[parameterIndex]; Parameter parameter = parameters[parameterIndex];
assertThat(ParameterResolutionDelegate.isAutowirable(parameter, parameterIndex)).as("Parameter " + parameter + " must not be autowirable").isFalse(); assertThat(ParameterResolutionDelegate.isAutowirable(parameter, parameterIndex))
.as("Parameter " + parameter + " must not be autowirable").isFalse();
} }
} }
@@ -100,15 +101,15 @@ class ParameterResolutionTests {
@Test @Test
void resolveDependencyPreconditionsForContainingClass() { void resolveDependencyPreconditionsForContainingClass() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException()
ParameterResolutionDelegate.resolveDependency(getParameter(), 0, null, null)) .isThrownBy(() -> ParameterResolutionDelegate.resolveDependency(getParameter(), 0, null, null))
.withMessageContaining("Containing class must not be null"); .withMessageContaining("Containing class must not be null");
} }
@Test @Test
void resolveDependencyPreconditionsForBeanFactory() { void resolveDependencyPreconditionsForBeanFactory() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException()
ParameterResolutionDelegate.resolveDependency(getParameter(), 0, getClass(), null)) .isThrownBy(() -> ParameterResolutionDelegate.resolveDependency(getParameter(), 0, getClass(), null))
.withMessageContaining("AutowireCapableBeanFactory must not be null"); .withMessageContaining("AutowireCapableBeanFactory must not be null");
} }
@@ -400,7 +400,7 @@ public class SpringExtension implements BeforeAllCallback, AfterAllCallback, Tes
ParameterResolutionDelegate.isAutowirable(parameter, parameterContext.getIndex())); ParameterResolutionDelegate.isAutowirable(parameter, parameterContext.getIndex()));
} }
private boolean supportsApplicationEvents(Class<?> parameterType, Executable executable) { private static boolean supportsApplicationEvents(Class<?> parameterType, Executable executable) {
if (ApplicationEvents.class.isAssignableFrom(parameterType)) { if (ApplicationEvents.class.isAssignableFrom(parameterType)) {
Assert.isTrue(executable instanceof Method, Assert.isTrue(executable instanceof Method,
"ApplicationEvents can only be injected into test and lifecycle methods"); "ApplicationEvents can only be injected into test and lifecycle methods");