| | |
| | | package org.opends.server.admin; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.opends.server.admin.std.meta.RootCfgDefn; |
| | | import org.testng.annotations.*; |
| | | |
| | | import java.util.EnumSet; |
| | |
| | | |
| | | @BeforeClass |
| | | public void setUp() { |
| | | builder = EnumPropertyDefinition.createBuilder("test-property"); |
| | | builder = EnumPropertyDefinition.createBuilder( |
| | | RootCfgDefn.getInstance(), "test-property"); |
| | | builder.setEnumClass(TestEnum.class); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Test |
| | | public void testBuildInstance() { |
| | | EnumPropertyDefinition epd = builder.buildInstance("test-property", |
| | | EnumPropertyDefinition epd = builder.buildInstance( |
| | | RootCfgDefn.getInstance(), "test-property", |
| | | EnumSet.noneOf(PropertyOption.class), |
| | | new UndefinedDefaultBehaviorProvider<TestEnum>()); |
| | | assertEquals(epd.getEnumClass(), TestEnum.class); |
| | |
| | | @Test(expectedExceptions = {IllegalStateException.class}) |
| | | public void testBuildInstance2() { |
| | | EnumPropertyDefinition.Builder<TestEnum> localBuilder = |
| | | EnumPropertyDefinition.createBuilder("test-property"); |
| | | localBuilder.buildInstance("test-property", |
| | | EnumPropertyDefinition.createBuilder( |
| | | RootCfgDefn.getInstance(), "test-property"); |
| | | localBuilder.buildInstance(RootCfgDefn.getInstance(), "test-property", |
| | | EnumSet.noneOf(PropertyOption.class), |
| | | new UndefinedDefaultBehaviorProvider<TestEnum>()); |
| | | } |
| | |
| | | */ |
| | | @Test(dataProvider = "decodeValueData") |
| | | public void testDecodeValue(String value, TestEnum expectedValue) { |
| | | EnumPropertyDefinition epd = builder.buildInstance("test-property", |
| | | EnumPropertyDefinition epd = builder.buildInstance( |
| | | RootCfgDefn.getInstance(), "test-property", |
| | | EnumSet.noneOf(PropertyOption.class), |
| | | new UndefinedDefaultBehaviorProvider<TestEnum>()); |
| | | assertEquals(epd.decodeValue(value), expectedValue); |
| | |
| | | expectedExceptions = {AssertionError.class, |
| | | IllegalPropertyValueStringException.class} ) |
| | | public void testDecodeValue2(String value) { |
| | | EnumPropertyDefinition epd = builder.buildInstance("test-property", |
| | | EnumPropertyDefinition epd = builder.buildInstance( |
| | | RootCfgDefn.getInstance(), "test-property", |
| | | EnumSet.noneOf(PropertyOption.class), |
| | | new UndefinedDefaultBehaviorProvider<TestEnum>()); |
| | | epd.decodeValue(value); |
| | |
| | | */ |
| | | @Test |
| | | public void testNormalizeValue() { |
| | | EnumPropertyDefinition<TestEnum> epd = builder.buildInstance("test-property", |
| | | EnumPropertyDefinition<TestEnum> epd = builder.buildInstance( |
| | | RootCfgDefn.getInstance(), "test-property", |
| | | EnumSet.noneOf(PropertyOption.class), |
| | | new UndefinedDefaultBehaviorProvider<TestEnum>()); |
| | | assertEquals(epd.normalizeValue(TestEnum.ONE), "one"); |
| | |
| | | */ |
| | | @Test |
| | | public void testValidateValue() { |
| | | EnumPropertyDefinition<TestEnum> epd = builder.buildInstance("test-property", |
| | | EnumPropertyDefinition<TestEnum> epd = builder.buildInstance( |
| | | RootCfgDefn.getInstance(), "test-property", |
| | | EnumSet.noneOf(PropertyOption.class), |
| | | new UndefinedDefaultBehaviorProvider<TestEnum>()); |
| | | epd.validateValue(TestEnum.ONE); |