Reduce surface area of public API for AnnotationDescriptor types
This commit is contained in:
parent
946e5c9bbf
commit
1c82ba425b
|
@ -193,6 +193,7 @@ public abstract class TestContextAnnotationUtils {
|
|||
public static <T extends Annotation> AnnotationDescriptor<T> findAnnotationDescriptor(
|
||||
Class<?> clazz, Class<T> annotationType) {
|
||||
|
||||
Assert.notNull(annotationType, "Annotation type must not be null");
|
||||
return findAnnotationDescriptor(clazz, annotationType, TestContextAnnotationUtils::searchEnclosingClass,
|
||||
new HashSet<>());
|
||||
}
|
||||
|
@ -214,7 +215,6 @@ public abstract class TestContextAnnotationUtils {
|
|||
@Nullable Class<?> clazz, Class<T> annotationType, Predicate<Class<?>> searchEnclosingClass,
|
||||
Set<Annotation> visited) {
|
||||
|
||||
Assert.notNull(annotationType, "Annotation type must not be null");
|
||||
if (clazz == null || Object.class == clazz) {
|
||||
return null;
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ public abstract class TestContextAnnotationUtils {
|
|||
return this.declaringClass;
|
||||
}
|
||||
|
||||
public T getAnnotation() {
|
||||
T getAnnotation() {
|
||||
return this.annotation;
|
||||
}
|
||||
|
||||
|
@ -533,21 +533,21 @@ public abstract class TestContextAnnotationUtils {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Class<T> getAnnotationType() {
|
||||
Class<T> getAnnotationType() {
|
||||
return (Class<T>) this.annotation.annotationType();
|
||||
}
|
||||
|
||||
public AnnotationAttributes getAnnotationAttributes() {
|
||||
AnnotationAttributes getAnnotationAttributes() {
|
||||
return this.annotationAttributes;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Annotation getComposedAnnotation() {
|
||||
Annotation getComposedAnnotation() {
|
||||
return this.composedAnnotation;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Class<? extends Annotation> getComposedAnnotationType() {
|
||||
Class<? extends Annotation> getComposedAnnotationType() {
|
||||
return (this.composedAnnotation != null ? this.composedAnnotation.annotationType() : null);
|
||||
}
|
||||
|
||||
|
@ -633,16 +633,6 @@ public abstract class TestContextAnnotationUtils {
|
|||
this.annotationTypes = annotationTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an {@link UnsupportedOperationException} since the type of annotation
|
||||
* represented by an {@code UntypedAnnotationDescriptor} is unknown.
|
||||
*/
|
||||
@Override
|
||||
public Annotation synthesizeAnnotation() {
|
||||
throw new UnsupportedOperationException(
|
||||
"synthesizeAnnotation() is unsupported in UntypedAnnotationDescriptor");
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the next {@link UntypedAnnotationDescriptor} for the specified
|
||||
* annotation types in the hierarchy above the
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Set;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.ContextConfigurationAttributes;
|
||||
import org.springframework.test.context.ContextHierarchy;
|
||||
|
@ -127,8 +126,7 @@ abstract class ContextLoaderUtils {
|
|||
List<ContextConfigurationAttributes> configAttributesList = new ArrayList<>();
|
||||
|
||||
if (contextConfigDeclaredLocally) {
|
||||
ContextConfiguration contextConfiguration = AnnotationUtils.synthesizeAnnotation(
|
||||
desc.getAnnotationAttributes(), ContextConfiguration.class, desc.getRootDeclaringClass());
|
||||
ContextConfiguration contextConfiguration = (ContextConfiguration) desc.synthesizeAnnotation();
|
||||
convertContextConfigToConfigAttributesAndAddToList(
|
||||
contextConfiguration, rootDeclaringClass, configAttributesList);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue