Search in sources :

Example 6 with TestModel

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

the class MaxLengthValidatorTest method testInterceptor.

/**
 * Demonstrate that there's a proper situation for the MaxLengthInterceptor to throw.
 */
@Test
public void testInterceptor() throws Throwable {
    TestModel testModel = new TestModel();
    // max length is exceeded
    testModel.setField1("1234567891011");
    executeInterceptor(MaxLengthInterceptor.class, testModel, "[Field1]", TooMuchDataException.class);
}
Also used : TestModel(org.jaffa.rules.TestModel) Test(org.junit.Test)

Example 7 with TestModel

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

the class MinLengthValidatorTest method testInterceptor.

/**
 * Demonstrate that there's a proper situation for the MaxLengthInterceptor to throw.
 */
@Test
public void testInterceptor() throws Throwable {
    TestModel testModel = new TestModel();
    // min length is exceeded
    testModel.setField1("1");
    executeInterceptor(MinLengthInterceptor.class, testModel, "[Field1]", TooLittleDataException.class);
}
Also used : TestModel(org.jaffa.rules.TestModel) Test(org.junit.Test)

Example 8 with TestModel

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

the class MinValueValidatorTest method testValidator.

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

Example 9 with TestModel

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

the class MinValueValidatorTest method testInterceptor.

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

Example 10 with TestModel

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

the class FieldInitializerTest method testInitializer.

/**
 * Tests the initializer rule sets the property value
 */
@Test
public void testInitializer() throws FrameworkException {
    TestModel testModel = new TestModel();
    assertNull(testModel.getField1());
    target.initialize(testModel);
    // test when member parameter is not provided
    assertEquals(FIELD1_INIT_VALUE, testModel.getField1());
    // test when member parameter is provided
    assertEquals(FIELD2_INIT_VALUE, testModel.getField2());
}
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