use of org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method propertyEntryNotFound.
@Test
void propertyEntryNotFound() {
ConfigurableEnvironment environment = emptyEnvironment();
environment.getPropertySources().addFirst(singleKeyPropertySource("test", "foo", "bar"));
EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("does.not.exist");
assertThat(descriptor).isNotNull();
assertThat(descriptor.getProperty()).isNull();
Map<String, PropertySourceEntryDescriptor> sources = propertySources(descriptor);
assertThat(sources.keySet()).containsExactly("test");
assertPropertySourceEntryDescriptor(sources.get("test"), null, null);
}
use of org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method propertyEntry.
@Test
void propertyEntry() {
TestPropertyValues.of("my.foo=another").applyToSystemProperties(() -> {
StandardEnvironment environment = new StandardEnvironment();
TestPropertyValues.of("my.foo=bar", "my.foo2=bar2").applyTo(environment, TestPropertyValues.Type.MAP, "test");
EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("my.foo");
assertThat(descriptor).isNotNull();
assertThat(descriptor.getProperty()).isNotNull();
assertThat(descriptor.getProperty().getSource()).isEqualTo("test");
assertThat(descriptor.getProperty().getValue()).isEqualTo("bar");
Map<String, PropertySourceEntryDescriptor> sources = propertySources(descriptor);
assertThat(sources.keySet()).containsExactly("test", "systemProperties", "systemEnvironment");
assertPropertySourceEntryDescriptor(sources.get("test"), "bar", null);
assertPropertySourceEntryDescriptor(sources.get("systemProperties"), "another", null);
assertPropertySourceEntryDescriptor(sources.get("systemEnvironment"), null, null);
return null;
});
}
use of org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method originAndOriginParents.
@Test
void originAndOriginParents() {
StandardEnvironment environment = new StandardEnvironment();
OriginParentMockPropertySource propertySource = new OriginParentMockPropertySource();
propertySource.setProperty("name", "test");
environment.getPropertySources().addFirst(propertySource);
EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("name");
PropertySourceEntryDescriptor entryDescriptor = propertySources(descriptor).get("mockProperties");
assertThat(entryDescriptor.getProperty().getOrigin()).isEqualTo("name");
assertThat(entryDescriptor.getProperty().getOriginParents()).containsExactly("spring", "boot");
}
Aggregations