Use consistent exception messages in Assert calls
Update `Assert` calls to consistently use messages of the form "'item' must [not] ...". Closes gh-43780
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,7 +49,7 @@ public class FilterAnnotations implements Iterable<TypeFilter> {
|
||||
private final List<TypeFilter> filters;
|
||||
|
||||
public FilterAnnotations(ClassLoader classLoader, Filter[] filters) {
|
||||
Assert.notNull(filters, "Filters must not be null");
|
||||
Assert.notNull(filters, "'filters' must not be null");
|
||||
this.classLoader = classLoader;
|
||||
this.filters = createTypeFilters(filters);
|
||||
}
|
||||
@@ -72,16 +72,16 @@ public class FilterAnnotations implements Iterable<TypeFilter> {
|
||||
return switch (filterType) {
|
||||
case ANNOTATION -> {
|
||||
Assert.isAssignable(Annotation.class, filterClass,
|
||||
"An error occurred while processing an ANNOTATION type filter: ");
|
||||
"'filterClass' must be an Annotation when 'filterType' is ANNOTATION");
|
||||
yield new AnnotationTypeFilter((Class<Annotation>) filterClass);
|
||||
}
|
||||
case ASSIGNABLE_TYPE -> new AssignableTypeFilter(filterClass);
|
||||
case CUSTOM -> {
|
||||
Assert.isAssignable(TypeFilter.class, filterClass,
|
||||
"An error occurred while processing a CUSTOM type filter: ");
|
||||
"'filterClass' must be a TypeFilter when 'filterType' is CUSTOM");
|
||||
yield BeanUtils.instantiateClass(filterClass, TypeFilter.class);
|
||||
}
|
||||
default -> throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
|
||||
default -> throw new IllegalArgumentException("'filterClass' not supported [" + filterType + "]");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -126,8 +126,8 @@ public class TestDatabaseAutoConfiguration {
|
||||
if (AotDetector.useGeneratedArtifacts()) {
|
||||
return;
|
||||
}
|
||||
Assert.isInstanceOf(ConfigurableListableBeanFactory.class, registry,
|
||||
"Test Database Auto-configuration can only be used with a ConfigurableListableBeanFactory");
|
||||
Assert.isTrue(registry instanceof ConfigurableListableBeanFactory,
|
||||
"'registry' must be a ConfigurableListableBeanFactory");
|
||||
process(registry, (ConfigurableListableBeanFactory) registry);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,7 @@ public class TestEntityManager {
|
||||
* @param entityManagerFactory the source entity manager factory
|
||||
*/
|
||||
public TestEntityManager(EntityManagerFactory entityManagerFactory) {
|
||||
Assert.notNull(entityManagerFactory, "EntityManagerFactory must not be null");
|
||||
Assert.notNull(entityManagerFactory, "'entityManagerFactory' must not be null");
|
||||
this.entityManagerFactory = entityManagerFactory;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,7 +70,7 @@ public class SpringBootMockMvcBuilderCustomizer implements MockMvcBuilderCustomi
|
||||
* @param context the source application context
|
||||
*/
|
||||
public SpringBootMockMvcBuilderCustomizer(WebApplicationContext context) {
|
||||
Assert.notNull(context, "Context must not be null");
|
||||
Assert.notNull(context, "'context' must not be null");
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,7 +61,7 @@ class TestEntityManagerTests {
|
||||
@Test
|
||||
void createWhenEntityManagerIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new TestEntityManager(null))
|
||||
.withMessageContaining("EntityManagerFactory must not be null");
|
||||
.withMessageContaining("'entityManagerFactory' must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user