JmsIndexMessageCreator implements MessageCreator { @Override public Message createMessage(final Session session) throws JMSException { ObjectMessage message = session.createObjectMessage(); message.setObject(indexMessage); return message; } JmsIndexMessageCreator(final IndexMessage message); @Override Message createMessage(final Session session);  }
@Test public void testCreateMessageShouldSetRequestOnMessage() throws JMSException { given(session.createObjectMessage()).willReturn(objectMessage); underTest.createMessage(session); verify(objectMessage).setObject(indexMessage); }