首页 > 其他分享 >使用Jmockit 测试 spring + mybatis plus 项目 - CRUD Mapper 查询样例

使用Jmockit 测试 spring + mybatis plus 项目 - CRUD Mapper 查询样例

时间:2023-02-22 17:35:31浏览次数:35  
标签:Jmockit Mapper 00 service spring List Lists progress import

Jmockit 1.46+ junit4

package xxx;XXXProgress

import xxx;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.google.common.collect.Lists;
import mockit.Expectations;
import mockit.Injectable;
import mockit.Tested;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

@RunWith(SpringRunner.class)
public class XXXProgressServiceTest {

    @Tested
    XXXProgressService service=new XXXProgressServiceImpl();

    @Injectable
    private WindDataMapper windDataMapper;

    @Injectable
    private XXXProgressMapper XXXProgressMapper;



    @Test
    public void genProgressDay(@Tested XXXProgress progress) {
        List<Timestamp> aTradeDays = Lists.newArrayList(Timestamp.valueOf("1999-2-11 00:00:00"));
        List<Timestamp> hkTradeDays=Lists.newArrayList(Timestamp.valueOf("1999-7-11 00:00:00"));
        progress.setNote("note");
        progress.setXXXDay(20);
        progress.setXXXId(BigDecimal.TEN);
        progress.setXXXStatus("true");
        List<XXXProgress> list=Lists.newArrayList(progress);
        new Expectations(service){{
            windDataMapper.getXXXCalendars("XXX","20120101","20130101");
            result=aTradeDays;
            windDataMapper.getXXXCalendars("SSS","20120101","20130101");
            result=hkTradeDays;
            XXXProgressMapper.selectList((Wrapper<XXXProgress>) any);
            result=list;
        }};
        service.genProgressDay("20120101","20130101");
    }

}

标签:Jmockit,Mapper,00,service,spring,List,Lists,progress,import
From: https://www.cnblogs.com/funkboy/p/17145222.html

相关文章