### Question:
Exceptions { public static String condenseThrowableMessage(Throwable t) { StringBuilder condensedMessageBuilder = new StringBuilder(); condensedMessageBuilder.append(t.getMessage()); Throwable current = t.getCause(); while (current != null) { String currMessage = current.getMessage(); if (currMessage != null && currMessage.length() != 0) { condensedMessageBuilder.append(CONDENSE_COMBINER_STRING); condensedMessageBuilder.append(currMessage); } current = current.getCause(); } return condensedMessageBuilder.toString(); }  static String condenseThrowableMessage(Throwable t); static final String CONDENSE_COMBINER_STRING; }### Answer:
@Test public void testCondenseMultipleExceptions() { String m1 = "m1"; String m2 = "m2"; String m3 = "m3"; Exception e1 = new Exception(m1); Exception e2 = new Exception(m2, e1); Exception e3 = new Exception(m3, e2); String expected = m3 + Exceptions.CONDENSE_COMBINER_STRING + m2 + Exceptions.CONDENSE_COMBINER_STRING + m1; String condensedMessage = Exceptions.condenseThrowableMessage(e3); Assert.assertEquals(expected, condensedMessage); }
@Test public void testCondenseExceptionWithNullMessage() { String m1 = "m1"; String m2 = null; String m3 = "m3"; Exception e1 = new Exception(m1); Exception e2 = new Exception(m2, e1); Exception e3 = new Exception(m3, e2); String expected = m3 + Exceptions.CONDENSE_COMBINER_STRING + m1; String condensedMessage = Exceptions.condenseThrowableMessage(e3); Assert.assertEquals(expected, condensedMessage); }
@Test public void testCondenseExceptionWithEmptyMessage() { String m1 = "m1"; String m2 = ""; String m3 = "m3"; Exception e1 = new Exception(m1); Exception e2 = new Exception(m2, e1); Exception e3 = new Exception(m3, e2); String expected = m3 + Exceptions.CONDENSE_COMBINER_STRING + m1; String condensedMessage = Exceptions.condenseThrowableMessage(e3); Assert.assertEquals(expected, condensedMessage); }