use of org.springframework.boot.origin.Origin in project spring-boot by spring-projects.
the class ConfigDataLocationTests method splitWhenHasOriginReturnsElementsWithOriginSet.
@Test
void splitWhenHasOriginReturnsElementsWithOriginSet() {
Origin origin = mock(Origin.class);
ConfigDataLocation location = ConfigDataLocation.of("a;b").withOrigin(origin);
ConfigDataLocation[] split = location.split();
assertThat(split[0].getOrigin()).isEqualTo(origin);
assertThat(split[1].getOrigin()).isEqualTo(origin);
}
use of org.springframework.boot.origin.Origin in project spring-boot by spring-projects.
the class InputStreamSourceToByteArrayConverterTests method convertWhenFailsWithIOExceptionFromOriginProviderThrowsException.
@ConversionServiceTest
void convertWhenFailsWithIOExceptionFromOriginProviderThrowsException(ConversionService conversionService) throws Exception {
Origin origin = new TestOrigin("mylocation");
InputStreamSource source = mock(InputStreamSource.class, withSettings().extraInterfaces(OriginProvider.class));
given(source.getInputStream()).willThrow(IOException.class);
given(((OriginProvider) source).getOrigin()).willReturn(origin);
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> conversionService.convert(source, byte[].class)).withCauseExactlyInstanceOf(IllegalStateException.class).withMessageContaining("Unable to read from mylocation");
}
use of org.springframework.boot.origin.Origin in project spring-boot by spring-projects.
the class EnvironmentEndpoint method describeValueOf.
@SuppressWarnings("unchecked")
private PropertyValueDescriptor describeValueOf(String name, PropertySource<?> source, PlaceholdersResolver resolver) {
Object resolved = resolver.resolvePlaceholders(source.getProperty(name));
Origin origin = ((source instanceof OriginLookup) ? ((OriginLookup<Object>) source).getOrigin(name) : null);
Object sanitizedValue = sanitize(source, name, resolved);
return new PropertyValueDescriptor(stringifyIfNecessary(sanitizedValue), origin);
}
use of org.springframework.boot.origin.Origin in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpoint method getInput.
private Map<String, Object> getInput(ConfigurationProperty candidate, Object sanitizedValue) {
Map<String, Object> input = new LinkedHashMap<>();
Origin origin = Origin.from(candidate);
List<Origin> originParents = Origin.parentsFrom(candidate);
input.put("value", sanitizedValue);
input.put("origin", (origin != null) ? origin.toString() : "none");
if (!originParents.isEmpty()) {
input.put("originParents", originParents.stream().map(Object::toString).toArray(String[]::new));
}
return input;
}
Aggregations