package kr.co.jinwoosi.clfd.clfd.prod.mapper;

import kr.co.jinwoosi.clfd.clfd.prod.model.ProdLike;
import kr.co.jinwoosi.clfd.clfd.prod.model.ProdLikeSearch;
import kr.co.jinwoosi.clfd.conts.prod.service.ProdService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
        "classpath:config/spring/context-datasource.xml",
        "classpath:config/spring/context-mybatis.xml",
        "classpath:config/spring/context-common.xml",
        "classpath:config/spring/context-transaction.xml"
})
public class ProdLikeMapperTest {
    @Autowired
    private ProdLikeMapper prodLikeMapper;


    @Test
    public void insertTest() {
        ProdLike prodLike = new ProdLike();
        prodLike.setProdId(3L);
        prodLike.setUserId(164L);
        prodLikeMapper.insert(prodLike);
    }

    @Test
    public void deleteTest() {
        ProdLike prodLike = new ProdLike();
        prodLike.setProdLikeId(11L);
        prodLikeMapper.delete(prodLike);
    }

    @Test
    public void selecTest() {
        ProdLikeSearch prodLikeSearch = new ProdLikeSearch();
        prodLikeSearch.setProdId(1L);
        prodLikeSearch.setUserId(164L);

        ProdLike prodLike = prodLikeMapper.select(prodLikeSearch);
        System.out.println(prodLike.toString());

        ProdLikeSearch prodLikeSearch1 = new ProdLikeSearch();
        prodLikeSearch1.setProdLikeId(1L);
        ProdLike prodLike1 = prodLikeMapper.select(prodLikeSearch1);
        System.out.println(prodLike1.toString());
    }

    @Test
    public void selectListTest() {
        ProdLikeSearch prodLikeSearch = new ProdLikeSearch();
        prodLikeSearch.setProdId(1L);
        List<ProdLike> prodLikeList = prodLikeMapper.selectList(prodLikeSearch);
        System.out.println(prodLikeList.size());
    }
}
