Search in sources :

Example 1 with AllNoneEnumListProperty

use of com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty in project synopsys-detect by blackducksoftware.

the class AllNoneListPropertiesTests method testTwoValues.

@Test
public void testTwoValues() throws InvalidPropertyException {
    AllNoneEnumListProperty<Example> property = new AllNoneEnumListProperty<>("enum.valued", new ArrayList<>(), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "thIrd,another"));
    AllNoneEnumList<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 : AllNoneEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with AllNoneEnumListProperty

use of com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty in project synopsys-detect by blackducksoftware.

the class AllNoneListPropertiesTests method testAll.

@Test
public void testAll() throws InvalidPropertyException {
    AllNoneEnumListProperty<Example> property = new AllNoneEnumListProperty<>("enum.valued", new ArrayList<>(), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "ALL"));
    AllNoneEnumList<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 : AllNoneEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 3 with AllNoneEnumListProperty

use of com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty in project synopsys-detect by blackducksoftware.

the class AllNoneListPropertiesTests method testSingleValue.

@Test
public void testSingleValue() throws InvalidPropertyException {
    AllNoneEnumListProperty<Example> property = new AllNoneEnumListProperty<>("enum.valued", new ArrayList<>(), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "thIrd"));
    AllNoneEnumList<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 : AllNoneEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with AllNoneEnumListProperty

use of com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty in project synopsys-detect by blackducksoftware.

the class AllNoneListPropertiesTests method testNone.

@Test
public void testNone() throws InvalidPropertyException {
    AllNoneEnumListProperty<Example> property = new AllNoneEnumListProperty<>("enum.valued", new ArrayList<>(), Example.class);
    PropertyConfiguration config = configOf(Pair.of("enum.valued", "nOnE"));
    AllNoneEnumList<Example> list = config.getValue(property);
    Assertions.assertTrue(list.containsNone());
    Assertions.assertFalse(list.containsAll());
    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 NONE.");
    Assertions.assertEquals(list.representedValues().size(), 0, "No values should be represented by NONE.");
}
Also used : AllNoneEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 5 with AllNoneEnumListProperty

use of com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty in project synopsys-detect by blackducksoftware.

the class AllNoneListPropertiesTests method testUnknownThrows.

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

Aggregations

PropertyConfiguration (com.synopsys.integration.configuration.config.PropertyConfiguration)5 AllNoneEnumListProperty (com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty)5 Test (org.junit.jupiter.api.Test)5