Search in sources :

Example 1 with CaseTypeInterceptor

use of org.jaffa.rules.jbossaop.interceptors.CaseTypeInterceptor in project jaffa-framework by jaffa-projects.

the class CaseTypeValidatorTest method testInterceptor.

/**
 * Demonstrate that there's a proper situation for the CaseTypeInterceptor to change the case of the field.
 */
@Test
public void testInterceptor() throws Throwable {
    testModel.setField1(TEST_STRING);
    CaseTypeInterceptor interceptor = new CaseTypeInterceptor();
    interceptor.setTargetClassName(TestModel.class.getName());
    Method method = TestModel.class.getMethod("validate");
    MethodInvocation invocation = new MethodInvocation(new Interceptor[0], 0, method, method, null);
    // "field1" is configured to be UPPER CASE, but is set to all lower case.
    invocation.setTargetObject(testModel);
    interceptor.invoke(invocation);
    assertEquals(TEST_STRING.toUpperCase(), testModel.getField1());
}
Also used : CaseTypeInterceptor(org.jaffa.rules.jbossaop.interceptors.CaseTypeInterceptor) MethodInvocation(org.jboss.aop.joinpoint.MethodInvocation) Method(java.lang.reflect.Method) TestModel(org.jaffa.rules.TestModel) Test(org.junit.Test)

Aggregations

Method (java.lang.reflect.Method)1 TestModel (org.jaffa.rules.TestModel)1 CaseTypeInterceptor (org.jaffa.rules.jbossaop.interceptors.CaseTypeInterceptor)1 MethodInvocation (org.jboss.aop.joinpoint.MethodInvocation)1 Test (org.junit.Test)1