public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (args == null) args = new Object[0];
for (Iterator i = expectations.iterator(); i.hasNext();) {
Expectation expectation = (Expectation) i.next();
if (expectation.matches(method.getName(), args)) {
return expectation.invoke(proxy, method, args);
}
}
// if we get here we didn't match on any expectations