@Test public void testOnMessageShouldSendResponseToLoggerQueue() throws JMSException { // GIVEN given(objectMessage.getObject()).willReturn(response); given(response.isLoggingEnabled()).willReturn(true); underTest.setMessageLoggingEnabled(true); // WHEN underTest.onMessage(objectMessage); // THEN verify(jmsTemplate).send(loggerQueue, jmsResponseMessageCreator); }
@Test public void testOnMessageShouldCallSequenceManagerToSaveTheResponse() throws JMSException { // GIVEN underTest.setMessageLoggingEnabled(true); given(response.isLoggingEnabled()).willReturn(true); given(objectMessage.getObject()).willReturn(response); // WHEN underTest.onMessage(objectMessage); // THEN verify(manager).tryToSaveResponseIntoSequence(response); }
@Test public void testLogRequestShouldNotSendMessageToQueueWhenSafeGuarded() throws JMSException { // GIVEN given(objectMessage.getObject()).willReturn(response); given(response.isLoggingEnabled()).willReturn(true); underTest.setMessageLoggingEnabled(false); // WHEN underTest.onMessage(objectMessage); // THEN verifyZeroInteractions(jmsTemplate); }
@Test(expectedExceptions = SystemException.class) public void testOnMessageShouldThrowNewRuntimeExceptionWhenCannotGetWilmaResponseFromMessage() throws JMSException { // GIVEN underTest.setMessageLoggingEnabled(true); given(response.isLoggingEnabled()).willReturn(true); given(objectMessage.getObject()).willThrow(new JMSException("exception")); // WHEN underTest.onMessage(objectMessage); // THEN exception should be thrown }
@Test public void testOnMessageShouldDecompressResponse() throws ApplicationException, JMSException { // GIVEN underTest.setFiDecompressionEnabled(true); underTest.setMessageLoggingEnabled(true); given(response.isLoggingEnabled()).willReturn(true); given(objectMessage.getObject()).willReturn(response); // WHEN underTest.onMessage(objectMessage); // THEN verify(messageExtractor).extract(response); }