### Question:
IntercomException extends RuntimeException { public static String getMessage(ErrorCollection errorCollection) { String message = "Could not read error message from server"; if(errorCollection!=null && errorCollection.getErrors() != null && errorCollection.getErrors().size() > 0 && errorCollection.getErrors().get(0) != null && errorCollection.getErrors().get(0).getMessage() != null){ message = errorCollection.getErrors().get(0).getMessage(); } return message; } @SuppressWarnings("WeakerAccess")  IntercomException(String message);  IntercomException(String message, Throwable cause);  IntercomException(ErrorCollection errorCollection); @SuppressWarnings("WeakerAccess")  IntercomException(ErrorCollection errorCollection, Throwable cause); static String getMessage(ErrorCollection errorCollection); ErrorCollection getErrorCollection(); Error getFirstError();  }### Answer:
@Test public void testNullCollection() { assertEquals("Could not read error message from server", IntercomException.getMessage(null)); }
@Test public void testBlankCollection() { ErrorCollection ec = new ErrorCollection(); assertEquals("Could not read error message from server", IntercomException.getMessage(ec)); }
@Test public void testEmptyCollection() { try { new ErrorCollection(Lists.<Error>newArrayList()); fail(); } catch (IllegalArgumentException e) { } final ErrorCollection ec = new ErrorCollection(Lists.newArrayList(new Error())); assertEquals("Could not read error message from server", IntercomException.getMessage(ec)); }