All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vertexium.test.util.IterableUtils Maven / Gradle / Ivy

There is a newer version: 4.10.0
Show newest version
package org.vertexium.test.util;

import org.vertexium.util.CloseableUtils;

import java.util.Iterator;

import static org.junit.Assert.assertTrue;

public class IterableUtils {
    public static  void assertContains(Object expected, Iterable iterable) {
        StringBuilder found = new StringBuilder();
        boolean first = true;
        Iterator iterator = iterable.iterator();
        try {
            while (iterator.hasNext()) {
                T o = iterator.next();
                if (expected.equals(o)) {
                    return;
                }
                if (!first) {
                    found.append(", ");
                }
                found.append(o);
                first = false;
            }
        } finally {
            CloseableUtils.closeQuietly(iterator);
        }

        assertTrue("Iterable does not contain [" + expected + "], found [" + found + "]", false);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy