return newDummy(interfaceClass, "dummy" + Formatting.classShortName(interfaceClass));
}
public static Object newDummy( final Class interfaceClass, final String name ) {
CoreMock mock = new CoreMock(interfaceClass, name);
InvocationMocker mocker = new InvocationMocker();
mocker.addMatcher(new StatelessInvocationMatcher()
{
public boolean matches( Invocation invocation ) {
return invocation.invokedMethod.getDeclaringClass() == interfaceClass;
}
public StringBuffer describeTo( StringBuffer buf ) {
return buf.append("any invokedMethod declared in " + interfaceClass);
}
});
mocker.setStub(new CustomStub("dummy invokedMethod")
{
public Object invoke( Invocation invocation ) throws Throwable {
throw new NotImplementedException(invocation.invokedMethod.getName() + " called on " + name);
}
});