package com.github.blahord.bettercollections.util;

import com.github.blahord.bettercollections.PrivateConstructorCaller;
import com.github.blahord.bettercollections.list.ArrayList;
import com.github.blahord.bettercollections.list.ExtensibleList;
import com.github.blahord.bettercollections.list.List;
import org.testng.annotations.Test;

import static com.github.blahord.bettercollections.compatibility.ListWrappers.asJavaUtilList;
import static com.github.blahord.bettercollections.util.Lists.asList;
import static org.assertj.core.api.Java6Assertions.assertThat;

@Test(groups = "unit-tests")
public class PrivateUtilsTest {

    public void testPrivateConstructor() throws Exception {
        PrivateConstructorCaller.callPrivateConstructor(PrivateUtils.class);
    }

    public void testAddFilteredElements() throws Exception {
        final List<? extends Integer> sourceList = asList(3, 6, 8, 5, 1, 4, 2, 0, 9, 7);
        final ExtensibleList<? extends Integer, ? super Integer> targetList = ArrayList.create(asList(1, 2, 3));

        PrivateUtils.addFilteredElements(sourceList, v -> v % 2 == 0, targetList);

        assertThat(asJavaUtilList(targetList)).containsExactly(1, 2, 3, 6, 8, 4, 2, 0);
    }
}