REM:
1. 编写数据库DeviceTask已数组方式增加清洗任务的单元测试
This commit is contained in:
chenlinghy 2020-08-24 17:08:35 +08:00
parent e1fa24f3b9
commit ee2ff75a26
1 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,101 @@
package com.dispose.test.mapper;
import com.dispose.common.DisposeCapacityType;
import com.dispose.common.DisposeObjectType;
import com.dispose.common.DisposeTaskStatus;
import com.dispose.common.IpAddrType;
import com.dispose.mapper.DeviceTaskMapper;
import com.dispose.mapper.DisposeDeviceMapper;
import com.dispose.mapper.DisposeTaskMapper;
import com.dispose.mapper.UserAccountMapper;
import com.dispose.pojo.entity.DeviceTask;
import com.dispose.pojo.entity.DisposeCapacity;
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.ArrayList;
import java.util.List;
/**
* The type Dispose task mapper test.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback
public class DeviceTaskMapperTest {
/**
* The Dispose task mapper.
*/
@Resource
private DisposeTaskMapper disposeTaskMapper;
/**
* The device task mapper.
*/
@Resource
private DeviceTaskMapper deviceTaskMapper;
/**
* The Dispose device mapper.
*/
@Resource
private DisposeDeviceMapper disposeDeviceMapper;
/**
* The Object mapper.
*/
@Resource
private ObjectMapper objectMapper;
/**
* A 1 add new task info list.
*
* @throws JsonProcessingException the json processing exception
*/
@Test
public void a1_addNewTaskInfoList() throws JsonProcessingException {
List<DeviceTask> taskList = new ArrayList<>();
Long dId = disposeDeviceMapper.selectAll().get(0).getId();
Long tId = disposeTaskMapper.selectAll().get(0).getId();
taskList.add(DeviceTask.builder()
.taskId(tId)
.deviceId(dId)
.taskAttackType(10737508814L)
.status((long)DisposeTaskStatus.TASK_FINISHED.getValue())
.build());
taskList.add(DeviceTask.builder()
.taskId(tId)
.deviceId(dId)
.taskAttackType(25097508814L)
.status((long)DisposeTaskStatus.TASK_NEW.getValue())
.build());
log.info("taskList: {}", objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskList));
int number = deviceTaskMapper.addNewTaskInfoList(taskList);
log.info("number-->{}",number );
Assert.assertNotNull(taskList);
Assert.assertEquals(number, taskList.size());
}
}