1 9 package test.ozoneDB.tools.OPP.srcgen.query; 10 11 import org.ozoneDB.tools.OPP.srcgen.ClassQuery; 12 import com.mockobjects.ExpectationMap; 13 import com.mockobjects.Verifiable; 14 import com.mockobjects.util.Verifier; 15 16 import java.util.HashMap ; 17 import java.util.Map ; 18 19 24 public class MockClassQuery implements ClassQuery, Verifiable { 25 private ExpectationMap getInterfacesExpectations = new ExpectationMap("getInterfaces"); 26 private ExpectationMap isInterfaceExpectations = new ExpectationMap("isInterface"); 27 private ExpectationMap isAssignableFrom = new ExpectationMap("isAssignableFrom"); 28 private Map fromClasses = new HashMap (); 29 30 public void setupIsAssignable(String itf, String from, boolean result) { 31 ExpectationMap fromValues; 32 if (!fromClasses.keySet().contains(itf)) { 33 fromValues = new ExpectationMap(itf + " from values"); 34 fromClasses.put(itf, fromValues); 35 isAssignableFrom.addExpected(itf, fromValues); 36 } else { 37 fromValues = (ExpectationMap) fromClasses.get(itf); 38 } 39 fromValues.addExpected(from, Boolean.valueOf(result)); 40 } 41 42 public void setupGetInterfaces(String className, String interfaces[]) { 43 getInterfacesExpectations.addExpected(className, interfaces); 44 } 45 46 public void setupIsInterface(String className, boolean result) { 47 isInterfaceExpectations.addExpected(className, Boolean.valueOf(result)); 48 } 49 50 public boolean isAssignable(String itf, String from) throws ClassNotFoundException { 51 ExpectationMap fromClasses = (ExpectationMap) isAssignableFrom.get(itf); 52 Boolean result = (Boolean ) fromClasses.get(from); 53 return result.booleanValue(); 54 } 55 56 public String [] getInterfaces(String className) throws ClassNotFoundException { 57 return (String []) getInterfacesExpectations.get(className); 58 } 59 60 public boolean isInterface(String className) throws ClassNotFoundException { 61 Boolean result = (Boolean ) isInterfaceExpectations.get(className); 62 return result.booleanValue(); 63 } 64 65 public void verify() { 66 Verifier.verifyObject(this); 67 } 68 } 69 | Popular Tags |