| | |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(true); |
| | | DurationPropertyDefinition def = buildTestDefinition(builder); |
| | | def.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | def.decodeValue("unlimited"); |
| | | } |
| | | |
| | | @Test(expectedExceptions = PropertyException.class) |
| | |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(false); |
| | | DurationPropertyDefinition def = buildTestDefinition(builder); |
| | | def.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | def.decodeValue("unlimited"); |
| | | } |
| | | |
| | | @Test(expectedExceptions = PropertyException.class) |
| | |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(false); |
| | | DurationPropertyDefinition def = buildTestDefinition(builder); |
| | | def.validateValue(-1L, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | def.validateValue(-1L); |
| | | } |
| | | |
| | | @DataProvider(name = "validateValueData") |
| | |
| | | builder.setUpperLimit(higherLimitInMillis); |
| | | builder.setAllowUnlimited(isAllowUnlimited); |
| | | DurationPropertyDefinition def = buildTestDefinition(builder); |
| | | def.validateValue(valueInSeconds, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | def.validateValue(valueInSeconds); |
| | | } |
| | | |
| | | @DataProvider(name = "illegalValidateValueData") |
| | |
| | | builder.setUpperLimit(highLimitInMillis); |
| | | builder.setAllowUnlimited(isAllowUnlimited); |
| | | DurationPropertyDefinition def = buildTestDefinition(builder); |
| | | def.validateValue(valueInSeconds, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | def.validateValue(valueInSeconds); |
| | | } |
| | | |
| | | @DataProvider(name = "encodeValueData") |
| | |
| | | builder.setMaximumUnit(DurationUnit.DAYS); |
| | | DurationPropertyDefinition def = buildTestDefinition(builder); |
| | | |
| | | assertThat(def.decodeValue(valueToDecode, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS)). |
| | | assertThat(def.decodeValue(valueToDecode)). |
| | | isEqualTo(expectedValue); |
| | | } |
| | | |
| | |
| | | builder.setLowerLimit(5L); |
| | | builder.setUpperLimit(10L); |
| | | DurationPropertyDefinition def = buildTestDefinition(builder); |
| | | def.decodeValue(valueToDecode, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS); |
| | | def.decodeValue(valueToDecode); |
| | | } |
| | | |
| | | private DurationPropertyDefinition.Builder createTestBuilder() { |