Merge pull request #45382 from quaff

* pr/45382:
  Polish "Test that source information is resolved from super class"
  Test that source information is resolved from super class

Closes gh-45382
This commit is contained in:
Stéphane Nicoll
2025-05-07 10:38:15 +02:00
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("Concrete property.", "Parent property.", "Grandparent property.");
});
}

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 {
/**
* Concrete property.
*/
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 {
/**
* Grandparent property.
*/
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 {
/**
* Parent property.
*/
private String second = "two";
public String getSecond() {