package kr.co.jinwoosi.clfd.clfd.dgns.service;

import kr.co.jinwoosi.clfd.clfd.dgns.model.DgnsDtl;
import kr.co.jinwoosi.clfd.clfd.dgns.model.DgnsDtlSearch;
import kr.co.jinwoosi.clfd.clfd.dgns.model.SkTy;
import kr.co.jinwoosi.clfd.clfd.dgns.model.SkTySearch;
import org.junit.Assert;
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.ArrayList;
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 SkTyServiceTest {

    @Autowired
    private SkTyService skTyService;
    @Autowired
    private DgnsDtlService dgnsDtlService;

    @Test
    public void selectListTest() {
        skTyService.selectList(new SkTySearch()).forEach(skTy -> System.out.println(skTy.toString()));
    }

    @Test
    public void selectSkTyByDgnsDtlList() {
        List<DgnsDtl> dgnsDtlList = new ArrayList<>();
        dgnsDtlList.add(dgnsDtlService.select(new DgnsDtlSearch(1L)));
        dgnsDtlList.add(dgnsDtlService.select(new DgnsDtlSearch(5L)));
        dgnsDtlList.add(dgnsDtlService.select(new DgnsDtlSearch(9L)));
        dgnsDtlList.add(dgnsDtlService.select(new DgnsDtlSearch(11L)));
        SkTy skTy = skTyService.selectSkTyByDgnsDtlList(dgnsDtlList);
        System.out.println(skTy.toString());
    }

    @Test
    public void getCashedSkTyListTest() {
        List<SkTy> cashedSkTyList = skTyService.getCashedSkTyList(false);
        Assert.assertEquals(16, cashedSkTyList.size());
    }
}
