Search in sources :

Example 1 with DateValidator

use of org.apache.sling.validation.impl.util.examplevalidators.DateValidator in project sling by apache.

the class ValidationServiceImplTest method setUp.

@Before
public void setUp() throws LoginException, PersistenceException, RepositoryException {
    validationService = new ValidationServiceImpl();
    validationService.searchPaths = Arrays.asList(context.resourceResolver().getSearchPath());
    validationService.configuration = configuration;
    Mockito.doReturn(20).when(configuration).defaultSeverity();
    validationService.resourceBundleProviders = Collections.singletonList(resourceBundleProvider);
    Mockito.doReturn(defaultResourceBundle).when(resourceBundleProvider).getResourceBundle(Mockito.anyObject());
    modelBuilder = new ValidationModelBuilder();
    propertyBuilder = new ResourcePropertyBuilder();
    dateValidator = new DateValidator();
    Mockito.doReturn(1l).when(providingBundle).getBundleId();
    Mockito.doReturn(providingBundle).when(validatorServiceReference).getBundle();
    Mockito.doReturn(providingBundle).when(newValidatorServiceReference).getBundle();
    validationService.validatorMap.put(DATE_VALIDATOR_ID, dateValidator, validatorServiceReference, 10);
    validationService.validatorMap.put(REGEX_VALIDATOR_ID, new RegexValidator(), validatorServiceReference, 10);
    validationService.modelRetriever = modelRetriever;
}
Also used : DateValidator(org.apache.sling.validation.impl.util.examplevalidators.DateValidator) RegexValidator(org.apache.sling.validation.impl.validators.RegexValidator) ResourcePropertyBuilder(org.apache.sling.validation.impl.model.ResourcePropertyBuilder) ValidationModelBuilder(org.apache.sling.validation.impl.model.ValidationModelBuilder) Before(org.junit.Before)

Example 2 with DateValidator

use of org.apache.sling.validation.impl.util.examplevalidators.DateValidator in project sling by apache.

the class ValidatorMapTest method setUp.

@Before
public void setUp() {
    validatorMap = new ValidatorMap();
    dateValidator = new DateValidator();
    Mockito.doReturn("some name").when(providingBundle).getSymbolicName();
    Mockito.doReturn(providingBundle).when(validatorServiceReference).getBundle();
    Mockito.doReturn(providingBundle).when(newValidatorServiceReference).getBundle();
    validatorMap.put(DATE_VALIDATOR_ID, dateValidator, validatorServiceReference, 10);
}
Also used : DateValidator(org.apache.sling.validation.impl.util.examplevalidators.DateValidator) Before(org.junit.Before)

Aggregations

DateValidator (org.apache.sling.validation.impl.util.examplevalidators.DateValidator)2 Before (org.junit.Before)2 ResourcePropertyBuilder (org.apache.sling.validation.impl.model.ResourcePropertyBuilder)1 ValidationModelBuilder (org.apache.sling.validation.impl.model.ValidationModelBuilder)1 RegexValidator (org.apache.sling.validation.impl.validators.RegexValidator)1