@Test
 public void retryOnOriginalEvent() throws Exception {
   when(mockUntilSuccessfulConfiguration.getFailureExpressionFilter())
       .thenReturn(mockAlwaysTrueFailureExpressionFilter);
   SynchronousUntilSuccessfulProcessingStrategy processingStrategy = createProcessingStrategy();
   when(mockRoute.process(any(MuleEvent.class)))
       .then(
           new Answer<MuleEvent>() {
             @Override
             public MuleEvent answer(InvocationOnMock invocation) throws Throwable {
               MuleEvent argEvent = (MuleEvent) invocation.getArguments()[0];
               assertThat(argEvent.getMessageAsString(), is(TEST_DATA));
               argEvent.getMessage().setPayload(PROCESSED_DATA);
               return argEvent;
             }
           });
   try {
     processingStrategy.route(event);
     fail("processing should throw exception");
   } catch (MessagingException e) {
     assertThat(e, instanceOf(RoutingException.class));
     verify(mockRoute, times(DEFAULT_RETRIES + 1)).process(event);
     verify(mockAlwaysTrueFailureExpressionFilter, times(DEFAULT_RETRIES + 1))
         .accept(any(MuleMessage.class));
   }
 }
 @Test
 public void successfulExecutionWithAckExpression() throws Exception {
   String ackExpression = "some-expression";
   String expressionEvalutaionResult = "new payload";
   event.setMessage(spy(event.getMessage()));
   when(mockUntilSuccessfulConfiguration.getAckExpression()).thenReturn(ackExpression);
   when(mockUntilSuccessfulConfiguration
           .getMuleContext()
           .getExpressionManager()
           .evaluate(ackExpression, event))
       .thenReturn(expressionEvalutaionResult);
   SynchronousUntilSuccessfulProcessingStrategy processingStrategy = createProcessingStrategy();
   when(mockRoute.process(event)).thenReturn(event);
   assertThat(processingStrategy.route(event), is(event));
   verify(mockRoute).process(event);
   verify(mockUntilSuccessfulConfiguration.getMuleContext().getExpressionManager())
       .evaluate(ackExpression, event);
   verify(event.getMessage()).setPayload(expressionEvalutaionResult);
 }
 @Test
 public void alwaysFailUsingFailureExpression() throws MuleException {
   when(mockUntilSuccessfulConfiguration.getFailureExpressionFilter())
       .thenReturn(mockAlwaysTrueFailureExpressionFilter);
   SynchronousUntilSuccessfulProcessingStrategy processingStrategy = createProcessingStrategy();
   try {
     processingStrategy.route(event);
     fail("processing should throw exception");
   } catch (MessagingException e) {
     assertThat(e, instanceOf(RoutingException.class));
     verify(mockRoute, times(DEFAULT_RETRIES + 1)).process(event);
     verify(mockAlwaysTrueFailureExpressionFilter, times(DEFAULT_RETRIES + 1))
         .accept(any(MuleMessage.class));
   }
 }
 @Before
 public void setUp() throws Exception {
   when(mockAlwaysTrueFailureExpressionFilter.accept(any(MuleMessage.class))).thenReturn(true);
   when(mockUntilSuccessfulConfiguration.getRoute()).thenReturn(mockRoute);
   when(mockUntilSuccessfulConfiguration.getAckExpression()).thenReturn(null);
   when(mockUntilSuccessfulConfiguration.getMaxRetries()).thenReturn(DEFAULT_RETRIES);
   when(mockUntilSuccessfulConfiguration.getThreadingProfile()).thenReturn(null);
   when(mockUntilSuccessfulConfiguration.getObjectStore()).thenReturn(null);
   when(mockUntilSuccessfulConfiguration.getDlqMP()).thenReturn(null);
   event = getTestEvent(TEST_DATA);
 }
 @Test(expected = InitialisationException.class)
 public void failWhenDlqIsConfigured() throws Exception {
   when(mockUntilSuccessfulConfiguration.getObjectStore()).thenReturn(mockObjectStore);
   when(mockUntilSuccessfulConfiguration.getDlqMP()).thenReturn(mockRoute);
   createProcessingStrategy();
 }
 @Test(expected = InitialisationException.class)
 public void failWhenThreadingProfileIsConfigured() throws Exception {
   when(mockUntilSuccessfulConfiguration.getThreadingProfile()).thenReturn(mockThreadingProfile);
   createProcessingStrategy();
 }