DefaultTraceLogger implements TraceLogger { @Override public void trace(final Logger logger, final Supplier<String> supplier) { LoggerUtils.trace(logger, supplier); }  @Override void trace(final Logger logger, final Supplier<String> supplier);  }
@Test public void shouldLogAMessageSuppliedByASupplier() throws Exception { final String logMessage = "A log message"; final Logger logger = mock(Logger.class); final Supplier<String> stringSupplier = mock(Supplier.class); when(logger.isTraceEnabled()).thenReturn(true); when(stringSupplier.get()).thenReturn(logMessage); defaultTraceLogger.trace(logger, stringSupplier); verify(logger).trace(logMessage); }
@Test public void shouldDoNothingIfTraceIsNotEnabled() throws Exception { final Logger logger = mock(Logger.class); final Supplier<String> stringSupplier = mock(Supplier.class); when(logger.isTraceEnabled()).thenReturn(false); defaultTraceLogger.trace(logger, stringSupplier); verify(logger, never()).trace(any(String.class)); verifyZeroInteractions(stringSupplier); }