@Test
public void testStatsLoggingOnError() {

  DummyOperation operation = mock(DummyOperation.class);
  DummyOperationFactory mutatorFactory = new DummyOperationFactory(operation);
  OperationProcessor processor = new OperationProcessor(mutatorFactory);
  InternalEvent ievent = new InternalEvent("a", null, 1);
  doThrow(new OperationException("Expceted")).when(operation).perform(ievent);
  /*
   * Mock the Stat object
   */
  Stat runtimeStat = mock(Stat.class);
  Stat successStat = mock(Stat.class);
  Stat errorStat = mock(Stat.class);
  processor.setRuntimeStat(runtimeStat);
  processor.setSuccessCountStat(successStat);
  processor.setErrorCountStat(errorStat);
  Stream<InternalEvent> stream = processor.perform(Stream.of(ievent));
  List<InternalEvent> output = stream.collect(Collectors.toList());
  /*
   * Verify start, stop are called, increment error count and never increment success count.
   */
  verify(runtimeStat, times(1)).start();
  verify(runtimeStat, times(1)).stop();
  verify(successStat, never()).increment();
  verify(errorStat, times(1)).increment();
  /*
   * Verify contents of output stream
   */
  assertEquals(0, output.size());
}