NegNews测试类

package com.winchampion.credit.core2.repository.dao.news;


import java.util.HashMap;
import java.util.List;
import java.util.Map;


import javax.annotation.Resource;


import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;


import com.winchampion.credit.core2.repository.bean.news.NegNew;
import com.winchampion.credit.core2.repository.dao.DaoBaseTest;
import com.winchampion.credit.core2.repository.dao.inlet.news.NegNewDao;


/**
 *  数据访问层Juni单元测试
 * @version 1.0
 * @created 2016-06-23 09:27:16
 * @author Apollo.LiuZhengHai
 */


public class NegNewDaoJunitTestCase extends DaoBaseTest{


    @Resource
private  NegNewDao  negNewDao;
  
  
    @Test
public void init(){
logger.info("初始化NegNew测试数据");
NegNew entity=new NegNew(); 
    entity.setId("id");       
    entity.setKeyword("keyword");       
    entity.setTitle("title");       
    entity.setUrl("url");       
    entity.setPulishTime("pulishTime");       
    entity.setOperateTime("operateTime");       
    entity.setNewsId("newsId");       
    entity.setType("1");
boolean expected=true;
    boolean actual =negNewDao.insertNegNew(entity);
Assert.assertEquals(expected, actual);
}

    @Test
public void destory(){
logger.info("销毁NegNew测试数据");
NegNew negNew=new NegNew(); 
negNew.setKeyword("keyword");
boolean expected=true;
boolean actual =negNewDao.deleteNegNew(negNew);
Assert.assertEquals(expected, actual);
}

     /**
      * 测试  修改一条  (  )  记录
      */
 @Test
 public void testUpdateNegNew(){
 logger.info("修改NegNew测试数据");
 NegNew negNew=new NegNew(); 
      negNew.setId("id");
      negNew.setKeyword("keyword2");
      negNew.setTitle("title2");
      negNew.setUrl("url2");
      negNew.setPulishTime("pulishTime");
      negNew.setOperateTime("operateTime");
      negNew.setNewsId("newsId");
      negNew.setType("1");
  boolean expected=true;
  boolean actual =negNewDao.updateNegNew(negNew);
  Assert.assertEquals(expected, actual);
 }
 



      /**
  * 测试  通过查询参数列表获得 (  )List集合
  */
  @Test
  public void testGetNegNewByParams(){
  logger.info("获取NegNew测试数据 List集合   --注意数据量大的表测试会很慢,自己单元测试的时候按照需求设置查询条件放开测试");
  Map<String,Object> parameterMap=new HashMap<String,Object>();
  boolean expected=false;
  boolean actual =negNewDao.getNegNewByParams(parameterMap).isEmpty();
  Assert.assertEquals(expected, actual) ;
  }




/**
* 测试  通过查询参数列表获得 ( ) List集合[分页 ]
*/
 @Test
 public void testGetNegNewByParamsPage(){
 logger.info("获取NegNew测试数据 List集合[分页 ]");
 Map<String,Object> parameterMap=new HashMap<String,Object>();
      parameterMap.put("id","id");
      parameterMap.put("keyword","keyword");
      parameterMap.put("title","title");
      parameterMap.put("url","url");
      parameterMap.put("pulishTime","pulishTime");
      parameterMap.put("operateTime","operateTime");
      parameterMap.put("newsId","newsId");
      parameterMap.put("type","1");
      List<NegNew> list=negNewDao.getNegNewByParams(parameterMap,0,10,true);
 boolean expected=false;
 boolean actual =list.isEmpty();
 Assert.assertEquals(expected, actual);
 }



/**
* 测试 通过查询参数列表查询 (  ) 总数
*/
 @Test
 public void testCountNegNewByParams(){
 logger.info("条件查询NegNew测试数据总数");
 Map<String,Object> parameterMap=new HashMap<String,Object>();
      parameterMap.put("id","id");
      parameterMap.put("keyword","keyword");
      parameterMap.put("title","title");
      parameterMap.put("url","url");
      parameterMap.put("pulishTime","pulishTime");
      parameterMap.put("operateTime","operateTime");
      parameterMap.put("newsId","newsId");
      parameterMap.put("type","1");
 boolean expected=true;
 boolean actual=negNewDao.countNegNewByParams(parameterMap)>0;
 Assert.assertEquals(expected, actual);
 } 
}

你可能感兴趣的:(NegNews测试类)