IExpectationSetters.andThenExecute
Brought to you by:
tammofreese
Requesting
IExpectationSetters.andThenExecute(Runnable)
Use case:
===
interface MessageContext {
void reply(Object reply);
}
interface Actor {
void processMessage(Object message, MessageContext context);
}
Actor actor = expect(Actor.class);
final Capture<MessageContext> messageContext = new Capture();
actor.processMessage(eq("hello to you"), capture(messageContext));
expectLastCall().andThenExecute(new Runnable() {
void run() {
messageContext.getValue().reply("hello to you too");
}
});
===
Runnable must be called after easymock encounters a call to actor.processMessage().
Note, MessageContext is not a mock, it is real object created by system I'm testing, and I must reply using that MessageContext.