package cn.bdqn.mhouse.dao.impl;
import static org.junit.Assert.*;
import java.util.Date;
import java.util.List;
import org.junit.Test;
import cn.bdqn.mhouse.dao.IHouseDao;
import cn.bdqn.mhouse.entity.District;
import cn.bdqn.mhouse.entity.House;
import cn.bdqn.mhouse.entity.HouseCondition;
import cn.bdqn.mhouse.entity.Street;
import cn.bdqn.mhouse.entity.Types;
import cn.bdqn.mhouse.entity.Users;
import cn.bdqn.mhouse.util.Page;
/**
*
*
* 项目名称:mhouse
* 类名称:HouseDaoMybatisImplTest
* 类描述: 测试房屋信息的测试类
* 创建人:Mu Xiongxiong
* 创建时间:2017-3-15 下午8:20:44
* 修改人:Mu Xiongxiong
* 修改时间:2017-3-15 下午8:20:44
* 修改备注:
* @version
*
*/
public class HouseDaoMybatisImplTest {
IHouseDao houseDao=new HouseDaoMybatisImpl();
HouseCondition houseC=new HouseCondition();
District district=new District();
House house=new House();
Users users=new Users();
Types types=new Types();
Street street=new Street();
/**
*
* @Title: testInsert
* @Description: 该方法的主要作用:
* @param 设定文件
* @return 返回类型:void
* @throws
*/
@Test
public void testInsert() {
users.setId(1000);
types.setId(1000);
street.setId(1000);
house.setUsers(users);
house.setStreet(street);
house.setTypes(types);
house.setContact("穆雄雄");
house.setDescription("描述");
house.setFloorage(50);
house.setPrice(2500F);
house.setPubdate(new Date());
house.setTitle("标题");
int rel=houseDao.insert(house);
if(rel>0){
System.out.println("添加成功!");
}else {
System.out.println("添加失败!");
}
}
/**
*
* @Title: reCount
* @Description: 该方法的主要作用:动态查询总记录数
* @param 设定文件
* @return 返回类型:void
* @throws
*/
@Test
public void reCount(){
houseC.setPriceBegin(50);
houseC.setPriceEnd(4000);
houseC.setFloorageBegin(10);
houseC.setFloorageEnd(6000);
types.setId(1000);
houseC.setTypes(types);
street.setId(1000);
houseC.setStreet(street);
int count=houseDao.reCount(houseC);
System.out.println("总记录数:"+count);
}
/**
*
* @Title: reCount
* @Description: 该方法的主要作用:分页查询房屋信息
* @param 设定文件
* @return 返回类型:void
* @throws
*/
@Test
public void getHouseInfoByDymanic(){
Page page=new Page();
// houseC.setPriceBegin(50); //起始价格
// houseC.setPriceEnd(4000); //结束价格
// houseC.setFloorageBegin(10); //起始面积
// houseC.setFloorageEnd(6000); //最终面积
types.setId(1003); //房屋类型
houseC.setTypes(types);
street.setId(1003); //所在的街道
// //street.setDistrict(district);
houseC.setStreet(street);
int pageIndex=3;
page=houseDao.getHouseInfoByDymanic(houseC, pageIndex);
System.out.println("当前页是:"+page.getPageIndex());
System.out.println("下一页是:"+page.getNextPage());
System.out.println("上一页是:"+page.getPrePage());
System.out.println("总记录数:"+page.getRecord());
System.out.println("总页数是:"+page.getTotalPageCount());
System.out.println("页大小是:"+page.getPageSize());
List<House> houselist=page.getHouseList();
for (House house : houselist) {
System.out.println("房屋标题:"+house.getTitle());
}
}
/**
*
* @Title: testGetHouseInfo
* @Description: 查询所有的房屋
* @param 设定文件
* @return void 返回类型
* @throws
*/
@Test
public void testGetHouseInfo(){
Page page=houseDao.getHouseInfo();
List<House> housel=page.getHouseList();
for (House house : housel) {
System.out.println(house.getTitle());
}
}
/**
*
* @Title: testGetAllHousePage
* @Description: 该方法的主要作用:测试分页查询房屋信息
* @param 设定文件
* @return 返回类型:void
* @throws
*/
@Test
public void testGetAllHousePage(){
Page page=houseDao.getHousePage(1); //当前第一页
System.out.println("=====================test===================");
System.out.println("当前页是:"+page.getPageIndex());
System.out.println("下一页是:"+page.getNextPage());
System.out.println("上一页是:"+page.getPrePage());
System.out.println("总记录数:"+page.getRecord());
System.out.println("总页数是:"+page.getTotalPageCount());
System.out.println("页大小是:"+page.getPageSize());
List<House> housel=page.getHouseList();
for (House house : housel) {
System.out.println(house.getTitle());
}
}
}