1 /** 2 * Copyright 2010 The Kuali Foundation Licensed under the 3 * Educational Community License, Version 2.0 (the "License"); you may 4 * not use this file except in compliance with the License. You may 5 * obtain a copy of the License at 6 * 7 * http://www.osedu.org/licenses/ECL-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, 10 * software distributed under the License is distributed on an "AS IS" 11 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 * or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package org.kuali.student.common.test.mock; 17 18 import java.util.HashMap; 19 import java.util.Map; 20 21 /** 22 * Use this mapper to set method return for mock proxy to return values you 23 * based on predefined arguments. 24 * 25 * NOTE: Currently only supports single argument methods. 26 */ 27 public class MockArgumentMapper { 28 private Map<Object,Object> argumentMapper; 29 30 public MockArgumentMapper() { 31 super(); 32 argumentMapper = new HashMap<Object, Object>(); 33 } 34 35 /** 36 * 37 * This method returns the return value for the specified arguments 38 * 39 * @param arguments 40 * @return return value for arguments. 41 */ 42 public Object getReturnValue(Object[] arguments){ 43 if (arguments!=null ){ 44 return argumentMapper.get(arguments[0]); 45 } 46 return null; 47 } 48 49 /** 50 * @return the methodReturnMap 51 */ 52 public Map<Object, Object> getArgumentMapper() { 53 return argumentMapper; 54 } 55 56 /** 57 * @param methodReturnMap the methodReturnMap to set 58 */ 59 public void setArgumentMapper(Map<Object, Object> argumentMapper) { 60 this.argumentMapper = argumentMapper; 61 } 62 63 }