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

import javax.annotation.Resource;
import net.ranides.assira.collection.maps.IntLazyMap;
import net.ranides.assira.test.TMap;
import static net.ranides.assira.junit.NewAssert.*;
import net.ranides.assira.junit.TestContract;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
@SuppressWarnings("element-type-mismatch")
public final class IntLazyMapTester<K,V> {
        
    @Resource(name = "map!")
    private TMap<Integer,V> $var;
    
    @Resource(name = "map.default!")
    private V $default = null;
    
    @TestContract
    public void basicIfPresent(IntLazyMap<V> target) {
        
        $var.item(14).into(target);
        
        assertEquals($var.item(14).value(), target.getIfPresent($var.item(14).keyInt()));
        assertEquals($var.item(14).value(), target.get($var.item(14).keyInt()));

        assertEquals(null, target.getIfPresent($var.item(15).keyInt()));
        
        assertEquals($default, target.get($var.item(16).keyInt()));
    }
        
}
