@Test
 public void cannotInitiateWithNullProcessor() {
   try {
     ProcessorChain.startWith(null);
     fail("No exception thrown!!");
   } catch (NullPointerException e) {
     assertEquals(e.getMessage(), BUNDLE.getMessage("processing.nullProcessor"));
   }
 }
 @Test
 public void cannotChainWithNullProcessor() {
   @SuppressWarnings("unchecked")
   final Processor<MessageProvider, MessageProvider> p = mock(Processor.class);
   try {
     ProcessorChain.startWith(p).chainWith(null);
     fail("No exception thrown!!");
   } catch (NullPointerException e) {
     assertEquals(e.getMessage(), BUNDLE.getMessage("processing.nullProcessor"));
   }
 }
  @Test
  public void noFailureDoesNotTriggerEarlyExit() throws ProcessingException {
    @SuppressWarnings("unchecked")
    final Processor<MessageProvider, MessageProvider> p1 = mock(Processor.class);
    @SuppressWarnings("unchecked")
    final Processor<MessageProvider, MessageProvider> p2 = mock(Processor.class);

    final Processor<MessageProvider, MessageProvider> processor =
        ProcessorChain.startWith(p1).failOnError().chainWith(p2).getProcessor();

    final MessageProvider input = mock(MessageProvider.class);
    final ProcessingReport report = new DummyReport(LogLevel.DEBUG);

    processor.process(report, input);

    verify(p1).process(same(report), any(MessageProvider.class));
    verify(p2).process(same(report), any(MessageProvider.class));
  }
  @Test
  public void failingOnErrorExitsEarly() throws ProcessingException {
    @SuppressWarnings("unchecked")
    final Processor<MessageProvider, MessageProvider> p1 = mock(Processor.class);
    @SuppressWarnings("unchecked")
    final Processor<MessageProvider, MessageProvider> p2 = mock(Processor.class);

    final Processor<MessageProvider, MessageProvider> processor =
        ProcessorChain.startWith(p1).failOnError().chainWith(p2).getProcessor();

    final MessageProvider input = mock(MessageProvider.class);
    final ProcessingReport report = new DummyReport(LogLevel.ERROR);

    try {
      processor.process(report, input);
      fail("No exception thrown!!");
    } catch (ProcessingException e) {
      assertMessage(e.getProcessingMessage())
          .hasMessage(BUNDLE.getMessage("processing.chainStopped"));
    }

    verify(p1).process(same(report), any(MessageProvider.class));
    verify(p2, never()).process(any(ProcessingReport.class), any(MessageProvider.class));
  }