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,9 +45,9 @@ class ParameterResolutionTests {
@Test
void isAutowirablePreconditions() {
assertThatIllegalArgumentException().isThrownBy(() ->
ParameterResolutionDelegate.isAutowirable(null, 0))
.withMessageContaining("Parameter must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ParameterResolutionDelegate.isAutowirable(null, 0))
.withMessageContaining("Parameter must not be null");
}
@Test
@@ -87,29 +87,30 @@ class ParameterResolutionTests {
Parameter[] parameters = notAutowirableConstructor.getParameters();
for (int parameterIndex = 0; parameterIndex < parameters.length; 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();
}
}
@Test
void resolveDependencyPreconditionsForParameter() {
assertThatIllegalArgumentException()
.isThrownBy(() -> ParameterResolutionDelegate.resolveDependency(null, 0, null, mock()))
.withMessageContaining("Parameter must not be null");
.isThrownBy(() -> ParameterResolutionDelegate.resolveDependency(null, 0, null, mock()))
.withMessageContaining("Parameter must not be null");
}
@Test
void resolveDependencyPreconditionsForContainingClass() {
assertThatIllegalArgumentException().isThrownBy(() ->
ParameterResolutionDelegate.resolveDependency(getParameter(), 0, null, null))
.withMessageContaining("Containing class must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ParameterResolutionDelegate.resolveDependency(getParameter(), 0, null, null))
.withMessageContaining("Containing class must not be null");
}
@Test
void resolveDependencyPreconditionsForBeanFactory() {
assertThatIllegalArgumentException().isThrownBy(() ->
ParameterResolutionDelegate.resolveDependency(getParameter(), 0, getClass(), null))
.withMessageContaining("AutowireCapableBeanFactory must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ParameterResolutionDelegate.resolveDependency(getParameter(), 0, getClass(), null))
.withMessageContaining("AutowireCapableBeanFactory must not be null");
}
private Parameter getParameter() throws NoSuchMethodException {
@@ -400,7 +400,7 @@ public class SpringExtension implements BeforeAllCallback, AfterAllCallback, Tes
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)) {
Assert.isTrue(executable instanceof Method,
"ApplicationEvents can only be injected into test and lifecycle methods");