1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif;
17
18 import org.junit.Assert;
19 import org.junit.Test;
20 import org.kuali.rice.krad.uif.component.MethodInvokerConfig;
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25
26
27
28
29
30 public class MethodInvokerConfigTest {
31
32 @Test
33 public void testGetArgumentsTypes() {
34
35 checkGetArgumentTypes(TestMethodClass.class, "retrieveTestObject", 0, 1);
36
37 checkGetArgumentTypes(TestMethodClass.class, "retrieveTestObject", 1, 1);
38 checkGetArgumentTypes(TestMethodClass.class, "retrieveTestObject", 2, 2);
39 }
40
41 protected void checkGetArgumentTypes(Class targetClass, String methodName, int argumentTypeSize, int expectedSize) {
42 MethodInvokerConfig methodInvokerConfig = new MethodInvokerConfig();
43 methodInvokerConfig.setTargetClass(targetClass);
44 methodInvokerConfig.setTargetMethod(methodName);
45 methodInvokerConfig.setArguments(new Object[argumentTypeSize]);
46
47 Class[] classes = methodInvokerConfig.getArgumentTypes();
48 Assert.assertEquals("Should return " + argumentTypeSize + " classes", expectedSize, classes.length);
49 }
50
51 private class TestMethodClass {
52
53 public List<Object> retrieveTestObject(String term1) {
54 return new ArrayList<Object>();
55 }
56
57 public List<Object> retrieveTestObject(String term1, String term2) {
58 return new ArrayList<Object>();
59 }
60
61 }
62
63 }