Search in sources :

Example 46 with PropertyConfiguration

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

the class ExtendedEnumPropertiesTests method testValued.

@Test
public void testValued() throws InvalidPropertyException {
    ValuedAlikeProperty<ExtendedEnumValue<ExampleExtension, Example>> property = new ExtendedEnumProperty<>("enum.nullable", ExtendedEnumValue.ofExtendedValue(ExampleExtension.NONE), ExampleExtension.class, Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.nullable", "ANOTHER"));
    ExtendedEnumValue<ExampleExtension, Example> value = config.getValue(property);
    Assertions.assertEquals(ExtendedEnumValue.ofBaseValue(Example.ANOTHER), value);
    PropertyTestHelpUtil.assertAllHelpValid(property, Bds.listOf("THING", "ANOTHER", "THIRD", "NONE"));
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 47 with PropertyConfiguration

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

the class ExtendedEnumPropertiesTests method testList.

@Test
public void testList() throws InvalidPropertyException {
    List<ExtendedEnumValue<ExampleExtension, Example>> defaultValue = Bds.listOf(ExtendedEnumValue.ofBaseValue(Example.THING), ExtendedEnumValue.ofExtendedValue(ExampleExtension.NONE));
    ExtendedEnumListProperty<ExampleExtension, Example> property = new ExtendedEnumListProperty<>("enum.nullable", defaultValue, ExampleExtension.class, Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.nullable", "THIRD,NONE"));
    List<ExtendedEnumValue<ExampleExtension, Example>> value = config.getValue(property);
    Assertions.assertEquals(Bds.listOf(ExtendedEnumValue.ofBaseValue(Example.THIRD), ExtendedEnumValue.ofExtendedValue(ExampleExtension.NONE)), value);
    PropertyTestHelpUtil.assertAllListHelpValid(property, Bds.listOf("THING", "ANOTHER", "THIRD", "NONE"));
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 48 with PropertyConfiguration

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

the class EnumPropertiesTests method testDeprecatedValueDefaultNotUsage.

@Test
public void testDeprecatedValueDefaultNotUsage() throws InvalidPropertyException {
    EnumProperty<Example> property = new EnumProperty<>("enum.valued", Example.THIRD, Example.class);
    property.deprecateValue(Example.THIRD, "Third is deprecated");
    PropertyConfiguration config = emptyConfig();
    Optional<Example> value = config.getProvidedParsedValue(property);
    Assertions.assertFalse(value.isPresent());
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 49 with PropertyConfiguration

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

the class EnumPropertiesTests method testList.

@Test
public void testList() throws InvalidPropertyException {
    EnumListProperty<Example> property = new EnumListProperty<>("enum.list", Bds.listOf(Example.THIRD), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.list", "ANOTHER,THING"));
    Assertions.assertEquals(Bds.listOf(Example.ANOTHER, Example.THING), config.getValue(property));
    PropertyTestHelpUtil.assertAllListHelpValid(property);
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 50 with PropertyConfiguration

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

the class EnumPropertiesTests method testValued.

@Test
public void testValued() throws InvalidPropertyException {
    EnumProperty<Example> property = new EnumProperty<>("enum.valued", Example.THIRD, Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "THIRD"));
    Assertions.assertEquals(Example.THIRD, config.getValue(property));
    PropertyTestHelpUtil.assertAllHelpValid(property, Bds.listOf("THING", "ANOTHER", "THIRD"));
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) 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