use of org.apache.sling.validation.impl.util.examplevalidators.StringValidator in project sling by apache.
the class ValidatorMapTest method testPutValidatorWithSameValidatorIdAndHigherRanking.
@Test
public void testPutValidatorWithSameValidatorIdAndHigherRanking() {
Map<String, Object> validatorProperties = new HashMap<>();
validatorProperties.put(Validator.PROPERTY_VALIDATOR_ID, DATE_VALIDATOR_ID);
validatorProperties.put(Validator.PROPERTY_VALIDATOR_SEVERITY, 2);
Mockito.doReturn(1).when(newValidatorServiceReference).compareTo(Mockito.anyObject());
Validator<String> stringValidator = new StringValidator();
validatorMap.put(validatorProperties, stringValidator, newValidatorServiceReference);
Assert.assertEquals(new ValidatorMetadata(stringValidator, newValidatorServiceReference, 2), validatorMap.get(DATE_VALIDATOR_ID));
}
use of org.apache.sling.validation.impl.util.examplevalidators.StringValidator in project sling by apache.
the class ValidatorTypeUtilTest method testGetValidatorTypeOfDirectImplementations.
@SuppressWarnings("unchecked")
@Test
public void testGetValidatorTypeOfDirectImplementations() {
Assert.assertThat((Class<String>) ValidatorTypeUtil.getValidatorType(new RegexValidator()), Matchers.equalTo(String.class));
Assert.assertThat((Class<String>) ValidatorTypeUtil.getValidatorType(new StringValidator()), Matchers.equalTo(String.class));
Assert.assertThat((Class<Integer>) ValidatorTypeUtil.getValidatorType(new IntegerValidator()), Matchers.equalTo(Integer.class));
}
use of org.apache.sling.validation.impl.util.examplevalidators.StringValidator in project sling by apache.
the class ValidatorMapTest method testPutValidatorWithSameValidatorIdAndLowerRanking.
@Test
public void testPutValidatorWithSameValidatorIdAndLowerRanking() {
Map<String, Object> validatorProperties = new HashMap<>();
validatorProperties.put(Validator.PROPERTY_VALIDATOR_ID, DATE_VALIDATOR_ID);
validatorProperties.put(Validator.PROPERTY_VALIDATOR_SEVERITY, 2);
Mockito.doReturn(-1).when(newValidatorServiceReference).compareTo(Mockito.anyObject());
Validator<String> stringValidator = new StringValidator();
validatorMap.put(validatorProperties, stringValidator, newValidatorServiceReference);
Assert.assertEquals(new ValidatorMetadata(dateValidator, validatorServiceReference, 10), validatorMap.get(DATE_VALIDATOR_ID));
}
Aggregations