package com.atlassian.stash.internal.user;

import com.google.common.collect.Iterators;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class InIteratorPredicateTest {

    @Test
    public void testApply() throws Exception {
        InIteratorPredicate<String> predicate = new InIteratorPredicate<String>(
                String.CASE_INSENSITIVE_ORDER,
                Iterators.forArray("A", "AB", "DEF", "XyZ")
        );
        assertTrue(predicate.test("a"));
        assertTrue(predicate.test("A"));
        assertFalse(predicate.test("b"));
        assertTrue(predicate.test("def"));
        assertFalse(predicate.test("zzz"));
        assertFalse(predicate.test("a")); // verify that it really is stateful and requires an ordered iterator
    }
}
