From 0f4205adbfda38784ae8d5a4f441ee60433ca09f Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 21 Jun 2022 07:57:11 +0200 Subject: [PATCH] Polish assertions --- .../beans/factory/aot/AotFactoriesLoader.java | 6 ++--- .../beans/factory/aot/AutowiredArguments.java | 2 +- .../aot/AutowiredArgumentsCodeGenerator.java | 4 ++-- .../aot/AutowiredFieldValueResolver.java | 12 +++++----- ...towiredInstantiationArgumentsResolver.java | 22 +++++++++---------- .../aot/AutowiredMethodArgumentsResolver.java | 12 +++++----- .../aot/BeanRegistrationCodeFragments.java | 2 +- .../aot/BeanRegistrationCodeGenerator.java | 2 +- .../beans/factory/support/RegisteredBean.java | 10 ++++----- .../factory/aot/AotFactoriesLoaderTests.java | 4 ++-- .../aot/AutowiredFieldValueResolverTests.java | 8 +++---- ...edInstantiationArgumentsResolverTests.java | 16 +++++++------- ...AutowiredMethodArgumentsResolverTests.java | 8 +++---- .../factory/support/RegisteredBeanTests.java | 10 ++++----- .../aot/hint/SimpleTypeReference.java | 2 +- .../springframework/aot/hint/TypeHint.java | 2 +- 16 files changed, 61 insertions(+), 61 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java index a3d39aa4db8..1b241d6eee1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java @@ -58,7 +58,7 @@ public class AotFactoriesLoader { * @param beanFactory the bean factory to use */ public AotFactoriesLoader(ListableBeanFactory beanFactory) { - Assert.notNull(beanFactory, "BeanFactory must not be null"); + Assert.notNull(beanFactory, "'beanFactory' must not be null"); ClassLoader classLoader = (beanFactory instanceof ConfigurableBeanFactory configurableBeanFactory) ? configurableBeanFactory.getBeanClassLoader() : null; this.beanFactory = beanFactory; @@ -76,8 +76,8 @@ public class AotFactoriesLoader { public AotFactoriesLoader(ListableBeanFactory beanFactory, SpringFactoriesLoader factoriesLoader) { - Assert.notNull(beanFactory, "BeanFactory must not be null"); - Assert.notNull(factoriesLoader, "FactoriesLoader must not be null"); + Assert.notNull(beanFactory, "'beanFactory' must not be null"); + Assert.notNull(factoriesLoader, "'factoriesLoader' must not be null"); this.beanFactory = beanFactory; this.factoriesLoader = factoriesLoader; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredArguments.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredArguments.java index 0ad070dc06b..d07af723967 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredArguments.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredArguments.java @@ -80,7 +80,7 @@ public interface AutowiredArguments { * @return a new {@link AutowiredArguments} instance */ static AutowiredArguments of(Object[] arguments) { - Assert.notNull(arguments, "Arguments must not be null"); + Assert.notNull(arguments, "'arguments' must not be null"); return () -> arguments; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredArgumentsCodeGenerator.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredArgumentsCodeGenerator.java index 49a8c86c13c..970d10a6161 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredArgumentsCodeGenerator.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredArgumentsCodeGenerator.java @@ -66,8 +66,8 @@ public class AutowiredArgumentsCodeGenerator { public CodeBlock generateCode(Class[] parameterTypes, int startIndex, String variableName) { - Assert.notNull(parameterTypes, "ParameterTypes must not be null"); - Assert.notNull(variableName, "VariableName must not be null"); + Assert.notNull(parameterTypes, "'parameterTypes' must not be null"); + Assert.notNull(variableName, "'variableName' must not be null"); boolean ambiguous = isAmbiguous(); CodeBlock.Builder builder = CodeBlock.builder(); for (int i = startIndex; i < parameterTypes.length; i++) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredFieldValueResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredFieldValueResolver.java index ed10d48d559..cd329aa9f13 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredFieldValueResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredFieldValueResolver.java @@ -64,7 +64,7 @@ public final class AutowiredFieldValueResolver extends AutowiredElementResolver private AutowiredFieldValueResolver(String fieldName, boolean required, @Nullable String shortcut) { - Assert.hasText(fieldName, "FieldName must not be empty"); + Assert.hasText(fieldName, "'fieldName' must not be empty"); this.fieldName = fieldName; this.required = required; this.shortcut = shortcut; @@ -110,8 +110,8 @@ public final class AutowiredFieldValueResolver extends AutowiredElementResolver * @param action the action to execute with the resolved field value */ public void resolve(RegisteredBean registeredBean, ThrowingConsumer action) { - Assert.notNull(registeredBean, "RegisteredBean must not be null"); - Assert.notNull(action, "Action must not be null"); + Assert.notNull(registeredBean, "'registeredBean' must not be null"); + Assert.notNull(action, "'action' must not be null"); T resolved = resolve(registeredBean); if (resolved != null) { action.accept(resolved); @@ -150,7 +150,7 @@ public final class AutowiredFieldValueResolver extends AutowiredElementResolver */ @Nullable public Object resolveObject(RegisteredBean registeredBean) { - Assert.notNull(registeredBean, "RegisteredBean must not be null"); + Assert.notNull(registeredBean, "'registeredBean' must not be null"); return resolveValue(registeredBean, getField(registeredBean)); } @@ -161,8 +161,8 @@ public final class AutowiredFieldValueResolver extends AutowiredElementResolver * @param instance the bean instance */ public void resolveAndSet(RegisteredBean registeredBean, Object instance) { - Assert.notNull(registeredBean, "RegisteredBean must not be null"); - Assert.notNull(instance, "Instance must not be null"); + Assert.notNull(registeredBean, "'registeredBean' must not be null"); + Assert.notNull(instance, "'instance' must not be null"); Field field = getField(registeredBean); Object resolved = resolveValue(registeredBean, field); if (resolved != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredInstantiationArgumentsResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredInstantiationArgumentsResolver.java index b67b2376a93..cc8be0706a3 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredInstantiationArgumentsResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredInstantiationArgumentsResolver.java @@ -94,9 +94,9 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem public static AutowiredInstantiationArgumentsResolver forConstructor( Class... parameterTypes) { - Assert.notNull(parameterTypes, "ParameterTypes must not be null"); + Assert.notNull(parameterTypes, "'parameterTypes' must not be null"); Assert.noNullElements(parameterTypes, - "ParameterTypes must not contain null elements"); + "'parameterTypes' must not contain null elements"); return new AutowiredInstantiationArgumentsResolver( new ConstructorLookup(parameterTypes), null); } @@ -112,11 +112,11 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem public static AutowiredInstantiationArgumentsResolver forFactoryMethod( Class declaringClass, String methodName, Class... parameterTypes) { - Assert.notNull(declaringClass, "DeclaringClass must not be null"); - Assert.hasText(methodName, "MethodName must not be empty"); - Assert.notNull(parameterTypes, "ParameterTypes must not be null"); + Assert.notNull(declaringClass, "'declaringClass' must not be null"); + Assert.hasText(methodName, "'methodName' must not be empty"); + Assert.notNull(parameterTypes, "'parameterTypes' must not be null"); Assert.noNullElements(parameterTypes, - "ParameterTypes must not contain null elements"); + "'parameterTypes' must not contain null elements"); return new AutowiredInstantiationArgumentsResolver( new FactoryMethodLookup(declaringClass, methodName, parameterTypes), null); @@ -149,8 +149,8 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem public T resolve(RegisteredBean registeredBean, ThrowingFunction generator) { - Assert.notNull(registeredBean, "RegisteredBean must not be null"); - Assert.notNull(generator, "Action must not be null"); + Assert.notNull(registeredBean, "'registeredBean' must not be null"); + Assert.notNull(generator, "'action' must not be null"); AutowiredArguments resolved = resolveArguments(registeredBean, this.lookup.get(registeredBean)); return generator.apply(resolved); @@ -162,7 +162,7 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem * @return the resolved constructor or factory method arguments */ public AutowiredArguments resolve(RegisteredBean registeredBean) { - Assert.notNull(registeredBean, "RegisteredBean must not be null"); + Assert.notNull(registeredBean, "'registeredBean' must not be null"); return resolveArguments(registeredBean, this.lookup.get(registeredBean)); } @@ -188,8 +188,8 @@ public final class AutowiredInstantiationArgumentsResolver extends AutowiredElem public T resolveAndInstantiate(RegisteredBean registeredBean, Class requiredType) { - Assert.notNull(registeredBean, "RegisteredBean must not be null"); - Assert.notNull(registeredBean, "RequiredType must not be null"); + Assert.notNull(registeredBean, "'registeredBean' must not be null"); + Assert.notNull(registeredBean, "'requiredType' must not be null"); Executable executable = this.lookup.get(registeredBean); AutowiredArguments arguments = resolveArguments(registeredBean, executable); Object instance = instantiate(registeredBean.getBeanFactory(), executable, diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredMethodArgumentsResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredMethodArgumentsResolver.java index 9fce1f6fc0e..681297eb347 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredMethodArgumentsResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AutowiredMethodArgumentsResolver.java @@ -69,7 +69,7 @@ public final class AutowiredMethodArgumentsResolver extends AutowiredElementReso private AutowiredMethodArgumentsResolver(String methodName, Class[] parameterTypes, boolean required, @Nullable String[] shortcuts) { - Assert.hasText(methodName, "MethodName must not be empty"); + Assert.hasText(methodName, "'methodName' must not be empty"); this.methodName = methodName; this.parameterTypes = parameterTypes; this.required = required; @@ -126,8 +126,8 @@ public final class AutowiredMethodArgumentsResolver extends AutowiredElementReso public void resolve(RegisteredBean registeredBean, ThrowingConsumer action) { - Assert.notNull(registeredBean, "RegisteredBean must not be null"); - Assert.notNull(action, "Action must not be null"); + Assert.notNull(registeredBean, "'registeredBean' must not be null"); + Assert.notNull(action, "'action' must not be null"); AutowiredArguments resolved = resolve(registeredBean); if (resolved != null) { action.accept(resolved); @@ -141,7 +141,7 @@ public final class AutowiredMethodArgumentsResolver extends AutowiredElementReso */ @Nullable public AutowiredArguments resolve(RegisteredBean registeredBean) { - Assert.notNull(registeredBean, "RegisteredBean must not be null"); + Assert.notNull(registeredBean, "'registeredBean' must not be null"); return resolveArguments(registeredBean, getMethod(registeredBean)); } @@ -152,8 +152,8 @@ public final class AutowiredMethodArgumentsResolver extends AutowiredElementReso * @param instance the bean instance */ public void resolveAndInvoke(RegisteredBean registeredBean, Object instance) { - Assert.notNull(registeredBean, "RegisteredBean must not be null"); - Assert.notNull(instance, "Instance must not be null"); + Assert.notNull(registeredBean, "'registeredBean' must not be null"); + Assert.notNull(instance, "'instance' must not be null"); Method method = getMethod(registeredBean); AutowiredArguments resolved = resolveArguments(registeredBean, method); if (resolved != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeFragments.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeFragments.java index b252c2949ff..bbfdc0f739f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeFragments.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeFragments.java @@ -53,7 +53,7 @@ public abstract class BeanRegistrationCodeFragments { protected BeanRegistrationCodeFragments(BeanRegistrationCodeFragments codeFragments) { - Assert.notNull(codeFragments, "CodeFragments must not be null"); + Assert.notNull(codeFragments, "'codeFragments' must not be null"); this.codeFragments = codeFragments; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeGenerator.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeGenerator.java index b2d2fb6b028..bd1eb2ba9a7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeGenerator.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanRegistrationCodeGenerator.java @@ -75,7 +75,7 @@ class BeanRegistrationCodeGenerator implements BeanRegistrationCode { @Override public void addInstancePostProcessor(MethodReference methodReference) { - Assert.notNull(methodReference, "MethodReference must not be null"); + Assert.notNull(methodReference, "'methodReference' must not be null"); this.instancePostProcessors.add(methodReference); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/RegisteredBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/RegisteredBean.java index 8a0b8361c9f..1de3defeae6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/RegisteredBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/RegisteredBean.java @@ -74,8 +74,8 @@ public final class RegisteredBean { public static RegisteredBean of(ConfigurableBeanFactory beanFactory, String beanName) { - Assert.notNull(beanFactory, "BeanFactory must not be null"); - Assert.hasLength(beanName, "BeanName must not be empty"); + Assert.notNull(beanFactory, "'beanFactory' must not be null"); + Assert.hasLength(beanName, "'beanName' must not be empty"); return new RegisteredBean(beanFactory, () -> beanName, false, () -> (RootBeanDefinition) beanFactory.getMergedBeanDefinition(beanName), null); @@ -90,7 +90,7 @@ public final class RegisteredBean { public static RegisteredBean ofInnerBean(RegisteredBean parent, BeanDefinitionHolder innerBean) { - Assert.notNull(innerBean, "InnerBean must not be null"); + Assert.notNull(innerBean, "'innerBean' must not be null"); return ofInnerBean(parent, innerBean.getBeanName(), innerBean.getBeanDefinition()); } @@ -118,8 +118,8 @@ public final class RegisteredBean { public static RegisteredBean ofInnerBean(RegisteredBean parent, @Nullable String innerBeanName, BeanDefinition innerBeanDefinition) { - Assert.notNull(parent, "Parent must not be null"); - Assert.notNull(innerBeanDefinition, "InnerBeanDefinition must not be null"); + Assert.notNull(parent, "'parent' must not be null"); + Assert.notNull(innerBeanDefinition, "'innerBeanDefinition' must not be null"); InnerBeanResolver resolver = new InnerBeanResolver(parent, innerBeanName, innerBeanDefinition); Supplier beanName = StringUtils.hasLength(innerBeanName) diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/aot/AotFactoriesLoaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/aot/AotFactoriesLoaderTests.java index 19b1b3c80a0..8d5d7359e33 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/aot/AotFactoriesLoaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/aot/AotFactoriesLoaderTests.java @@ -39,7 +39,7 @@ class AotFactoriesLoaderTests { void createWhenBeanFactoryIsNullThrowsException() { assertThatIllegalArgumentException() .isThrownBy(() -> new AotFactoriesLoader(null)) - .withMessage("BeanFactory must not be null"); + .withMessage("'beanFactory' must not be null"); } @Test @@ -47,7 +47,7 @@ class AotFactoriesLoaderTests { ListableBeanFactory beanFactory = new DefaultListableBeanFactory(); assertThatIllegalArgumentException() .isThrownBy(() -> new AotFactoriesLoader(beanFactory, null)) - .withMessage("FactoriesLoader must not be null"); + .withMessage("'factoriesLoader' must not be null"); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredFieldValueResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredFieldValueResolverTests.java index eb233d38c11..3e05cfadb64 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredFieldValueResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredFieldValueResolverTests.java @@ -45,7 +45,7 @@ class AutowiredFieldValueResolverTests { @Test void forFieldWhenFieldNameIsEmptyThrowsException() { - String message = "FieldName must not be empty"; + String message = "'fieldName' must not be empty"; assertThatIllegalArgumentException() .isThrownBy(() -> AutowiredFieldValueResolver.forField(null)) .withMessage(message); @@ -64,7 +64,7 @@ class AutowiredFieldValueResolverTests { void resolveWhenRegisteredBeanIsNullThrowsException() { assertThatIllegalArgumentException().isThrownBy( () -> AutowiredFieldValueResolver.forField("string").resolve(null)) - .withMessage("RegisteredBean must not be null"); + .withMessage("'registeredBean' must not be null"); } @Test @@ -122,7 +122,7 @@ class AutowiredFieldValueResolverTests { assertThatIllegalArgumentException() .isThrownBy(() -> AutowiredFieldValueResolver.forField("string") .resolveAndSet(registeredBean, null)) - .withMessage("Instance must not be null"); + .withMessage("'instance' must not be null"); } @Test @@ -141,7 +141,7 @@ class AutowiredFieldValueResolverTests { assertThatIllegalArgumentException() .isThrownBy(() -> AutowiredFieldValueResolver.forField("string") .resolve(registeredBean, (ThrowingConsumer) null)) - .withMessage("Action must not be null"); + .withMessage("'action' must not be null"); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredInstantiationArgumentsResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredInstantiationArgumentsResolverTests.java index f606d50304a..eedb7200508 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredInstantiationArgumentsResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredInstantiationArgumentsResolverTests.java @@ -76,7 +76,7 @@ class AutowiredInstantiationArgumentsResolverTests { assertThatIllegalArgumentException() .isThrownBy(() -> AutowiredInstantiationArgumentsResolver .forConstructor((Class[]) null)) - .withMessage("ParameterTypes must not be null"); + .withMessage("'parameterTypes' must not be null"); } @Test @@ -84,7 +84,7 @@ class AutowiredInstantiationArgumentsResolverTests { assertThatIllegalArgumentException() .isThrownBy(() -> AutowiredInstantiationArgumentsResolver .forConstructor(String.class, null)) - .withMessage("ParameterTypes must not contain null elements"); + .withMessage("'parameterTypes' must not contain null elements"); } @Test @@ -104,7 +104,7 @@ class AutowiredInstantiationArgumentsResolverTests { assertThatIllegalArgumentException() .isThrownBy(() -> AutowiredInstantiationArgumentsResolver .forFactoryMethod(null, "test")) - .withMessage("DeclaringClass must not be null"); + .withMessage("'declaringClass' must not be null"); } @Test @@ -112,7 +112,7 @@ class AutowiredInstantiationArgumentsResolverTests { assertThatIllegalArgumentException() .isThrownBy(() -> AutowiredInstantiationArgumentsResolver .forFactoryMethod(SingleArgFactory.class, "")) - .withMessage("MethodName must not be empty"); + .withMessage("'methodName' must not be empty"); } @Test @@ -121,7 +121,7 @@ class AutowiredInstantiationArgumentsResolverTests { .isThrownBy( () -> AutowiredInstantiationArgumentsResolver.forFactoryMethod( SingleArgFactory.class, "single", (Class[]) null)) - .withMessage("ParameterTypes must not be null"); + .withMessage("'parameterTypes' must not be null"); } @Test @@ -130,7 +130,7 @@ class AutowiredInstantiationArgumentsResolverTests { .isThrownBy( () -> AutowiredInstantiationArgumentsResolver.forFactoryMethod( SingleArgFactory.class, "single", String.class, null)) - .withMessage("ParameterTypes must not contain null elements"); + .withMessage("'parameterTypes' must not contain null elements"); } @Test @@ -153,7 +153,7 @@ class AutowiredInstantiationArgumentsResolverTests { RegisteredBean registerBean = source.registerBean(this.beanFactory); assertThatIllegalArgumentException() .isThrownBy(() -> resolver.resolve(registerBean, null)) - .withMessage("Action must not be null"); + .withMessage("'action' must not be null"); } @Test @@ -174,7 +174,7 @@ class AutowiredInstantiationArgumentsResolverTests { AutowiredInstantiationArgumentsResolver resolver = AutowiredInstantiationArgumentsResolver .forConstructor(String.class); assertThatIllegalArgumentException().isThrownBy(() -> resolver.resolve(null)) - .withMessage("RegisteredBean must not be null"); + .withMessage("'registeredBean' must not be null"); } @ParameterizedResolverTest(Sources.SINGLE_ARG) diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredMethodArgumentsResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredMethodArgumentsResolverTests.java index 4ed2bfa26a8..a8413a0ded7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredMethodArgumentsResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/aot/AutowiredMethodArgumentsResolverTests.java @@ -47,7 +47,7 @@ class AutowiredMethodArgumentsResolverTests { @Test void forMethodWhenMethodNameIsEmptyThrowsException() { - String message = "MethodName must not be empty"; + String message = "'methodName' must not be empty"; assertThatIllegalArgumentException() .isThrownBy(() -> AutowiredMethodArgumentsResolver.forMethod(null)) .withMessage(message); @@ -68,7 +68,7 @@ class AutowiredMethodArgumentsResolverTests { assertThatIllegalArgumentException() .isThrownBy(() -> AutowiredMethodArgumentsResolver .forMethod("injectString", String.class).resolve(null)) - .withMessage("RegisteredBean must not be null"); + .withMessage("'registeredBean' must not be null"); } @Test @@ -134,7 +134,7 @@ class AutowiredMethodArgumentsResolverTests { .isThrownBy(() -> AutowiredMethodArgumentsResolver .forMethod("injectString", String.class) .resolveAndInvoke(registeredBean, null)) - .withMessage("Instance must not be null"); + .withMessage("'instance' must not be null"); } @Test @@ -155,7 +155,7 @@ class AutowiredMethodArgumentsResolverTests { .isThrownBy(() -> AutowiredMethodArgumentsResolver .forMethod("injectString", String.class) .resolve(registeredBean, null)) - .withMessage("Action must not be null"); + .withMessage("'action' must not be null"); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/RegisteredBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/RegisteredBeanTests.java index d24552076a0..2939d662e4b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/RegisteredBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/RegisteredBeanTests.java @@ -51,14 +51,14 @@ class RegisteredBeanTests { void ofWhenBeanFactoryIsNullThrowsException() { assertThatIllegalArgumentException() .isThrownBy(() -> RegisteredBean.of(null, "bd")) - .withMessage("BeanFactory must not be null"); + .withMessage("'beanFactory' must not be null"); } @Test void ofWhenBeanNameIsEmptyThrowsException() { assertThatIllegalArgumentException() .isThrownBy(() -> RegisteredBean.of(this.beanFactory, null)) - .withMessage("BeanName must not be empty"); + .withMessage("'beanName' must not be empty"); } @Test @@ -66,7 +66,7 @@ class RegisteredBeanTests { RegisteredBean parent = RegisteredBean.of(this.beanFactory, "bd"); assertThatIllegalArgumentException().isThrownBy( () -> RegisteredBean.ofInnerBean(parent, (BeanDefinitionHolder) null)) - .withMessage("InnerBean must not be null"); + .withMessage("'innerBean' must not be null"); } @Test @@ -74,7 +74,7 @@ class RegisteredBeanTests { assertThatIllegalArgumentException() .isThrownBy(() -> RegisteredBean.ofInnerBean(null, new RootBeanDefinition(TestInnerBean.class))) - .withMessage("Parent must not be null"); + .withMessage("'parent' must not be null"); } @Test @@ -82,7 +82,7 @@ class RegisteredBeanTests { RegisteredBean parent = RegisteredBean.of(this.beanFactory, "bd"); assertThatIllegalArgumentException() .isThrownBy(() -> RegisteredBean.ofInnerBean(parent, "ib", null)) - .withMessage("InnerBeanDefinition must not be null"); + .withMessage("'innerBeanDefinition' must not be null"); } @Test diff --git a/spring-core/src/main/java/org/springframework/aot/hint/SimpleTypeReference.java b/spring-core/src/main/java/org/springframework/aot/hint/SimpleTypeReference.java index e20aaff41ca..024471f90d3 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/SimpleTypeReference.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/SimpleTypeReference.java @@ -42,7 +42,7 @@ final class SimpleTypeReference extends AbstractTypeReference { } static SimpleTypeReference of(String className) { - Assert.notNull(className, "ClassName must not be null"); + Assert.notNull(className, "'className' must not be null"); if (!isValidClassName(className)) { throw new IllegalStateException("Invalid class name '" + className + "'"); } diff --git a/spring-core/src/main/java/org/springframework/aot/hint/TypeHint.java b/spring-core/src/main/java/org/springframework/aot/hint/TypeHint.java index 81fa6d3f4be..519eba94a68 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/TypeHint.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/TypeHint.java @@ -69,7 +69,7 @@ public final class TypeHint implements ConditionalHint { * @return a builder */ public static Builder of(TypeReference type) { - Assert.notNull(type, "Type must not be null"); + Assert.notNull(type, "'type' must not be null"); return new Builder(type); }