/*
 * @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.Map;
import java.util.function.Supplier;
import java.util.regex.Pattern;
import net.ranides.assira.ContractTesters;
import net.ranides.assira.collection.lookups.AVLTreeLookup;
import net.ranides.assira.collection.mockup.TMaps;
import net.ranides.assira.test.TMap;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class IntLazyMapTest {
    
    private final TMap<Integer, String> $map = TMaps.MAP_IS;

    @Test
    public void testContract() {
		Supplier<String> sup1 = (Serializable & Supplier<String>) () -> null;
		Supplier<String> sup2 = (Serializable & Supplier<String>) () -> "1";
		
        ContractTesters.runner()
			.ignore(Pattern.compile(".*_HC"))
			.param("map!", $map)
			.function(new int[0], array -> $map.list(array).into(newmap($map, sup1)))
			.run();
        ContractTesters.runner()
			.ignore(Pattern.compile(".*_HC"))
			.param("map!", $map)
			.param("map.default!", "1")
            .function(new int[0], array -> $map.list(array).into(newmap($map, sup2)))
			.run();
        assertTrue(true);
    }
    
    private static IntMap<String> newmap(TMap<Integer, String> map, Supplier<String> sup) {
        return new IntLazyMap<>(new IntAVLTreeMap<>(map.comparator()), sup);
    }
    
}
