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 kr.co.jinwoosi.clfd.clfd.dgns.model.DgnsDtl;
import kr.co.jinwoosi.clfd.clfd.dgns.model.DgnsDtlSearch;
import kr.co.jinwoosi.clfd.clfd.dgns.vo.DgnsSelection;
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 DgnsServiceTest {

    @Autowired
    private DgnsService dgnsService;
    @Autowired
    private DgnsAskService dgnsAskService;
    @Autowired
    private DgnsDtlService dgnsDtlService;

    @Test
    public void calculateDgnsTotalScoreTest() {
        List<DgnsAsk> dgnsAskList = dgnsAskService.selectListWithDgnsAns(new DgnsAskSearch());
        List<DgnsSelection> dgnsSelectionList = getWtDgnsSelection();
        Double totalScore = dgnsService.calculateDgnsTotalScore("WT", dgnsAskList, dgnsSelectionList);
        System.out.println(totalScore);
    }

    public List<DgnsSelection> getWtDgnsSelection() {
//       wt는 ASK ID가 40~59번까지
        List<DgnsSelection> dgnsSelectionList = new ArrayList<>();
        dgnsSelectionList.add(new DgnsSelection("40", "181")); // 1번
        dgnsSelectionList.add(new DgnsSelection("41", "185")); // 1번
        dgnsSelectionList.add(new DgnsSelection("42", "190")); // 1번
        dgnsSelectionList.add(new DgnsSelection("43", "195")); // 1번
        dgnsSelectionList.add(new DgnsSelection("44", "200")); // 1번
        dgnsSelectionList.add(new DgnsSelection("45", "205")); // 1번
        dgnsSelectionList.add(new DgnsSelection("46", "210")); // 1번
        dgnsSelectionList.add(new DgnsSelection("47", "215")); // 1번
        dgnsSelectionList.add(new DgnsSelection("48", "219")); // 1번
        dgnsSelectionList.add(new DgnsSelection("49", "223")); // 1번
        dgnsSelectionList.add(new DgnsSelection("50", "227")); // 1번
        dgnsSelectionList.add(new DgnsSelection("51", "231")); // 1번
        dgnsSelectionList.add(new DgnsSelection("52", "235")); // 1번
        dgnsSelectionList.add(new DgnsSelection("53", "239")); // 1번
        dgnsSelectionList.add(new DgnsSelection("54", "243")); // 1번
        dgnsSelectionList.add(new DgnsSelection("55", "247")); // 1번
        dgnsSelectionList.add(new DgnsSelection("56", "251")); // 1번
        dgnsSelectionList.add(new DgnsSelection("57", "255")); // 1번
        dgnsSelectionList.add(new DgnsSelection("58", "259")); // 1번
        dgnsSelectionList.add(new DgnsSelection("59", "263")); // 1번
        System.out.println(dgnsSelectionList.size());
        return dgnsSelectionList;
    }

    @Test
    public void findDgnsDtlByScoreTest() {
        DgnsDtl dgnsDtl = dgnsService.findDgnsDtlByScore("WT", dgnsDtlService.selectList(new DgnsDtlSearch()), 50.0);
        System.out.println(dgnsDtl.toString());
    }
}
