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

flarestar.bdd.assertions.matchers.ContainsAllItemsMatcher Maven / Gradle / Ivy

The newest version!
package flarestar.bdd.assertions.matchers;

import org.hamcrest.Description;

import java.util.Iterator;

/**
 * TODO
 */
public class ContainsAllItemsMatcher extends BaseItemMatcher {
    private boolean checkExact;

    public ContainsAllItemsMatcher(Object[] expectedItems, boolean checkExact) {
        super(expectedItems);

        this.checkExact = checkExact;
    }

    public boolean matches(Object o) {
        for (int i = 0; i != expectedItems.length; ++i) {
            if (!hasItem(o, expectedItems[i])) {
                return false;
            }
        }

        if (checkExact) {
            return getSize(o) == expectedItems.length;
        } else {
            return true;
        }
    }

    public void describeTo(Description description) {
        description.appendText("array or collection containing all values in ");
        description.appendValueList("[", ", ", "]", expectedItems);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy