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));
}
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());
}
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));
}
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));
}
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());
}
Aggregations