package io.renren;
import io.renren.common.utils.Query;
import io.renren.modules.sys.entity.AlarmRecordEntity;
import io.renren.modules.sys.service.AlarmRecordService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Service层的测试类
*
* @Author: Connie
* @Date: 2018/4/12 11:40
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class AlarmRecordSerTest {
@Autowired
private AlarmRecordService alarmRecordService;
/**
* 查询测试
*/
@Test
public void getAlarmRecordList() {
Map<String, Object> map = new HashMap<>();
map.put("page", 1);
map.put("limit", 5);
Query query = new Query(map);
List<AlarmRecordEntity> alarmRecordList = alarmRecordService.getAlarmRecordList(query);
for (AlarmRecordEntity a : alarmRecordList) {
System.out.println(a.getModuleInfo());
}
}
/**
* 添加测试
*/
@Test
public void saveAlarmRecord() {
AlarmRecordEntity a = new AlarmRecordEntity();
a.setAlarmTypeId(1);
a.setDescribeDetail("测试添加详情");
// Date date = Date.valueOf("2010-01-01 12:12:12");
// a.setEvenBegintime(new Timestamp(date.getTime()));
a.setModuleInfo("测试模块");
a.setRemark("测试备注");
a.setResult("测试结果");
alarmRecordService.save(a);
System.out.println("添加成功!");
}
/**
* 修改测试
*/
@Test
public void updateAlarmRecord() {
AlarmRecordEntity a = new AlarmRecordEntity();
a.setId(12);
a.setAlarmTypeId(1);
a.setDescribeDetail("测试添加详情1");
// Date date = Date.valueOf("2010-01-01 12:12:12");
// a.setEvenBegintime(new Timestamp(date.getTime()));
a.setModuleInfo("测试模块1");
a.setRemark("测试备注1");
a.setResult("测试结果1");
alarmRecordService.update(a);
System.out.println("修改成功!");
}
/**
* 删除测试
*/
@Test
public void deleteAlarmRecord() {
String[] strs = {"12", "9"};
Long[] ids = new Long[strs.length];
for (int i = 0; i < strs.length; i++) {
ids[i] = Long.parseLong(strs[i]);
}
alarmRecordService.deleteBatch(ids);
}
}
SpringBoot的单元测试
最新推荐文章于 2023-02-22 13:02:04 发布