Test that source information is resolved from super class

See gh-45382

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
Yanming Zhou
2025-05-07 15:14:56 +08:00
committed by Stéphane Nicoll
parent 543de7430b
commit 91715a8c7d
4 changed files with 20 additions and 6 deletions

View File

@@ -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.
@@ -56,6 +56,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
* @author Scott Frederick
* @author Yanming Zhou
*/
class PropertyDescriptorResolverTests {
@@ -77,9 +78,13 @@ class PropertyDescriptorResolverTests {
.map((descriptor) -> descriptor.getGetter().getEnclosingElement().getSimpleName().toString()))
.containsExactly("HierarchicalProperties", "HierarchicalPropertiesParent",
"HierarchicalPropertiesParent");
assertThat(resolver.resolve(type, null)
List<ItemMetadata> itemMetadataList = resolver.resolve(type, null)
.map((descriptor) -> descriptor.resolveItemMetadata("test", metadataEnv))
.map(ItemMetadata::getDefaultValue)).containsExactly("three", "two", "one");
.toList();
assertThat(itemMetadataList).map(ItemMetadata::getDefaultValue)
.containsExactly("three", "two", "one");
assertThat(itemMetadataList).map(ItemMetadata::getDescription)
.containsExactly("I'm third", "I'm second", "I'm first");
});
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -26,6 +26,9 @@ import org.springframework.boot.configurationsample.ConfigurationProperties;
@ConfigurationProperties(prefix = "hierarchical")
public class HierarchicalProperties extends HierarchicalPropertiesParent {
/**
* I'm third
*/
private String third = "three";
public String getThird() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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.
@@ -23,6 +23,9 @@ package org.springframework.boot.configurationsample.simple;
*/
public abstract class HierarchicalPropertiesGrandparent {
/**
* I'm first
*/
private String first = "one";
public String getFirst() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 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.
@@ -23,6 +23,9 @@ package org.springframework.boot.configurationsample.simple;
*/
public abstract class HierarchicalPropertiesParent extends HierarchicalPropertiesGrandparent {
/**
* I'm second
*/
private String second = "two";
public String getSecond() {