001 /** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.krad.uif; 017 018 import org.junit.Assert; 019 import org.junit.Test; 020 import org.kuali.rice.krad.uif.component.MethodInvokerConfig; 021 022 import java.util.ArrayList; 023 import java.util.List; 024 025 /** 026 * This class MethodInvokerConfig 027 * 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030 public class MethodInvokerConfigTest { 031 032 @Test 033 public void testGetArgumentsTypes() { 034 // if arguments are not set, will select first match 035 checkGetArgumentTypes(TestMethodClass.class, "retrieveTestObject", 0, 1); 036 037 checkGetArgumentTypes(TestMethodClass.class, "retrieveTestObject", 1, 1); 038 checkGetArgumentTypes(TestMethodClass.class, "retrieveTestObject", 2, 2); 039 } 040 041 protected void checkGetArgumentTypes(Class targetClass, String methodName, int argumentTypeSize, int expectedSize) { 042 MethodInvokerConfig methodInvokerConfig = new MethodInvokerConfig(); 043 methodInvokerConfig.setTargetClass(targetClass); 044 methodInvokerConfig.setTargetMethod(methodName); 045 methodInvokerConfig.setArguments(new Object[argumentTypeSize]); 046 047 Class[] classes = methodInvokerConfig.getArgumentTypes(); 048 Assert.assertEquals("Should return " + argumentTypeSize + " classes", expectedSize, classes.length); 049 } 050 051 private class TestMethodClass { 052 053 public List<Object> retrieveTestObject(String term1) { 054 return new ArrayList<Object>(); 055 } 056 057 public List<Object> retrieveTestObject(String term1, String term2) { 058 return new ArrayList<Object>(); 059 } 060 061 } 062 063 }