Skip to content

Commit

Permalink
Polish Javadoc for BeanOverrideHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Dec 12, 2024
1 parent 3ab4ee2 commit ea8b18f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ public BeanOverrideContextCustomizer createContextCustomizer(Class<?> testClass,
List<ContextConfigurationAttributes> configAttributes) {

Set<BeanOverrideHandler> handlers = new LinkedHashSet<>();
findBeanOverrideHandler(testClass, handlers);
findBeanOverrideHandlers(testClass, handlers);
if (handlers.isEmpty()) {
return null;
}
return new BeanOverrideContextCustomizer(handlers);
}

private void findBeanOverrideHandler(Class<?> testClass, Set<BeanOverrideHandler> handlers) {
private void findBeanOverrideHandlers(Class<?> testClass, Set<BeanOverrideHandler> handlers) {
if (TestContextAnnotationUtils.searchEnclosingClass(testClass)) {
findBeanOverrideHandler(testClass.getEnclosingClass(), handlers);
findBeanOverrideHandlers(testClass.getEnclosingClass(), handlers);
}
BeanOverrideHandler.forTestClass(testClass).forEach(handler ->
Assert.state(handlers.add(handler), () ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
* unique set of metadata used to identify the bean to override. Overridden
* {@code equals()} and {@code hashCode()} methods should also delegate to the
* {@code super} implementations in this class in order to support the basic
* metadata used by all bean overrides.
* metadata used by all bean overrides. In addition, it is recommended that
* implementations override {@code toString()} to include all relevant metadata
* in order to enhance diagnostics.
*
* <p>Concrete implementations of {@code BeanOverrideHandler} can store additional
* metadata to use during override {@linkplain #createOverrideInstance instance
Expand Down Expand Up @@ -93,9 +95,11 @@ protected BeanOverrideHandler(Field field, ResolvableType beanType, @Nullable St
/**
* Process the given {@code testClass} and build the corresponding
* {@code BeanOverrideHandler} list derived from {@link BeanOverride @BeanOverride}
* fields in the test class, its type hierarchy, and its enclosing class hierarchy.
* fields in the test class and its type hierarchy.
* <p>This method does not search the enclosing class hierarchy.
* @param testClass the test class to process
* @return a list of bean override handlers
* @see org.springframework.test.context.TestContextAnnotationUtils#searchEnclosingClass(Class)
*/
public static List<BeanOverrideHandler> forTestClass(Class<?> testClass) {
List<BeanOverrideHandler> handlers = new LinkedList<>();
Expand Down

0 comments on commit ea8b18f

Please sign in to comment.