### Question:
ExceptionMapperBase { protected static CharSequence collectErrorMessages(Throwable exception) { StringBuilder messages = new StringBuilder(); collectErrorMessages(messages, exception); return messages; }    }### Answer:
@Test public void collectErrorMessages() { Assert.assertEquals("", ExceptionMapperBase.collectErrorMessages(null).toString()); Assert.assertEquals("", ExceptionMapperBase.collectErrorMessages(new Exception()).toString()); Assert.assertEquals("", ExceptionMapperBase.collectErrorMessages(new Exception((String) null)).toString()); Assert.assertEquals("", ExceptionMapperBase.collectErrorMessages(new Exception(" ")).toString()); Assert.assertEquals("NullPointerException", ExceptionMapperBase.collectErrorMessages(new NullPointerException()) .toString()); Assert.assertEquals("test message", ExceptionMapperBase.collectErrorMessages(new Exception("test message")) .toString()); Assert.assertEquals("test message. Caused by: cause 1. Caused by: cause 2", ExceptionMapperBase .collectErrorMessages(new Exception("test message", new Exception("cause 1", new Exception("cause 2")))) .toString()); Assert.assertEquals("test message. Caused by: NullPointerException", ExceptionMapperBase.collectErrorMessages(new Exception("test message", new NullPointerException())).toString()); }