• 单表增删改查一套全部自动生成--测试类


    package service;

    import java.util.Date;
    import java.util.List;

    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 com.eaju.bos.dao.mapper.DownloadCenterMapper;
    import com.eaju.bos.entity.DownloadCenter;
    import com.eaju.bos.entity.DownloadCenterExample;
    import com.eaju.bos.entity.DownloadCenterExample.Criteria;

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration("/spring/spring-config.xml")
    public class DownloadCenterServiceTest {

    @Autowired
    private DownloadCenterMapper downloadCenterMapper;

    //增 success
    @Test
    public void testInsert(){

    DownloadCenterExample record = new DownloadCenterExample();
    Criteria createCriteria = record.createCriteria();
    createCriteria.andCreateTimeEqualTo(new Date());
    DownloadCenter downloadCenter = new DownloadCenter();
    downloadCenter.setCreateTime(new Date());
    downloadCenter.setCreator("shun");
    downloadCenter.setOperateStatus("2");
    downloadCenter.setOperateResult("success");
    downloadCenter.setRemark("test");
    downloadCenter.setDownloadUrl("http://127.0.0.1:8083/bos/downloadCenter/test0627.txt");
    int insertSelective = downloadCenterMapper.insertSelective(downloadCenter);
    System.out.println(insertSelective);
    }

    //删 success
    @Test
    public void testDelete(){

    DownloadCenterExample example = new DownloadCenterExample();
    Criteria criteria = example.createCriteria();
    criteria.andIdEqualTo(4);
    int deleteByExample = downloadCenterMapper.deleteByExample(example);
    System.out.println(deleteByExample);
    }

    //改 success
    @Test
    public void testUpdate(){

    DownloadCenterExample example = new DownloadCenterExample();
    DownloadCenter record = new DownloadCenter();
    Criteria criteria = example.createCriteria();
    criteria.andOperateStatusEqualTo("1");
    record.setRemark("test update case");
    record.setCreateTime(new Date());
    int updateByExample = downloadCenterMapper.updateByExampleSelective(record, example);
    System.out.println(updateByExample);
    }

    //查 success
    @Test
    public void testSelect(){
    DownloadCenterExample example = new DownloadCenterExample();
    Criteria criteria = example.createCriteria();
    criteria.andOperateStatusEqualTo("1");
    List<DownloadCenter> selectByExample = downloadCenterMapper.selectByExample(example);
    System.out.println(selectByExample);
    }





    }

  • 相关阅读:
    与大神聊天1h
    《海上钢琴师》观后感
    《小王子》读书笔记
    Joining Data with dplyr in R
    SQL学习笔记1
    电影《受益人》观后感
    markdown文本编辑学习笔记2
    importing-cleaning-data-in-r-case-studies
    一个测试人员的工作该怎么开展
    测试总结报告
  • 原文地址:https://www.cnblogs.com/21heshang/p/7086170.html
Copyright © 2020-2023  润新知