ExceptionLogger implements InitializingBean { protected String formatLogMessage(String exceptionCode, String exceptionMessage) { String bindingExceptionCode = exceptionCode; String bindingExceptionMessage = exceptionMessage; if (StringUtils.isEmpty(bindingExceptionCode)) { bindingExceptionCode = defaultCode; } if (StringUtils.isEmpty(bindingExceptionMessage)) { bindingExceptionMessage = defaultMessage; } String message = MessageFormat.format(logMessageFormat, bindingExceptionCode, bindingExceptionMessage); if (trimLogMessage) { message = message.trim(); } return message; } ExceptionLogger();  ExceptionLogger(String name); void setExceptionCodeResolver(
            ExceptionCodeResolver exceptionCodeResolver); void setExceptionLevelResolver(
            ExceptionLevelResolver exceptionLevelResolver); void setLogMessageFormat(String logMessageFormat); void setTrimLogMessage(boolean trimLogMessage); void setDefaultCode(String defaultCode); void setDefaultMessage(String defaultMessage); @Override void afterPropertiesSet(); void log(Exception ex); void info(Exception ex); void warn(Exception ex); void error(Exception ex);  }
@Test public void testFormatLogMessage_code_and_message_is_notnull() { String code = "code"; String message = "message"; String actualLogMessage = testTarget.formatLogMessage(code, message); String expectedLogMessage = "[" + code + "] " + message; assertThat(actualLogMessage, is(expectedLogMessage)); }
@Test public void testFormatLogMessage_code_is_null() { String code = null; String message = "message"; String actualLogMessage = testTarget.formatLogMessage(code, message); String expectedLogMessage = "[UNDEFINED-CODE] " + message; assertThat(actualLogMessage, is(expectedLogMessage)); }
@Test public void testFormatLogMessage_code_is_empty() { String code = ""; String message = "message"; String actualLogMessage = testTarget.formatLogMessage(code, message); String expectedLogMessage = "[UNDEFINED-CODE] " + message; assertThat(actualLogMessage, is(expectedLogMessage)); }
@Test public void testFormatLogMessage_message_is_null() { String code = "code"; String message = null; String actualLogMessage = testTarget.formatLogMessage(code, message); String expectedLogMessage = "[" + code + "] UNDEFINED-MESSAGE"; assertThat(actualLogMessage, is(expectedLogMessage)); }
@Test public void testFormatLogMessage_message_is_empty() { String code = "code"; String message = ""; String actualLogMessage = testTarget.formatLogMessage(code, message); String expectedLogMessage = "[" + code + "] UNDEFINED-MESSAGE"; assertThat(actualLogMessage, is(expectedLogMessage)); }
@Test public void testFormatLogMessage_code_and_message_is_null() { String code = null; String message = null; String actualLogMessage = testTarget.formatLogMessage(code, message); String expectedLogMessage = "[UNDEFINED-CODE] UNDEFINED-MESSAGE"; assertThat(actualLogMessage, is(expectedLogMessage)); }