Search in sources :

Example 6 with Property

use of com.synopsys.integration.configuration.property.Property in project synopsys-detect by blackducksoftware.

the class PropertyConfigurationTest method getRawValueMapWithPassthroughs.

@Test
public void getRawValueMapWithPassthroughs() {
    Set<Property> properties = new HashSet<>();
    PassthroughProperty passthrough = new PassthroughProperty("blackduck.passthrough");
    properties.add(passthrough);
    Map<String, String> propertyMap = Bds.mapOf(Pair.of("blackduck.passthrough.password", "password"));
    PropertyConfiguration configuration = configOf(propertyMap);
    Map<String, String> rawPropertyValues = configuration.getMaskedRawValueMap(properties, rawKey -> rawKey.contains("password"));
    Assertions.assertEquals("********", rawPropertyValues.get("blackduck.passthrough.password"));
}
Also used : NullableAlikeProperty(com.synopsys.integration.configuration.property.base.NullableAlikeProperty) Property(com.synopsys.integration.configuration.property.Property) ValuedAlikeProperty(com.synopsys.integration.configuration.property.base.ValuedAlikeProperty) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 7 with Property

use of com.synopsys.integration.configuration.property.Property in project synopsys-detect by blackducksoftware.

the class ValuedListPropertyTest method isCommaSeparated.

@Test
public void isCommaSeparated() {
    Property testProperty = new TestListProperty("key", emptyList());
    Assertions.assertTrue(testProperty.isCommaSeparated(), "This parser should separate on comma and should report that it does.");
}
Also used : Property(com.synopsys.integration.configuration.property.Property) Test(org.junit.jupiter.api.Test)

Example 8 with Property

use of com.synopsys.integration.configuration.property.Property in project synopsys-detect by blackducksoftware.

the class PropertyConfigurationHelpContext method findPropertyParseErrors.

public Map<String, List<String>> findPropertyParseErrors(List<Property> knownProperties) {
    Map<String, List<String>> exceptions = new HashMap<>();
    for (Property property : knownProperties) {
        if (property.getClass().isAssignableFrom(TypedProperty.class)) {
            // TODO: Can we do this without reflection?
            Optional<ValueParseException> exception = propertyConfiguration.getPropertyException((TypedProperty) property);
            if (exception.isPresent()) {
                List<String> propertyExceptions = exceptions.getOrDefault(property.getKey(), new ArrayList<>());
                if (StringUtils.isNotBlank(exception.get().getMessage())) {
                    propertyExceptions.add(exception.get().getMessage());
                } else {
                    propertyExceptions.add(exception.get().toString());
                }
                exceptions.put(property.getKey(), propertyExceptions);
            }
        }
    }
    return exceptions;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Property(com.synopsys.integration.configuration.property.Property) TypedProperty(com.synopsys.integration.configuration.property.base.TypedProperty) ValueParseException(com.synopsys.integration.configuration.parse.ValueParseException)

Aggregations

Property (com.synopsys.integration.configuration.property.Property)8 PassthroughProperty (com.synopsys.integration.configuration.property.base.PassthroughProperty)4 Test (org.junit.jupiter.api.Test)4 TypedProperty (com.synopsys.integration.configuration.property.base.TypedProperty)3 NullableStringProperty (com.synopsys.integration.configuration.property.types.string.NullableStringProperty)3 NullableAlikeProperty (com.synopsys.integration.configuration.property.base.NullableAlikeProperty)2 ValuedAlikeProperty (com.synopsys.integration.configuration.property.base.ValuedAlikeProperty)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ValueParseException (com.synopsys.integration.configuration.parse.ValueParseException)1 Properties (com.synopsys.integration.configuration.property.Properties)1 NullableProperty (com.synopsys.integration.configuration.property.base.NullableProperty)1 ValuedProperty (com.synopsys.integration.configuration.property.base.ValuedProperty)1 BooleanProperty (com.synopsys.integration.configuration.property.types.bool.BooleanProperty)1 AllNoneEnumListProperty (com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty)1 NoneEnumListProperty (com.synopsys.integration.configuration.property.types.enumallnone.property.NoneEnumListProperty)1 ExtendedEnumProperty (com.synopsys.integration.configuration.property.types.enumextended.ExtendedEnumProperty)1 EnumListProperty (com.synopsys.integration.configuration.property.types.enums.EnumListProperty)1 EnumProperty (com.synopsys.integration.configuration.property.types.enums.EnumProperty)1 IntegerProperty (com.synopsys.integration.configuration.property.types.integer.IntegerProperty)1