From ee2ff75a26fee8a7b99f1b676ba533e82234873a Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Mon, 24 Aug 2020 17:08:35 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E7=BC=96=E5=86=99=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93DeviceTask=E5=B7=B2=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=A2=9E=E5=8A=A0=E6=B8=85=E6=B4=97=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/mapper/DeviceTaskMapperTest.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/test/java/com/dispose/test/mapper/DeviceTaskMapperTest.java diff --git a/src/test/java/com/dispose/test/mapper/DeviceTaskMapperTest.java b/src/test/java/com/dispose/test/mapper/DeviceTaskMapperTest.java new file mode 100644 index 00000000..b3589e1d --- /dev/null +++ b/src/test/java/com/dispose/test/mapper/DeviceTaskMapperTest.java @@ -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 + */ +@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 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()); + } +}