### Question:
MessageList implements Serializable, Iterable<Message> { public MessageList getMessagesFor(Object object) { return getMessagesFor(object, null); } 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 testGetMessagesFor_noObjects_shouldReturnEmptyMessageList() { MessageList messages = new MessageList(Message.newError("code", "msg"), Message.newWarning("code", "msg")) .getMessagesFor(new Object()); assertThat(messages, is(emptyMessageList())); }
@Test public void testGetMessagesFor_objectNull_shouldThrowNullPointerException() { Assertions.assertThrows(NullPointerException.class, () -> { new MessageList(Message.newError("code", "msg"), Message.newWarning("code", "msg")) .getMessagesFor(null); }); }