Search in sources :

Example 16 with TestModel

use of org.jaffa.rules.TestModel in project jaffa-framework by jaffa-projects.

the class MaxValueValidatorTest method testNoFailure.

/**
 * If the one rule is satisfied, there should be no validation exception.
 */
@Test
public void testNoFailure() throws ApplicationException, FrameworkException {
    TestModel testModel = new TestModel();
    // max value not exceeded
    testModel.setField2(7);
    targetMaxValue.validate(testModel);
}
Also used : TestModel(org.jaffa.rules.TestModel) Test(org.junit.Test)

Example 17 with TestModel

use of org.jaffa.rules.TestModel in project jaffa-framework by jaffa-projects.

the class MaxValueValidatorTest method testValidator.

/**
 * If the field value is to large, the validator should throw a exceeds max exception with the field label.
 */
@Test
public void testValidator() throws ApplicationException, FrameworkException {
    TestModel testModel = new TestModel();
    // max value is exceeded
    testModel.setField2(13);
    executeValidator(targetMaxValue, testModel, "[Field2]", ExceedsMaximumException.class);
}
Also used : TestModel(org.jaffa.rules.TestModel) Test(org.junit.Test)

Example 18 with TestModel

use of org.jaffa.rules.TestModel in project jaffa-framework by jaffa-projects.

the class MaxValueValidatorTest method testInterceptor.

/**
 * Demonstrate that there's a proper situation for the MaxValueInterceptor to throw.
 */
@Test
public void testInterceptor() throws Throwable {
    TestModel testModel = new TestModel();
    // max value is exceeded
    testModel.setField2(13);
    executeInterceptor(MaxValueInterceptor.class, testModel, "[Field2]", ExceedsMaximumException.class);
}
Also used : TestModel(org.jaffa.rules.TestModel) Test(org.junit.Test)

Example 19 with TestModel

use of org.jaffa.rules.TestModel in project jaffa-framework by jaffa-projects.

the class MinLengthValidatorTest method testValidator.

/**
 * If the field length is to short, the validator should throw a too much data field exception with the field label.
 */
@Test
public void testValidator() throws ApplicationException, FrameworkException {
    TestModel testModel = new TestModel();
    // min length is exceeded
    testModel.setField1("1");
    executeValidator(targetMinLength, testModel, "[Field1]", TooLittleDataException.class);
}
Also used : TestModel(org.jaffa.rules.TestModel) Test(org.junit.Test)

Example 20 with TestModel

use of org.jaffa.rules.TestModel in project jaffa-framework by jaffa-projects.

the class MinLengthValidatorTest method testNoFailure.

/**
 * If the one rule is satisfied, there should be no validation exception.
 */
@Test
public void testNoFailure() throws ApplicationException, FrameworkException {
    TestModel testModel = new TestModel();
    // not below min length
    testModel.setField1("123");
    targetMinLength.validate(testModel);
}
Also used : TestModel(org.jaffa.rules.TestModel) Test(org.junit.Test)

Aggregations

TestModel (org.jaffa.rules.TestModel)22 Test (org.junit.Test)22 Method (java.lang.reflect.Method)3 MethodInvocation (org.jboss.aop.joinpoint.MethodInvocation)3 RuleMetaData (org.jaffa.rules.meta.RuleMetaData)2 IRuleEvaluator (org.jaffa.rules.rulemeta.IRuleEvaluator)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 FakeModel (org.jaffa.persistence.FakeModel)1 AbstractRuleInterceptor (org.jaffa.rules.jbossaop.interceptors.AbstractRuleInterceptor)1 CaseTypeInterceptor (org.jaffa.rules.jbossaop.interceptors.CaseTypeInterceptor)1 CommentInterceptor (org.jaffa.rules.jbossaop.interceptors.CommentInterceptor)1 InitializeInterceptor (org.jaffa.rules.jbossaop.interceptors.InitializeInterceptor)1