DefaultJmsMessageLoggerHelper implements JmsMessageLoggerHelper { @Override public String toJmsTraceString(final Message message) { try { return metadataAsJsonObject((TextMessage) message).toString(); } catch (Exception e) { return "Could not find: _metadata in message"; } }  @Override String toJmsTraceString(final Message message); @Override JsonObject metadataAsJsonObject(final TextMessage message);  }
@SuppressWarnings("unchecked") @Test public void shouldReturnErrorMessageOnError() throws JMSException { when(message.getText()).thenThrow(JMSException.class); assertThat(jmsMessageLoggerHelper.toJmsTraceString(message), containsString("Could not find: _metadata in message")); }