@Test
public void shouldReturnMessage() throws Exception {

    when(jsonObjectEnvelopeConverter.asJsonString(envelope)).thenReturn(MESSAGE_TEXT);
    when(session.createTextMessage(MESSAGE_TEXT)).thenReturn(textMessage);
    when(envelope.metadata()).thenReturn(metadata);
    when(metadata.name()).thenReturn(NAME);
    TextMessage actualTextMessage = envelopeConverter.toMessage(envelope, session);
    assertThat(actualTextMessage, equalTo(textMessage));
    verify(textMessage).setStringProperty(JMS_HEADER_CPPNAME, NAME);
}