Search in sources :

Example 21 with ApplicationConfigurationProperties

use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties in project spring-boot by spring-projects.

the class ConfigurationPropertiesReportEndpointMethodAnnotationsTests method prefixFromBeanMethodConfigurationPropertiesCanOverridePrefixOnClass.

@Test
void prefixFromBeanMethodConfigurationPropertiesCanOverridePrefixOnClass() {
    ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(OverriddenPrefix.class).withPropertyValues("other.name:foo");
    contextRunner.run((context) -> {
        ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
        ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
        assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
        ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
        ConfigurationPropertiesBeanDescriptor bar = contextProperties.getBeans().get("bar");
        assertThat(bar).isNotNull();
        assertThat(bar.getPrefix()).isEqualTo("other");
        assertThat(bar.getProperties()).isNotNull();
        assertThat(bar.getProperties()).isNotEmpty();
    });
}
Also used : ContextConfigurationProperties(org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties) ConfigurationPropertiesBeanDescriptor(org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor) ApplicationConfigurationProperties(org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties) ApplicationContextRunner(org.springframework.boot.test.context.runner.ApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Example 22 with ApplicationConfigurationProperties

use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties in project spring-boot by spring-projects.

the class ConfigurationPropertiesReportEndpointMethodAnnotationsTests method testNaming.

@Test
void testNaming() {
    ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class).withPropertyValues("other.name:foo", "first.name:bar");
    contextRunner.run((context) -> {
        ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
        ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
        assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
        ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
        ConfigurationPropertiesBeanDescriptor other = contextProperties.getBeans().get("other");
        assertThat(other).isNotNull();
        assertThat(other.getPrefix()).isEqualTo("other");
        assertThat(other.getProperties()).isNotNull();
        assertThat(other.getProperties()).isNotEmpty();
    });
}
Also used : ContextConfigurationProperties(org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties) ConfigurationPropertiesBeanDescriptor(org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor) ApplicationConfigurationProperties(org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties) ApplicationContextRunner(org.springframework.boot.test.context.runner.ApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Aggregations

ApplicationConfigurationProperties (org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties)22 Test (org.junit.jupiter.api.Test)21 ApplicationContextRunner (org.springframework.boot.test.context.runner.ApplicationContextRunner)21 ConfigurationPropertiesBeanDescriptor (org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor)16 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ContextConfigurationProperties (org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationProperties)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 HikariDataSource (com.zaxxer.hikari.HikariDataSource)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InetAddress (java.net.InetAddress)2 Collections (java.util.Collections)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.entry (org.assertj.core.api.Assertions.entry)2 ConfigurationProperties (org.springframework.boot.context.properties.ConfigurationProperties)2 ConfigurationPropertiesBinding (org.springframework.boot.context.properties.ConfigurationPropertiesBinding)2 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)2