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

import kr.co.jinwoosi.clfd.clfd.dgns.model.DgnsAsk;
import kr.co.jinwoosi.clfd.clfd.dgns.model.DgnsAskSearch;
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 DgnsAskServiceTest {

    @Autowired
    private DgnsAskService dgnsAskService;

    @Test
    public void selectListTest() {
        DgnsAskSearch dgnsAskSearch = new DgnsAskSearch();
        List<DgnsAsk> dgnsAskList = dgnsAskService.selectList(dgnsAskSearch);
        System.out.println(dgnsAskList.size());
    }

    @Test
    public void selectTest() {
        DgnsAskSearch dgnsAskSearch = new DgnsAskSearch();
        dgnsAskSearch.setDgnsAskId(2L);
        DgnsAsk select = dgnsAskService.select(dgnsAskSearch);
        System.out.println(select.toString());
    }

    @Test
    public void selectListWithDgnsAnsTest() {
        List<DgnsAsk> dgnsAskList = dgnsAskService.selectListWithDgnsAns(new DgnsAskSearch());
        System.out.println(dgnsAskList.size());
//        dgnsAskList.forEach(dgnsAsk -> {
//            System.out.println(dgnsAsk.toString());
//            dgnsAsk.getDgnsAnsList().forEach(dgnsAns -> {
//                System.out.println(dgnsAns.toString());
//            });
//        });
    }
}
