What about mock action instead?
@Mock private Action action;
private ActionDispather subject = new ActionDispather(action);
@Test public void doAction1GivenSomeStateIsTrue() throws Throwable {
final Message message = new Message();
message.setState(true);
//message (json object in your case) population is omitted
context.checking(new Expectations() {
{
oneOf(action).doAction1();
}
});
subject.on(message);
}
@Test public void doAction2GivenSomeStateIsFalse() throws Throwable {
final Message message = new Message();
message.setState(false);
//message (json object in your case) population is omitted
context.checking(new Expectations() {
{
oneOf(action).doAction2();
}
});
subject.on(message);
}
The json parsing could be handled in Consumer, therefore the action decision test is json agnostic.
public class Consumer {
private ActionDispatcher dispatcher;
public void on(ActiveMQMessage message) {
Message m = convertFrom(message);
dispatcher.on(m);
}
}
Anyway, mock behavior not data.