Search in sources :

Example 1 with DeprecatedValueUsage

use of com.synopsys.integration.configuration.property.deprecation.DeprecatedValueUsage 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 2 with DeprecatedValueUsage

use of com.synopsys.integration.configuration.property.deprecation.DeprecatedValueUsage in project synopsys-detect by blackducksoftware.

the class EnumPropertiesTests method testDeprecatedValue.

@Test
public void testDeprecatedValue() throws InvalidPropertyException {
    EnumProperty<Example> property = new EnumProperty<>("enum.valued", Example.ANOTHER, 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)

Aggregations

PropertyConfiguration (com.synopsys.integration.configuration.config.PropertyConfiguration)2 DeprecatedValueUsage (com.synopsys.integration.configuration.property.deprecation.DeprecatedValueUsage)2 Test (org.junit.jupiter.api.Test)2