use of com.synopsys.integration.configuration.source.PropertySource in project synopsys-detect by blackducksoftware.
the class DetectConfigurationTest method testDeprecated.
@Test
public void testDeprecated() throws DetectUserFriendlyException {
HashMap<String, String> values = new HashMap<>();
values.put(DetectProperties.DETECT_BDIO2_ENABLED.getKey(), "false");
List<PropertySource> propertySources = new ArrayList<>();
propertySources.add(new MapPropertySource("test", values));
PropertyConfiguration propertyConfiguration = new PropertyConfiguration(propertySources);
DetectPropertyConfiguration detectPropertyConfiguration = new DetectPropertyConfiguration(propertyConfiguration, new SimplePathResolver());
DetectConfigurationFactory detectConfigurationFactory = new DetectConfigurationFactory(detectPropertyConfiguration, new Gson());
BdioOptions bdioOptions = detectConfigurationFactory.createBdioOptions();
Assertions.assertFalse(bdioOptions.isBdio2Enabled());
}
use of com.synopsys.integration.configuration.source.PropertySource in project synopsys-detect by blackducksoftware.
the class MapPropertySourceTests method testNormalizesKeys.
@Test
public void testNormalizesKeys() {
PropertySource source = new MapPropertySource("test", Collections.singletonMap("CAPITAL_UNDERSCORE", "value"));
Set<String> keys = source.getKeys();
Assertions.assertEquals(Collections.singleton("capital.underscore"), keys);
}
use of com.synopsys.integration.configuration.source.PropertySource in project synopsys-detect by blackducksoftware.
the class MapPropertySourceTests method returnsKey.
@Test
public void returnsKey() {
PropertySource source = new MapPropertySource("test", Collections.singletonMap("property.key", "value"));
Assertions.assertEquals("value", source.getValue("property.key"));
Assertions.assertEquals("test", source.getOrigin("property.key"));
Assertions.assertEquals("test", source.getName());
}
use of com.synopsys.integration.configuration.source.PropertySource 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.source.PropertySource 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());
}
Aggregations