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

import java.io.Serializable;
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.TMap;
import net.ranides.assira.test.TWrapper;
import org.junit.Test;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class IntMapUtilsTest {
    
    @Test
    public void testMap_Projection() {
        TMap<Integer, String> tmap = TMaps.MAP_IS;
        
        Function<int[], IntMap<String>> gf = (Function<int[], IntMap<String>> & Serializable)(int[] array) -> {
            IntMap<TWrapper<String>> mmap = new IntHashMap<>();
            TWrapper.into(mmap, tmap.list(array));
            return IntMapUtils.map(mmap, TWrapper.projection());
        };
        
        ContractTesters.runner()
            .ignore(Pattern.compile(".*_HC"))
            .param("map!", tmap)
            .function(new int[0], gf)
			.run();
        
    }
    
    @Test
    public void testMap_Function() {
        TMap<Integer, String> tmap = TMaps.MAP_IS;
        
        Function<int[], IntMap<String>> gf = (Function<int[], IntMap<String>> & Serializable)(int[] array) -> {
            IntMap<TWrapper<String>> mmap = new IntHashMap<>();
            TWrapper.into(mmap, tmap.list(array));
            return IntMapUtils.map(mmap, TWrapper.unwrap());
        };
        
        ContractTesters.runner()
            .ignore(Pattern.compile(".*_HC"))
            .ignore("MapTester.basicEntrySet_Iterator_SetValue")
            .ignore("MapTester.basicPut")
            .ignore("MapTester.basicPutRandom")
            .ignore("MapTester.basicPutReplace")
            .ignore("IntMapTester.basicEntrySet_Iterator_SetValue")
            .param("map!", tmap)
            .function(new int[0], gf)
			.run();
        
    }
    
}
