zoukankan      html  css  js  c++  java
  • 单表增删改查一套全部自动生成--测试类

    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);
    }





    }

  • 相关阅读:
    Myeclipse 找不到Convert to maven project选项
    myeclipse中disable maven nature
    运行Maven是报错:No goals have been specified for this build
    Maven 工程错误Failure to transfer org.codehaus.plexus:plexus-io:pom:1.0,Failure to transfer org.codehaus.plexus:plexus-archiver:jar:2.0.1
    -Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
    新建web工程Jdk怎么不是自己安装的, 是自带的
    AGC024B Backfront
    AGC037C Numbers on a Circle
    如何看待现在的教育?自己以后怎么做!!!!
    当局者迷
  • 原文地址:https://www.cnblogs.com/21heshang/p/7086170.html
Copyright © 2011-2022 走看看