Search in sources :

Example 11 with PropertyConfiguration

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

the class EnumPropertiesTests method testDeprecatedValueDefaultProvided.

@Test
public void testDeprecatedValueDefaultProvided() throws InvalidPropertyException {
    EnumProperty<Example> property = new EnumProperty<>("enum.valued", Example.THIRD, Example.class);
    property.deprecateValue(Example.THIRD, "Third is deprecated");
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "THIRD"));
    Optional<Example> value = config.getProvidedParsedValue(property);
    Assertions.assertTrue(value.isPresent());
    List<DeprecatedValueUsage> deprecatedUsages = property.checkForDeprecatedValues(value.get());
    Assertions.assertEquals(deprecatedUsages.size(), 1);
    Assertions.assertEquals(deprecatedUsages.get(0).getValue(), "THIRD");
    Assertions.assertEquals(deprecatedUsages.get(0).getInfo().getValueDescription(), "THIRD");
    Assertions.assertEquals(deprecatedUsages.get(0).getInfo().getReason(), "Third is deprecated");
}
Also used : DeprecatedValueUsage(com.synopsys.integration.configuration.property.deprecation.DeprecatedValueUsage) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 12 with PropertyConfiguration

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

the class EnumPropertiesTests method testNullable.

@Test
public void testNullable() throws InvalidPropertyException {
    NullableEnumProperty<Example> property = new NullableEnumProperty<>("enum.nullable", Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.nullable", "ANOTHER"));
    Assertions.assertEquals(Optional.of(Example.ANOTHER), 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)

Example 13 with PropertyConfiguration

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

the class SoftEnumPropertiesTest method testValuedActualValue.

@Test
public void testValuedActualValue() throws InvalidPropertyException {
    SoftEnumProperty<Example> property = new SoftEnumProperty<>("enum.valued", SoftEnumValue.ofEnumValue(Example.ANOTHER), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "THIRD"));
    Assertions.assertEquals(SoftEnumValue.ofEnumValue(Example.THIRD), config.getValue(property));
    PropertyTestHelpUtil.assertAllHelpValid(property, Arrays.asList("THING", "ANOTHER", "THIRD"));
}
Also used : PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 14 with PropertyConfiguration

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

the class SoftEnumPropertiesTest method testList.

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

Example 15 with PropertyConfiguration

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

the class SoftEnumPropertiesTest method testNullableActualValue.

@Test
public void testNullableActualValue() throws InvalidPropertyException {
    NullableSoftEnumProperty<Example> property = new NullableSoftEnumProperty<>("enum.nullable", Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.nullable", "ANOTHER"));
    Assertions.assertEquals(Optional.of(SoftEnumValue.ofEnumValue(Example.ANOTHER)), config.getValue(property));
    PropertyTestHelpUtil.assertAllHelpValid(property, Arrays.asList("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