GenericCommandMessage.toString()?

Was it a deliberate design decision to not include a toString() method in GenericCommandMessage that includes the string representation of the underlying command object? If so, I'm curious what the reasons were.

Without that, assertion failure messages from expectDispatchedCommandsEqualTo() in tests are much less useful because they end up looking something like, "Expected MyCommand(foo=bar, frob=nitz) but got GenericCommandMessage@19347a943". You end up having to stop the test in a debugger to see what the actual payload was, which is less than optimal.

My solution locally is to make a copy of GenericCommandMessage (such that it gets used instead of the one from the Axon jar) and add a toString() method. Nothing fancy, just

   @Override
   public String toString() {
     return String.format("%s(%s)", getClass().getSimpleName(), getPayload());
   }

If there's a reason that's a bad idea and I should stop doing it, though, I'll find some other approach.

-Steve

Hi Steven,

I don’t think there is a specific reason. It should work fine with a toString, so I guess that’s what we’re going to add :wink:
Thanks for reporting!

Cheers,

Allard