JmsMessageIndexer { public void sendMessageToIndexer(final IndexMessage message) { try { jmsTemplateForIndexing.send(messageCreatorFactory.createJmsMessageCreator(message)); turnOnConnectionErrorLog(); } catch (Exception e) { turnOffConnectionErrorLog(e); } }  void sendMessageToIndexer(final IndexMessage message);  }
@Test public void testSendMessageToIndexerShouldSendMessage() { given(messageCreatorFactory.createJmsMessageCreator(message)).willReturn(messageCreator); underTest.sendMessageToIndexer(message); verify(jmsTemplateForIndexing).send(messageCreator); }
@Test public void testSendMessageToIndexerWhenCannotConnectShouldLogError() { Whitebox.setInternalState(underTest, "logger", logger); given(messageCreatorFactory.createJmsMessageCreator(message)).willThrow(new RuntimeException()); underTest.sendMessageToIndexer(message); verify(logger).info(Mockito.anyString(), Mockito.any(Exception.class)); }