use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor 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();
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor 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();
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method testMap.
@Test
@SuppressWarnings("unchecked")
void testMap() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(MapConfig.class).withPropertyValues("foo.map.name:foo");
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor fooProperties = applicationProperties.getContexts().get(context.getId()).getBeans().get("foo");
assertThat(fooProperties).isNotNull();
assertThat(fooProperties.getPrefix()).isEqualTo("foo");
Map<String, Object> map = fooProperties.getProperties();
assertThat(map).isNotNull();
assertThat(map).hasSize(3);
assertThat(((Map<String, Object>) map.get("map")).get("name")).isEqualTo("foo");
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method testList.
@Test
@SuppressWarnings("unchecked")
void testList() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(ListConfig.class).withPropertyValues("foo.list[0]:foo");
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor foo = applicationProperties.getContexts().get(context.getId()).getBeans().get("foo");
assertThat(foo).isNotNull();
assertThat(foo.getPrefix()).isEqualTo("foo");
Map<String, Object> map = foo.getProperties();
assertThat(map).isNotNull();
assertThat(map).hasSize(3);
assertThat(((List<String>) map.get("list")).get(0)).isEqualTo("foo");
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method hikariDataSourceConfigurationPropertiesBeanCanBeSerialized.
@Test
void hikariDataSourceConfigurationPropertiesBeanCanBeSerialized() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(HikariDataSourceConfig.class);
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor hikariDataSource = applicationProperties.getContexts().get(context.getId()).getBeans().get("hikariDataSource");
Map<String, Object> nestedProperties = hikariDataSource.getProperties();
assertThat(nestedProperties).doesNotContainKey("error");
});
}
Aggregations