/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.collection.sets;

import java.io.Serializable;
import java.util.Set;
import java.util.function.Function;
import java.util.regex.Pattern;
import net.ranides.assira.ContractTesters;
import net.ranides.assira.collection.mockup.TMaps;
import net.ranides.assira.test.TCollection;
import net.ranides.assira.test.TWrapper;
import org.junit.Test;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class SetUtilsTest {
    
    @Test
    public void testMap_Projection() {
        TCollection<String> tmap = TMaps.MAP_IS.values();
        
        Function<int[], Set<String>> gf = (Function<int[], Set<String>> & Serializable)(int[] array) -> {
            Set<TWrapper<String>> mmap = new HashSet<>();
            TWrapper.into(mmap, tmap.list(array));
            return SetUtils.map(mmap, TWrapper.projection());
        };
        
        ContractTesters.runner()
            .ignore(Pattern.compile(".*_HC"))
            .param("collection!", tmap)
            .function(new int[0], gf)
			.run();
    }
    
    @Test
    public void testMap_Function() {
        TCollection<String> tmap = TMaps.MAP_IS.values();
        
        Function<int[], Set<String>> gf = (Function<int[], Set<String>> & Serializable)(int[] array) -> {
            Set<TWrapper<String>> mmap = new HashSet<>();
            TWrapper.into(mmap, tmap.list(array));
            return SetUtils.map(mmap, TWrapper.unwrap());
        };
        
        ContractTesters.runner()
            .ignore(Pattern.compile(".*_HC"))
            .ignore("CollectionTester.basicAdd")
            .ignore("CollectionTester.basicAddContains")
            .ignore("SetTester.basicAdd")
            .ignore("SetTester.basicAddReplace")
            .ignore("SetTester.basicPutRandom")
            .param("collection!", tmap)
            .function(new int[0], gf)
			.run();
        
    }
    
}
