OCT
REM: 1. 解决Mybatis没有匹配到参数的问题 2. 修改获取能力节点处置中任务接口的断言 3. 增加数据库测试用例
This commit is contained in:
parent
f09fb38db8
commit
887c11a9c8
|
@ -34,7 +34,8 @@ public interface TaskInfoMapper extends Mapper<TaskInfo>, MySqlMapper<TaskInfo>
|
||||||
* @param deviceId the device id
|
* @param deviceId the device id
|
||||||
* @return the task info
|
* @return the task info
|
||||||
*/
|
*/
|
||||||
List<TaskInfo> getTaskInfo(Long taskId, Long deviceId);
|
List<TaskInfo> getTaskInfo(@Param("taskId") Long taskId,
|
||||||
|
@Param("deviceId") Long deviceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets task info by task id.
|
* Gets task info by task id.
|
||||||
|
@ -50,5 +51,6 @@ public interface TaskInfoMapper extends Mapper<TaskInfo>, MySqlMapper<TaskInfo>
|
||||||
* @param id the id
|
* @param id the id
|
||||||
* @param status the status
|
* @param status the status
|
||||||
*/
|
*/
|
||||||
void changeTaskInfoStatus(Long id, Long status);
|
void changeTaskInfoStatus(@Param("id") Long id,
|
||||||
|
@Param("status") Long status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2623,8 +2623,8 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
|
||||||
rspInfo.getItems().forEach(v -> {
|
rspInfo.getItems().forEach(v -> {
|
||||||
Assert.assertNotNull(v);
|
Assert.assertNotNull(v);
|
||||||
Assert.assertNotNull(v.getId());
|
Assert.assertNotNull(v.getId());
|
||||||
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
Assert.assertEquals(Long.valueOf(v.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
|
||||||
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
Assert.assertEquals(v.getMessage(), ErrorCode.ERR_NOSUCHTASK.getMsg());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,191 @@
|
||||||
|
package com.dispose.test.mapper;
|
||||||
|
|
||||||
|
import com.dispose.common.DeviceCapacity;
|
||||||
|
import com.dispose.mapper.DisposeDeviceMapper;
|
||||||
|
import com.dispose.mapper.DisposeTaskMapper;
|
||||||
|
import com.dispose.mapper.TaskInfoMapper;
|
||||||
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
|
import com.dispose.pojo.vo.common.TaskInfo;
|
||||||
|
import com.dispose.pojo.vo.common.TaskInfoDetail;
|
||||||
|
import com.dispose.test.Global.InitTestEnvironment;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.FixMethodOrder;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.annotation.Rollback;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type task information mapper test.
|
||||||
|
*/
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@Slf4j
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
@Transactional
|
||||||
|
@Rollback
|
||||||
|
public class TaskInfoMapperTest extends InitTestEnvironment {
|
||||||
|
/**
|
||||||
|
* The Object mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The task information mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private TaskInfoMapper taskInfoMapper;
|
||||||
|
/**
|
||||||
|
* The Dispose task mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private DisposeTaskMapper disposeTaskMapper;
|
||||||
|
/**
|
||||||
|
* The Dispose device mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private DisposeDeviceMapper disposeDeviceMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 1 add new task information.
|
||||||
|
*
|
||||||
|
* @throws JsonProcessingException the json processing exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t1_addNewTaskInfo() throws JsonProcessingException {
|
||||||
|
Long beginTime = null;
|
||||||
|
Long endTime = null;
|
||||||
|
Long taskId = null;
|
||||||
|
|
||||||
|
DisposeDevice dev = disposeDeviceMapper.getDeviceByIp("10.88.77.15");
|
||||||
|
List<TaskInfoDetail> taskInfoDetailList = disposeTaskMapper.getAllTaskByType(DeviceCapacity.CLEANUP.getCode());
|
||||||
|
for (TaskInfoDetail task : taskInfoDetailList
|
||||||
|
) {
|
||||||
|
if (task.getDeviceId().equals(dev.getId())) {
|
||||||
|
taskId = task.getId();
|
||||||
|
log.info("taskId:{}", taskId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskInfo taskInfo = TaskInfo.builder()
|
||||||
|
.id(-1L)
|
||||||
|
.taskId(taskId)
|
||||||
|
.deviceId(dev.getId())
|
||||||
|
.externId(null)
|
||||||
|
.status(0L)
|
||||||
|
.beginTime(String.valueOf(beginTime))
|
||||||
|
.endTime(String.valueOf(endTime))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
taskInfoMapper.addNewTaskInfo(taskInfo.getTaskId(), taskInfo.getDeviceId(), taskInfo.getExternId(), taskInfo.getStatus());
|
||||||
|
|
||||||
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskInfo));
|
||||||
|
|
||||||
|
List<TaskInfo> taskInfoList = taskInfoMapper.getTaskInfoByTaskId(taskInfo.getTaskId());
|
||||||
|
|
||||||
|
if (taskInfoList.size() > 0) {
|
||||||
|
Assert.assertNotEquals(taskInfoList.size(), 0);
|
||||||
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskInfoList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 2 get task information by taskId.
|
||||||
|
*
|
||||||
|
* @throws JsonProcessingException the json processing exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t2_getTaskInfoByTaskId() throws JsonProcessingException {
|
||||||
|
List<TaskInfoDetail> taskInfoDetailList = disposeTaskMapper.getAllTaskByType(DeviceCapacity.CLEANUP.getCode());
|
||||||
|
if (taskInfoDetailList.size() > 0) {
|
||||||
|
for (TaskInfoDetail task : taskInfoDetailList
|
||||||
|
) {
|
||||||
|
log.info("taskId:{}", task.getId());
|
||||||
|
List<TaskInfo> taskInfoList = taskInfoMapper.getTaskInfoByTaskId(task.getId());
|
||||||
|
if (taskInfoList.size() > 0) {
|
||||||
|
Assert.assertNotEquals(taskInfoList.size(), 0);
|
||||||
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskInfoList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 3 get task information by taskId and deviceId.
|
||||||
|
*
|
||||||
|
* @throws JsonProcessingException the json processing exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t3_getTaskInfo() throws JsonProcessingException {
|
||||||
|
List<TaskInfoDetail> taskInfoDetailList = disposeTaskMapper.getAllTaskByType(DeviceCapacity.CLEANUP.getCode());
|
||||||
|
if (taskInfoDetailList.size() > 0) {
|
||||||
|
for (TaskInfoDetail task : taskInfoDetailList
|
||||||
|
) {
|
||||||
|
log.info("taskId-->{}, deviceId-->{}", task.getId(), task.getDeviceId());
|
||||||
|
List<TaskInfo> taskInfoList = taskInfoMapper.getTaskInfo(task.getId(), task.getDeviceId());
|
||||||
|
if (taskInfoList.size() > 0) {
|
||||||
|
Assert.assertNotEquals(taskInfoList.size(), 0);
|
||||||
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskInfoList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 4 change Task Information Status.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t4_changeTaskInfoStatus() {
|
||||||
|
List<TaskInfoDetail> taskInfoDetailList = disposeTaskMapper.getAllTaskByType(DeviceCapacity.CLEANUP.getCode());
|
||||||
|
|
||||||
|
if (taskInfoDetailList.size() > 0) {
|
||||||
|
for (TaskInfoDetail task : taskInfoDetailList
|
||||||
|
) {
|
||||||
|
log.info("taskId-->{}", task.getId());
|
||||||
|
List<TaskInfo> taskInfoList = taskInfoMapper.getTaskInfoByTaskId(task.getId());
|
||||||
|
|
||||||
|
if (taskInfoList.size() > 0) {
|
||||||
|
Assert.assertNotEquals(taskInfoList.size(), 0);
|
||||||
|
|
||||||
|
for (TaskInfo taskInfo : taskInfoList
|
||||||
|
) {
|
||||||
|
Assert.assertNotNull(taskInfo.getStatus());
|
||||||
|
Long beforeStatus = taskInfo.getStatus();
|
||||||
|
long changeStatus;
|
||||||
|
if(beforeStatus == 0){
|
||||||
|
changeStatus = 1L;
|
||||||
|
}else{
|
||||||
|
changeStatus = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("task_info table Id-->{}, before Status-->{}, change Stauts-->{}",
|
||||||
|
taskInfo.getId(),taskInfo.getStatus(),changeStatus);
|
||||||
|
|
||||||
|
taskInfoMapper.changeTaskInfoStatus(taskInfo.getId(), changeStatus);
|
||||||
|
log.info("task_info before Status-->{}, after Stauts-->{}",
|
||||||
|
beforeStatus, taskInfo.getStatus());
|
||||||
|
Assert.assertEquals(beforeStatus, taskInfo.getStatus());
|
||||||
|
|
||||||
|
log.info("change task info Status-->{}", taskInfo.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue