Search in sources :

Example 1 with NullableStringProperty

use of com.synopsys.integration.configuration.property.types.string.NullableStringProperty in project synopsys-detect by blackducksoftware.

the class MultiplePropertySourceTests method primaryValueUsedOverSecondary.

@Test
public void primaryValueUsedOverSecondary() throws InvalidPropertyException {
    NullableAlikeProperty<String> sharedProperty = new NullableStringProperty("shared.key");
    PropertySource secondarySource = propertySourceOf("secondaryName", Pair.of(sharedProperty.getKey(), "secondaryValue"));
    PropertySource primarySource = propertySourceOf("primaryName", Pair.of(sharedProperty.getKey(), "primaryValue"));
    PropertyConfiguration config = configOf(primarySource, secondarySource);
    Assertions.assertEquals(Optional.of("primaryValue"), config.getValue(sharedProperty));
    Assertions.assertEquals(Optional.of("primaryName"), config.getPropertySource(sharedProperty));
}
Also used : NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty) PropertySource(com.synopsys.integration.configuration.source.PropertySource) Test(org.junit.jupiter.api.Test)

Example 2 with NullableStringProperty

use of com.synopsys.integration.configuration.property.types.string.NullableStringProperty in project synopsys-detect by blackducksoftware.

the class MultiplePropertySourceTests method rawValueMapContainsValuesFromBothSources.

@Test
public void rawValueMapContainsValuesFromBothSources() {
    NullableAlikeProperty<String> primaryProperty = new NullableStringProperty("primary.key");
    PropertySource primarySource = propertySourceOf("primaryName", Pair.of(primaryProperty.getKey(), "primaryValue"));
    NullableAlikeProperty<String> secondaryProperty = new NullableStringProperty("secondary.key");
    PropertySource secondarySource = propertySourceOf("secondaryName", Pair.of(secondaryProperty.getKey(), "secondaryValue"));
    PropertyConfiguration config = configOf(primarySource, secondarySource);
    Assertions.assertEquals(Bds.mapOf(Pair.of(primaryProperty.getKey(), "primaryValue"), Pair.of(secondaryProperty.getKey(), "secondaryValue")), config.getRaw());
}
Also used : NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty) PropertySource(com.synopsys.integration.configuration.source.PropertySource) Test(org.junit.jupiter.api.Test)

Example 3 with NullableStringProperty

use of com.synopsys.integration.configuration.property.types.string.NullableStringProperty in project synopsys-detect by blackducksoftware.

the class SpringConfigurationPropertySourceTests method verifySpringReturnsValue.

@Test
public void verifySpringReturnsValue() throws InvalidPropertyException {
    MockEnvironment m = new MockEnvironment();
    m.setProperty("example.key", "value");
    List<PropertySource> sources = new ArrayList<>(SpringConfigurationPropertySource.fromConfigurableEnvironment(m, true));
    PropertyConfiguration config = new PropertyConfiguration(sources);
    NullableAlikeProperty<String> property = new NullableStringProperty("example.key");
    Assertions.assertEquals(Optional.of("value"), config.getValue(property));
    Assertions.assertEquals(Optional.of("mockProperties"), config.getPropertySource(property));
}
Also used : NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty) MockEnvironment(org.springframework.mock.env.MockEnvironment) ArrayList(java.util.ArrayList) PropertySource(com.synopsys.integration.configuration.source.PropertySource) SpringConfigurationPropertySource(com.synopsys.integration.configuration.source.SpringConfigurationPropertySource) Test(org.junit.jupiter.api.Test)

Example 4 with NullableStringProperty

use of com.synopsys.integration.configuration.property.types.string.NullableStringProperty in project synopsys-detect by blackducksoftware.

the class MultiplePropertySourceTests method valueFromSecondaryWhenNotInPrimary.

@Test
public void valueFromSecondaryWhenNotInPrimary() throws InvalidPropertyException {
    NullableAlikeProperty<String> property = new NullableStringProperty("any.key");
    PropertySource secondarySource = propertySourceOf("secondaryName", Pair.of(property.getKey(), "secondaryValue"));
    PropertySource primarySource = propertySourceOf("primaryName");
    PropertyConfiguration config = configOf(primarySource, secondarySource);
    Assertions.assertEquals(Optional.of("secondaryValue"), config.getValue(property));
    Assertions.assertEquals(Optional.of("secondaryName"), config.getPropertySource(property));
}
Also used : NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty) PropertySource(com.synopsys.integration.configuration.source.PropertySource) Test(org.junit.jupiter.api.Test)

Example 5 with NullableStringProperty

use of com.synopsys.integration.configuration.property.types.string.NullableStringProperty in project synopsys-detect by blackducksoftware.

the class MultiplePropertySourceTests method containsKeysFromBothSources.

@Test
public void containsKeysFromBothSources() {
    NullableAlikeProperty<String> primaryProperty = new NullableStringProperty("primary.key");
    PropertySource primarySource = propertySourceOf("primaryName", Pair.of(primaryProperty.getKey(), "primaryValue"));
    NullableAlikeProperty<String> secondaryProperty = new NullableStringProperty("secondary.key");
    PropertySource secondarySource = propertySourceOf("secondaryName", Pair.of(secondaryProperty.getKey(), "secondaryValue"));
    PropertyConfiguration config = configOf(primarySource, secondarySource);
    Assertions.assertEquals(Bds.setOf(primaryProperty.getKey(), secondaryProperty.getKey()), config.getKeys());
}
Also used : NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty) PropertySource(com.synopsys.integration.configuration.source.PropertySource) Test(org.junit.jupiter.api.Test)

Aggregations

NullableStringProperty (com.synopsys.integration.configuration.property.types.string.NullableStringProperty)6 Test (org.junit.jupiter.api.Test)6 PropertySource (com.synopsys.integration.configuration.source.PropertySource)5 Property (com.synopsys.integration.configuration.property.Property)1 NullableAlikeProperty (com.synopsys.integration.configuration.property.base.NullableAlikeProperty)1 PassthroughProperty (com.synopsys.integration.configuration.property.base.PassthroughProperty)1 ValuedAlikeProperty (com.synopsys.integration.configuration.property.base.ValuedAlikeProperty)1 SpringConfigurationPropertySource (com.synopsys.integration.configuration.source.SpringConfigurationPropertySource)1 ProductMajorVersion (com.synopsys.integration.configuration.util.ProductMajorVersion)1 ArrayList (java.util.ArrayList)1 MockEnvironment (org.springframework.mock.env.MockEnvironment)1