Search in sources :

Example 1 with PropertyConfiguration

use of com.synopsys.integration.configuration.config.PropertyConfiguration 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 PropertyConfiguration

use of com.synopsys.integration.configuration.config.PropertyConfiguration in project synopsys-detect by blackducksoftware.

the class AllListPropertiesTests method testTwoValues.

@Test
public void testTwoValues() throws InvalidPropertyException {
    AllEnumListProperty<Example> property = new AllEnumListProperty<>("enum.valued", new ArrayList<>(), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "thIrd,another"));
    AllEnumList<Example> list = config.getValue(property);
    Assertions.assertFalse(list.containsNone());
    Assertions.assertFalse(list.containsAll());
    Assertions.assertEquals(list.toPresentValues().size(), 2, "Since 'third' was provided, it should be present.");
    Assertions.assertEquals(list.toProvidedValues().size(), 2, "Should have two provided values of 'third' and 'another'.");
    Assertions.assertEquals(list.representedValues().size(), 2, "Two values, 'third' and 'another', should be represented.");
    Assertions.assertTrue(list.representedValues().contains(Example.THIRD));
    Assertions.assertTrue(list.representedValues().contains(Example.ANOTHER));
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) AllEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.AllEnumListProperty) Test(org.junit.jupiter.api.Test)

Example 3 with PropertyConfiguration

use of com.synopsys.integration.configuration.config.PropertyConfiguration in project synopsys-detect by blackducksoftware.

the class AllListPropertiesTests method testNoneThrows.

@Test()
public void testNoneThrows() throws InvalidPropertyException {
    AllEnumListProperty<Example> property = new AllEnumListProperty<>("enum.valued", new ArrayList<>(), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "none"));
    Assertions.assertThrows(InvalidPropertyException.class, () -> config.getValue(property));
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) AllEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.AllEnumListProperty) Test(org.junit.jupiter.api.Test)

Example 4 with PropertyConfiguration

use of com.synopsys.integration.configuration.config.PropertyConfiguration in project synopsys-detect by blackducksoftware.

the class AllListPropertiesTests method testSingleValue.

@Test
public void testSingleValue() throws InvalidPropertyException {
    AllEnumListProperty<Example> property = new AllEnumListProperty<>("enum.valued", new ArrayList<>(), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "thIrd"));
    AllEnumList<Example> list = config.getValue(property);
    Assertions.assertFalse(list.containsNone());
    Assertions.assertFalse(list.containsAll());
    Assertions.assertEquals(list.toPresentValues().size(), 1, "Since 'third' was provided, it should be present.");
    Assertions.assertEquals(list.toProvidedValues().size(), 1, "Should have single provided value of 'third'.");
    Assertions.assertEquals(list.representedValues().size(), 1, "One value, 'third', should be represented.");
    Assertions.assertTrue(list.representedValues().contains(Example.THIRD));
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) AllEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.AllEnumListProperty) Test(org.junit.jupiter.api.Test)

Example 5 with PropertyConfiguration

use of com.synopsys.integration.configuration.config.PropertyConfiguration in project synopsys-detect by blackducksoftware.

the class AllListPropertiesTests method testAll.

@Test
public void testAll() throws InvalidPropertyException {
    AllEnumListProperty<Example> property = new AllEnumListProperty<>("enum.valued", new ArrayList<>(), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "ALL"));
    AllEnumList<Example> list = config.getValue(property);
    Assertions.assertTrue(list.containsAll());
    Assertions.assertFalse(list.containsNone());
    Assertions.assertEquals(list.toPresentValues().size(), 0, "No 'actual' valaues of the enum are 'present'");
    Assertions.assertEquals(list.toProvidedValues().size(), 1, "Should have single provided value of ALL.");
    Assertions.assertEquals(list.representedValues().size(), 3, "All 3 values should be represented by ALL.");
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) AllEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.AllEnumListProperty) Test(org.junit.jupiter.api.Test)

Aggregations

PropertyConfiguration (com.synopsys.integration.configuration.config.PropertyConfiguration)58 Test (org.junit.jupiter.api.Test)53 SimplePathResolver (com.synopsys.integration.configuration.property.types.path.SimplePathResolver)7 MapPropertySource (com.synopsys.integration.configuration.source.MapPropertySource)7 Gson (com.google.gson.Gson)5 AllNoneEnumListProperty (com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty)5 PropertySource (com.synopsys.integration.configuration.source.PropertySource)5 DetectArgumentState (com.synopsys.integration.detect.configuration.help.DetectArgumentState)5 AllEnumListProperty (com.synopsys.integration.configuration.property.types.enumallnone.property.AllEnumListProperty)4 NoneEnumListProperty (com.synopsys.integration.configuration.property.types.enumallnone.property.NoneEnumListProperty)4 DetectConfigurationFactory (com.synopsys.integration.detect.configuration.DetectConfigurationFactory)4 DetectPropertyConfiguration (com.synopsys.integration.detect.configuration.DetectPropertyConfiguration)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 InstalledToolLocator (com.synopsys.integration.detect.tool.cache.InstalledToolLocator)3 DeprecatedValueUsage (com.synopsys.integration.configuration.property.deprecation.DeprecatedValueUsage)2 ConnectionFactory (com.synopsys.integration.detect.configuration.connection.ConnectionFactory)2 InstalledToolManager (com.synopsys.integration.detect.tool.cache.InstalledToolManager)2 ArtifactResolver (com.synopsys.integration.detect.workflow.ArtifactResolver)2 BdioOptions (com.synopsys.integration.detect.workflow.bdio.BdioOptions)2