Search in sources :

Example 16 with ConfigurationProperty

use of org.springframework.boot.context.properties.source.ConfigurationProperty in project spring-boot by spring-projects.

the class InvalidConfigDataPropertyExceptionTests method createWhenProfileSpecificHasCorrectMessage.

@Test
void createWhenProfileSpecificHasCorrectMessage() {
    ConfigurationProperty property = new ConfigurationProperty(this.invalid, "bad", null);
    assertThat(new InvalidConfigDataPropertyException(property, true, null, this.resource)).hasMessage("Property 'invalid' imported from location 'test' is invalid in a profile specific resource");
}
Also used : ConfigurationProperty(org.springframework.boot.context.properties.source.ConfigurationProperty) Test(org.junit.jupiter.api.Test)

Example 17 with ConfigurationProperty

use of org.springframework.boot.context.properties.source.ConfigurationProperty in project spring-boot by spring-projects.

the class ConfigurationPropertiesReportEndpoint method getCandidate.

private ConfigurationProperty getCandidate(ConfigurationPropertyName currentName) {
    BoundConfigurationProperties bound = BoundConfigurationProperties.get(this.context);
    if (bound == null) {
        return null;
    }
    ConfigurationProperty candidate = bound.get(currentName);
    if (candidate == null && currentName.isLastElementIndexed()) {
        candidate = bound.get(currentName.chop(currentName.getNumberOfElements() - 1));
    }
    return candidate;
}
Also used : ConfigurationProperty(org.springframework.boot.context.properties.source.ConfigurationProperty) BoundConfigurationProperties(org.springframework.boot.context.properties.BoundConfigurationProperties)

Example 18 with ConfigurationProperty

use of org.springframework.boot.context.properties.source.ConfigurationProperty in project spring-boot by spring-projects.

the class ConfigurationPropertiesReportEndpoint method applyInput.

private Map<String, Object> applyInput(String qualifiedKey) {
    ConfigurationPropertyName currentName = getCurrentName(qualifiedKey);
    ConfigurationProperty candidate = getCandidate(currentName);
    PropertySource<?> propertySource = getPropertySource(candidate);
    if (propertySource != null) {
        Object value = stringifyIfNecessary(candidate.getValue());
        SanitizableData data = new SanitizableData(propertySource, currentName.toString(), value);
        return getInput(candidate, this.sanitizer.sanitize(data));
    }
    return Collections.emptyMap();
}
Also used : ConfigurationProperty(org.springframework.boot.context.properties.source.ConfigurationProperty) ConfigurationPropertyName(org.springframework.boot.context.properties.source.ConfigurationPropertyName) SanitizableData(org.springframework.boot.actuate.endpoint.SanitizableData)

Aggregations

ConfigurationProperty (org.springframework.boot.context.properties.source.ConfigurationProperty)18 Test (org.junit.jupiter.api.Test)9 ConfigurationPropertyName (org.springframework.boot.context.properties.source.ConfigurationPropertyName)5 ArrayList (java.util.ArrayList)4 MockConfigurationPropertySource (org.springframework.boot.context.properties.source.MockConfigurationPropertySource)4 ConfigurationPropertySource (org.springframework.boot.context.properties.source.ConfigurationPropertySource)3 Origin (org.springframework.boot.origin.Origin)3 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 Map (java.util.Map)2 SanitizableData (org.springframework.boot.actuate.endpoint.SanitizableData)2 BindContext (org.springframework.boot.context.properties.bind.BindContext)2 Bindable (org.springframework.boot.context.properties.bind.Bindable)2 Binder (org.springframework.boot.context.properties.bind.Binder)2 ConverterNotFoundException (org.springframework.core.convert.ConverterNotFoundException)2 FieldError (org.springframework.validation.FieldError)2 ObjectError (org.springframework.validation.ObjectError)2 Valid (jakarta.validation.Valid)1 Min (jakarta.validation.constraints.Min)1 NotNull (jakarta.validation.constraints.NotNull)1