package net.ranides.assira.collection.query.derived;

import net.ranides.test.CQueryAssert;
import net.ranides.test.mockup.query.CQueryMockup;
import org.junit.Assert;
import org.junit.Test;

import net.ranides.assira.collection.query.CQuery;

import java.util.Arrays;

import static org.junit.Assert.*;

public class CQFilterTest {

    @Test
    public void size() {
        CQuery<Integer> query = CQuery.from()
            .values(1, 2, 3, 4, 5, 6, 7, 8)
            .filter(v -> v % 2 == 0);

        CQueryAssert.assertEquals(Arrays.asList(2, 4, 6, 8), query);

        CQuery<Integer> query2 =
            CQueryMockup.of("each1", Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8))
            .limit(v -> v != 5);

        CQueryAssert.assertEquals(Arrays.asList(1, 2, 3, 4), query2);
    }
}