@Test
public void logsExceptionTime() {

    final MetricRegistry mockRegistry = mock(MetricRegistry.class);
    final StatementNameStrategy mockNameStrategy = mock(StatementNameStrategy.class);
    final InstrumentedSqlLogger logger = new InstrumentedSqlLogger(mockRegistry, mockNameStrategy);
    final StatementContext mockContext = mock(StatementContext.class);
    final Timer mockTimer = mock(Timer.class);
    final String statementName = "my-fake-name";
    final long fakeElapsed = 1234L;
    when(mockNameStrategy.getStatementName(mockContext)).thenReturn(statementName);
    when(mockRegistry.timer(statementName)).thenReturn(mockTimer);
    when(mockContext.getElapsedTime(ChronoUnit.NANOS)).thenReturn(fakeElapsed);
    logger.logException(mockContext, new SQLException());
    verify(mockTimer).update(fakeElapsed, TimeUnit.NANOSECONDS);
}