ResultMessages implements Serializable, Iterable<ResultMessage> { @Override public Iterator<ResultMessage> iterator() { return list.iterator(); } ResultMessages(ResultMessageType type);  ResultMessages(ResultMessageType type, ResultMessage... messages); ResultMessageType getType(); List<ResultMessage> getList(); ResultMessages add(ResultMessage message); ResultMessages add(String code); ResultMessages add(String code, Object... args); ResultMessages addAll(ResultMessage... messages); ResultMessages addAll(Collection<ResultMessage> messages); boolean isNotEmpty(); static ResultMessages success(); static ResultMessages info(); @Deprecated static ResultMessages warn(); static ResultMessages warning(); static ResultMessages error(); static ResultMessages danger(); @Override Iterator<ResultMessage> iterator(); @Override String toString(); static final String DEFAULT_MESSAGES_ATTRIBUTE_NAME; }
@Test public void testIterator() { ResultMessage msg1 = ResultMessage.fromCode("foo", "aa"); ResultMessage msg2 = ResultMessage.fromCode("bar", "bb"); ResultMessages messages = new ResultMessages((ResultMessageType) ERROR); messages.addAll(Arrays.asList(msg1, msg2)); List<ResultMessage> result = new ArrayList<ResultMessage>(); for (ResultMessage message : messages) { result.add(message); } assertThat(result, is(Arrays.asList(msg1, msg2))); }