package cn.com.qmth.examcloud.core.questions.starter;

import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitNativeRepo;
import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * Created by songyue on 18/1/29.
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class PduNativeTest {

    private static final Logger log = LoggerFactory.getLogger(PduNativeTest.class);

    @Autowired
    private PaperDetailUnitNativeRepo paperDetailUnitNativeRepo;

    @Autowired
    private PaperDetailUnitRepo paperDetailUnitRepo;

    @Test
    public void testFind() {
        long beginTime = System.currentTimeMillis();
        List<PaperDetailUnit> pduList = paperDetailUnitNativeRepo.findByPaperId("591cf69b90994d7427e67008");
        log.info("原生driver共耗时:" + (System.currentTimeMillis() - beginTime) + "ms");
        System.out.printf(pduList.toString());
    }

    @Test
    public void testFind1() {
        long beginTime = System.currentTimeMillis();
        List<PaperDetailUnit> pduList = paperDetailUnitRepo.findByPaperId("591cf69b90994d7427e67008");
        log.info("spring data共耗时:" + (System.currentTimeMillis() - beginTime) + "ms");
        System.out.printf(pduList.toString());
    }
}
