### Question:
MessageList implements Serializable, Iterable<Message> { public String getText() { return messages.stream() .map(Message::getText) .collect(Collectors.joining("\n")); } MessageList(@NonNull Message... messages); void add(Message message); void add(@CheckForNull MessageList messageList); boolean isEmpty(); int size(); Message getMessage(int index); Optional<Message> getFirstMessage(Severity errorLevel); Optional<Message> getMessageByCode(@CheckForNull String code); MessageList getMessagesByCode(@CheckForNull String code); Optional<Severity> getSeverity(); String getText(); boolean containsErrorMsg(); MessageList getMessagesFor(Object object); MessageList getMessagesFor(Object object, @CheckForNull String property); MessageList getMessagesFor(Object object, @CheckForNull String property, int index); MessageList getMessagesByMarker(@CheckForNull ValidationMarker marker); MessageList getMessagesByMarker(Predicate<ValidationMarker> markerPredicate); MessageList sortBySeverity(); Optional<Message> getMessageWithHighestSeverity(); @Override Iterator<Message> iterator(); void clear(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); Stream<Message> stream(); static Collector<Message, ?, MessageList> collector();  }### Answer:
@Test public void testGetText() { MessageList messageList = new MessageList(Message.newInfo("don't care", "we care"), Message.newError("don't care", "even more")); assertThat(messageList.getText(), is("we care\neven more")); }
@Test public void testGetText_OneMessageList() { MessageList messageList = new MessageList(Message.newInfo("don't care", "we care")); assertThat(messageList.getText(), is("we care")); }
@Test public void testGetText_emptyList_shouldReturnEmptyString() { MessageList emptyMessageList = new MessageList(); assertThat(emptyMessageList.getText(), is(StringUtils.EMPTY)); }