### Question:
MessageList implements Serializable, Iterable<Message> { public Optional<Severity> getSeverity() { return messages.stream() .map(Message::getSeverity) .max(Comparator.comparing(Severity::ordinal)); } 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 testGetSeverity() { MessageList messageList = new MessageList( Message.newInfo(ANY, ANY), Message.newError(ANY, ANY), Message.newWarning(ANY, ANY)); assertThat(messageList.getSeverity(), is(hasValue(Severity.ERROR))); }
@Test public void testGetSeverity_OneSeverity() { MessageList messageList = new MessageList( Message.newInfo(ANY, ANY), Message.newInfo(ANY, ANY)); assertThat(messageList.getSeverity(), is(hasValue(Severity.INFO))); }
@Test public void testGetSeverity_EmptyList() { assertThat(new MessageList().getSeverity(), is(absent())); }