Search in sources :

Example 1 with PropertySource

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());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) SimplePathResolver(com.synopsys.integration.configuration.property.types.path.SimplePathResolver) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertySource(com.synopsys.integration.configuration.source.PropertySource) BdioOptions(com.synopsys.integration.detect.workflow.bdio.BdioOptions) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with PropertySource

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);
}
Also used : MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertySource(com.synopsys.integration.configuration.source.PropertySource) Test(org.junit.jupiter.api.Test)

Example 3 with PropertySource

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());
}
Also used : MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertySource(com.synopsys.integration.configuration.source.PropertySource) Test(org.junit.jupiter.api.Test)

Example 4 with PropertySource

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));
}
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 PropertySource

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

PropertySource (com.synopsys.integration.configuration.source.PropertySource)16 Test (org.junit.jupiter.api.Test)12 MapPropertySource (com.synopsys.integration.configuration.source.MapPropertySource)7 ArrayList (java.util.ArrayList)6 PropertyConfiguration (com.synopsys.integration.configuration.config.PropertyConfiguration)5 NullableStringProperty (com.synopsys.integration.configuration.property.types.string.NullableStringProperty)5 SimplePathResolver (com.synopsys.integration.configuration.property.types.path.SimplePathResolver)4 Gson (com.google.gson.Gson)3 HashMap (java.util.HashMap)3 PassthroughProperty (com.synopsys.integration.configuration.property.base.PassthroughProperty)2 SpringConfigurationPropertySource (com.synopsys.integration.configuration.source.SpringConfigurationPropertySource)2 BdioOptions (com.synopsys.integration.detect.workflow.bdio.BdioOptions)2 BlackDuckServerConfig (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig)1 NoPropertyResolution (com.synopsys.integration.configuration.config.resolution.NoPropertyResolution)1 PropertyResolutionInfo (com.synopsys.integration.configuration.config.resolution.PropertyResolutionInfo)1 SourcePropertyResolution (com.synopsys.integration.configuration.config.resolution.SourcePropertyResolution)1 DetectConfigurationFactory (com.synopsys.integration.detect.configuration.DetectConfigurationFactory)1 DetectPropertyConfiguration (com.synopsys.integration.detect.configuration.DetectPropertyConfiguration)1 BlackDuckConfigFactory (com.synopsys.integration.detect.configuration.connection.BlackDuckConfigFactory)1 DetectArgumentState (com.synopsys.integration.detect.configuration.help.DetectArgumentState)1