use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method testSelfReferentialProperty.
@Test
@SuppressWarnings("unchecked")
void testSelfReferentialProperty() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(SelfReferentialConfig.class).withPropertyValues("foo.name: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.getPrefix()).isEqualTo("foo");
Map<String, Object> map = foo.getProperties();
assertThat(map).isNotNull();
assertThat(map).containsOnlyKeys("bar", "name");
assertThat(map).containsEntry("name", "foo");
Map<String, Object> bar = (Map<String, Object>) map.get("bar");
assertThat(bar).containsOnlyKeys("name");
assertThat(bar).containsEntry("name", "123456");
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method testInitializedMapAndList.
@Test
@SuppressWarnings("unchecked")
void testInitializedMapAndList() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(InitializedMapAndListPropertiesConfig.class).withPropertyValues("foo.map.entryOne:true", "foo.list[0]:abc");
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.getPrefix()).isEqualTo("foo");
Map<String, Object> propertiesMap = foo.getProperties();
assertThat(propertiesMap).containsOnlyKeys("bar", "name", "map", "list");
Map<String, Object> map = (Map<String, Object>) propertiesMap.get("map");
assertThat(map).containsOnly(entry("entryOne", true));
List<String> list = (List<String>) propertiesMap.get("list");
assertThat(list).containsExactly("abc");
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method testNaming.
@Test
void testNaming() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(FooConfig.class).withPropertyValues("foo.name: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(2);
assertThat(map.get("name")).isEqualTo("foo");
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointFilteringTests method filterByPrefixNoMatches.
@Test
void filterByPrefixNoMatches() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class).withPropertyValues("foo.primary.name:foo1", "foo.secondary.name:foo2", "only.bar.name:solo1");
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationPropertiesWithPrefix("foo.third");
assertThat(applicationProperties.getContexts()).containsOnlyKeys(context.getId());
ContextConfigurationProperties contextProperties = applicationProperties.getContexts().get(context.getId());
assertThat(contextProperties.getBeans()).isEmpty();
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ApplicationConfigurationProperties in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointParentTests method configurationPropertiesClass.
@Test
void configurationPropertiesClass() {
new ApplicationContextRunner().withUserConfiguration(Parent.class).run((parent) -> {
new ApplicationContextRunner().withUserConfiguration(ClassConfigurationProperties.class).withParent(parent).run((child) -> {
ConfigurationPropertiesReportEndpoint endpoint = child.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
assertThat(applicationProperties.getContexts()).containsOnlyKeys(child.getId(), parent.getId());
assertThat(applicationProperties.getContexts().get(child.getId()).getBeans().keySet()).containsExactly("someProperties");
assertThat((applicationProperties.getContexts().get(parent.getId()).getBeans().keySet())).containsExactly("testProperties");
});
});
}
Aggregations