@Test
public void testStatsLoggingOnError() {

  DummyDeserializer mockDeser = mock(DummyDeserializer.class);
  when(mockDeser.deserialize("foo"))
      .thenThrow(new DeserializationException(new RuntimeException("expected")));
  DeserializerProcessor deser = new DeserializerProcessor(mockDeser);
  /*
   * Mock the Stat object
   */
  Stat runtimeStat = mock(Stat.class);
  Stat successStat = mock(Stat.class);
  Stat errorStat = mock(Stat.class);
  deser.setRuntimeStat(runtimeStat);
  deser.setSuccessCountStat(successStat);
  deser.setErrorCountStat(errorStat);
  try {
    deser.deserialize("foo");
  } catch (DeserializationException e) {
    // expected
  }
  /*
   * 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();
}