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

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

    @Test
    public void testContract() {
		Supplier<Integer> sup1 = (Serializable & Supplier<Integer>) () -> null;
		Supplier<Integer> sup2 = (Serializable & Supplier<Integer>) () -> 0;
		
        ContractTesters.runner()
			.param("map!", $map)
			.function(new int[0], array -> $map.list(array).into(new LazyMap<>(new AVLTreeMap<>($map.comparator()), sup1)))
			.run();
        ContractTesters.runner()
			.param("map!", $map)
			.param("map.default!", 0)
			.function(new int[0], array -> $map.list(array).into(new LazyMap<>(new AVLTreeMap<>($map.comparator()), sup2)))
			.run();
    }
    
}
