### Question:
LoggingFacade { public void warning(String msg) { if (isWarningEnabled()) { CallerDetails details = inferCaller(); logger.logp(Level.WARNING, details.clazz, details.method, msg); } } LoggingFacade(Logger logger); static Object convertArraysForLogging(Object value, boolean password); void config(String msg); void config(String msg, Object... params); void config(String msg, Throwable thrown); void entering(); void entering(Object... params); void exiting(); void exiting(Object result); void fine(String msg); void fine(String msg, Object... params); void fine(String msg, Throwable thrown); void finer(String msg); void finer(String msg, Object... params); void finer(String msg, Throwable thrown); void finest(String msg); void finest(String msg, Object... params); void finest(String msg, Throwable thrown); Level getLevel(); void setLevel(Level newLevel); String getName(); Logger getUnderlyingLogger(); void info(String msg); void info(String msg, Object... params); void info(LoggingFilter loggingFilter, String msg, Object... params); void info(String msg, Throwable thrown); boolean isConfigEnabled(); boolean isFineEnabled(); boolean isFinerEnabled(); boolean isFinestEnabled(); boolean isInfoEnabled(); boolean isLoggable(Level level); boolean isSevereEnabled(); boolean isWarningEnabled(); void log(Level level, String msg); void log(Level level, String msg, Object... params); void log(Level level, String msg, Throwable thrown); void severe(String msg); void severe(String msg, Object... params); void severe(LoggingFilter loggingFilter, String msg, Object... params); void severe(String msg, Throwable thrown); void severe(LoggingFilter loggingFilter, String msg, Throwable thrown); void throwing(Throwable pending); void warning(String msg); void warning(String msg, Object... params); void warning(LoggingFilter loggingFilter, String msg, Object... params); void warning(String msg, Throwable thrown); void trace(String msg); void trace(String msg, Object... args); ResourceBundle getResourceBundle(); String formatMessage(String msgId, Object... params); static final String TRACE; }### Answer:
@Test public void verifyWarningMessageLoggedIfLoggingFilterIsNull() { loggingFacade.warning((LoggingFilter) null, "msg"); assertThat(mockLogger.isLogpCalled(), is(true)); }
@Test public void verifyWarningMessageLoggedIfLoggingFilterAllows() { final String message = "warning message"; loggingFacade.warning(MockLoggingFilter.createWithReturnValue(true), message); assertThat(mockLogger.isLogpCalled(), is(true)); assertThat(mockLogger.getMessageLevel(), is(Level.WARNING)); assertThat(mockLogger.getMessage(), is(message)); }
@Test public void verifyWarningMessageNotLoggedIfLoggingFilterDenies() { loggingFacade.warning(MockLoggingFilter.createWithReturnValue(false), "msg"); assertThat(mockLogger.isLogpCalled(), is(false)); }