use of org.jaffa.rules.fieldvalidators.Validator in project jaffa-framework by jaffa-projects.
the class RuleValidatorFactoryTest method testGetValidator.
/**
* Test to verify that the validator factory creates a validator based on class name, realm, and variation.
* Also, verify that the validator is cached.
*
* @throws Exception
*/
@Test
public void testGetValidator() throws Exception {
Validator validator1 = target.getValidator(fakeModel);
assertNotNull(validator1);
Validator validator2 = target.getValidator(fakeModel);
assertNotNull(validator2);
assertSame(validator1, validator2);
}
use of org.jaffa.rules.fieldvalidators.Validator in project jaffa-framework by jaffa-projects.
the class PersistentConfigTest method testFallBackToPersistent.
/**
* Test add fallback pattern to the static context causes the class to initialize
*/
@Test
public void testFallBackToPersistent() throws PreAddFailedException, NoSuchFieldException, IllegalAccessException {
TestPersistentBean persistent = StaticContext.configure(new TestPersistentBean());
Field f = persistent.getClass().getSuperclass().getDeclaredField("validator");
f.setAccessible(true);
Validator validator = (Validator) f.get(persistent);
assertNotNull("bean should be initialized without a config for TestPersistentBean", validator);
}
use of org.jaffa.rules.fieldvalidators.Validator in project jaffa-framework by jaffa-projects.
the class RuleValidatorFactoryTest method testCaching.
/**
* Multiple hits to the same class/realm/variation should return the same instance.
*/
@Test
public void testCaching() {
Validator validator1 = target.getValidator(new FakeModel());
Validator validator2 = target.getValidator(new FakeModel());
assertSame(validator1, validator2);
}
Aggregations