@Test
public void shouldLogErrorIfExceptionIsThrownWhenLogging() {

    final RuntimeException runtimeException = new RuntimeException();
    when(logger.isDebugEnabled()).thenReturn(true);
    debugLogger.debug(logger, () -> {
        throw runtimeException;
    });
    verify(logger).isDebugEnabled();
    verify(logger).error("Could not generate debug log message", runtimeException);
}