use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method testEmptyMapIsNotAdded.
@Test
void testEmptyMapIsNotAdded() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(MapConfig.class);
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).doesNotContainKey("map");
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method endpointResponseUsesPlaceholderForComplexValueAsPropertyValue.
@Test
@SuppressWarnings("unchecked")
void endpointResponseUsesPlaceholderForComplexValueAsPropertyValue() throws IOException {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withInitializer((context) -> {
ConfigurableEnvironment environment = context.getEnvironment();
environment.getPropertySources().addFirst(new MapPropertySource("test", Collections.singletonMap("foo.name", new ComplexProperty("Spring Boot"))));
}).withUserConfiguration(ComplexPropertyToStringConverter.class, FooConfig.class);
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor descriptor = applicationProperties.getContexts().get(context.getId()).getBeans().get("foo");
assertThat((Map<String, Object>) descriptor.getInputs().get("name")).containsEntry("value", "Complex property value " + ComplexProperty.class.getName());
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method endpointResponseUsesToStringOfCharSequenceAsPropertyValue.
@Test
@SuppressWarnings("unchecked")
void endpointResponseUsesToStringOfCharSequenceAsPropertyValue() throws IOException {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withInitializer((context) -> {
ConfigurableEnvironment environment = context.getEnvironment();
environment.getPropertySources().addFirst(new MapPropertySource("test", Collections.singletonMap("foo.name", new CharSequenceProperty("Spring Boot"))));
}).withUserConfiguration(FooConfig.class);
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor descriptor = applicationProperties.getContexts().get(context.getId()).getBeans().get("foo");
assertThat((Map<String, Object>) descriptor.getInputs().get("name")).containsEntry("value", "Spring Boot");
});
}
use of org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpointSerializationTests method testNestedNaming.
@Test
@SuppressWarnings("unchecked")
void testNestedNaming() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(FooConfig.class).withPropertyValues("foo.bar.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();
Map<String, Object> map = foo.getProperties();
assertThat(map).isNotNull();
assertThat(map).hasSize(2);
assertThat(((Map<String, Object>) map.get("bar")).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 testCycle.
@Test
void testCycle() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(CycleConfig.class);
contextRunner.run((context) -> {
ConfigurationPropertiesReportEndpoint endpoint = context.getBean(ConfigurationPropertiesReportEndpoint.class);
ApplicationConfigurationProperties applicationProperties = endpoint.configurationProperties();
ConfigurationPropertiesBeanDescriptor cycle = applicationProperties.getContexts().get(context.getId()).getBeans().get("cycle");
assertThat(cycle.getPrefix()).isEqualTo("cycle");
Map<String, Object> map = cycle.getProperties();
assertThat(map).isNotNull();
assertThat(map).containsOnlyKeys("error");
assertThat(map).containsEntry("error", "Cannot serialize 'cycle'");
});
}
Aggregations