Search in sources :

Example 1 with MapPropertySource

use of com.synopsys.integration.configuration.source.MapPropertySource 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 MapPropertySource

use of com.synopsys.integration.configuration.source.MapPropertySource 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 MapPropertySource

use of com.synopsys.integration.configuration.source.MapPropertySource 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 MapPropertySource

use of com.synopsys.integration.configuration.source.MapPropertySource in project synopsys-detect by blackducksoftware.

the class DetectConfigurationFactoryTestUtils method factoryOf.

@SafeVarargs
public static DetectConfigurationFactory factoryOf(Pair<Property, String>... properties) {
    Map<String, String> propertyMap = Bds.of(properties).toMap(pair -> pair.getLeft().getKey(), Pair::getRight);
    PropertySource inMemoryPropertySource = new MapPropertySource("test", propertyMap);
    PropertyConfiguration propertyConfiguration = new PropertyConfiguration(Collections.singletonList(inMemoryPropertySource));
    DetectPropertyConfiguration detectPropertyConfiguration = new DetectPropertyConfiguration(propertyConfiguration, new SimplePathResolver());
    return new DetectConfigurationFactory(detectPropertyConfiguration, new Gson());
}
Also used : MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) Gson(com.google.gson.Gson) SimplePathResolver(com.synopsys.integration.configuration.property.types.path.SimplePathResolver) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Pair(org.apache.commons.lang3.tuple.Pair) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertySource(com.synopsys.integration.configuration.source.PropertySource)

Example 5 with MapPropertySource

use of com.synopsys.integration.configuration.source.MapPropertySource in project synopsys-detect by blackducksoftware.

the class DetectConfigurationTest method testGenericProperty.

@Test
public void testGenericProperty() {
    HashMap<String, String> values = new HashMap<>();
    values.put(DetectProperties.DETECT_PROJECT_CODELOCATION_PREFIX.getKey(), "some_prefix");
    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();
    assertTrue(bdioOptions.getProjectCodeLocationPrefix().isPresent());
    assertEquals("some_prefix", bdioOptions.getProjectCodeLocationPrefix().get());
}
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)

Aggregations

MapPropertySource (com.synopsys.integration.configuration.source.MapPropertySource)10 PropertyConfiguration (com.synopsys.integration.configuration.config.PropertyConfiguration)7 PropertySource (com.synopsys.integration.configuration.source.PropertySource)7 SimplePathResolver (com.synopsys.integration.configuration.property.types.path.SimplePathResolver)5 Gson (com.google.gson.Gson)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Test (org.junit.jupiter.api.Test)4 DetectConfigurationFactory (com.synopsys.integration.detect.configuration.DetectConfigurationFactory)2 DetectPropertyConfiguration (com.synopsys.integration.detect.configuration.DetectPropertyConfiguration)2 BdioOptions (com.synopsys.integration.detect.workflow.bdio.BdioOptions)2 BlackDuckServerConfig (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig)1 PathResolver (com.synopsys.integration.configuration.property.types.path.PathResolver)1 DetectInfo (com.synopsys.integration.detect.configuration.DetectInfo)1 DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)1 DetectableOptionFactory (com.synopsys.integration.detect.configuration.DetectableOptionFactory)1 BlackDuckConfigFactory (com.synopsys.integration.detect.configuration.connection.BlackDuckConfigFactory)1 HelpJsonManager (com.synopsys.integration.detect.configuration.help.json.HelpJsonManager)1 HelpPrinter (com.synopsys.integration.detect.configuration.help.print.HelpPrinter)1 DeprecationResult (com.synopsys.integration.detect.configuration.validation.DeprecationResult)1