From 315f15386e422ac2aa65812403128e6824d49e82 Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Sat, 9 May 2020 11:09:19 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E6=8B=86=E5=88=86TaskControl?= =?UTF-8?q?ler=20QA=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E4=B8=8ETaskContro?= =?UTF-8?q?ller=E5=86=92=E7=83=9F=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=202.?= =?UTF-8?q?=20=E7=A7=BB=E9=99=A4TaskController=E5=86=92=E7=83=9F=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=E4=B8=AD=E9=9D=9E=E5=86=92=E7=83=9F?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=203.=20=E6=B7=BB=E5=8A=A0a?= =?UTF-8?q?skController=20QA=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dispose/TestSuit/QATest.java | 6 +- .../java/com/dispose/TestSuit/SmokeTest.java | 4 +- ...okeTest.java => TaskControllerQATest.java} | 110 ++------- .../controller/TaskControllerSmokeTest.java | 212 ++++++++++++++++++ 4 files changed, 233 insertions(+), 99 deletions(-) rename src/test/java/com/dispose/controller/{TaskControllerExceptionSmokeTest.java => TaskControllerQATest.java} (78%) create mode 100644 src/test/java/com/dispose/controller/TaskControllerSmokeTest.java diff --git a/src/test/java/com/dispose/TestSuit/QATest.java b/src/test/java/com/dispose/TestSuit/QATest.java index 4b3de07d..4f314696 100644 --- a/src/test/java/com/dispose/TestSuit/QATest.java +++ b/src/test/java/com/dispose/TestSuit/QATest.java @@ -2,7 +2,8 @@ package com.dispose.TestSuit; import com.dispose.controller.AuthControllerQATest; import com.dispose.controller.AuthControllerSmokeTest; -import com.dispose.controller.TaskControllerExceptionSmokeTest; +import com.dispose.controller.TaskControllerQATest; +import com.dispose.controller.TaskControllerSmokeTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -10,7 +11,8 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ AuthControllerQATest.class, AuthControllerSmokeTest.class, - TaskControllerExceptionSmokeTest.class + TaskControllerQATest.class, + TaskControllerSmokeTest.class }) public class QATest { } diff --git a/src/test/java/com/dispose/TestSuit/SmokeTest.java b/src/test/java/com/dispose/TestSuit/SmokeTest.java index 016ca028..2548b808 100644 --- a/src/test/java/com/dispose/TestSuit/SmokeTest.java +++ b/src/test/java/com/dispose/TestSuit/SmokeTest.java @@ -1,6 +1,7 @@ package com.dispose.TestSuit; import com.dispose.controller.AuthControllerSmokeTest; +import com.dispose.controller.TaskControllerSmokeTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -9,7 +10,8 @@ import org.junit.runners.Suite; */ @RunWith(Suite.class) @Suite.SuiteClasses({ - AuthControllerSmokeTest.class + AuthControllerSmokeTest.class, + TaskControllerSmokeTest.class }) public class SmokeTest { diff --git a/src/test/java/com/dispose/controller/TaskControllerExceptionSmokeTest.java b/src/test/java/com/dispose/controller/TaskControllerQATest.java similarity index 78% rename from src/test/java/com/dispose/controller/TaskControllerExceptionSmokeTest.java rename to src/test/java/com/dispose/controller/TaskControllerQATest.java index 8fab99c3..3bbe169b 100644 --- a/src/test/java/com/dispose/controller/TaskControllerExceptionSmokeTest.java +++ b/src/test/java/com/dispose/controller/TaskControllerQATest.java @@ -33,7 +33,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Slf4j -public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { +public class TaskControllerQATest extends InitTestEnvironment { /** * The Mock mvc. */ @@ -46,43 +46,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { private ObjectMapper objectMapper; @Test - public void t1_NormalTaskTest() throws Exception { - String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + - "\"msgContent\":\"{\\\"id\\\":-1," + - "\\\"type\\\":0, " + - "\\\"disposeIp\\\":\\\"192.168.5.5\\\", " + - "\\\"disposeTime\\\":120}\"}"; - - String taskStart = mockMvc.perform(MockMvcRequestBuilders - .post("/task/start") - .contentType(MediaType.APPLICATION_JSON) - .header("Authorization", "Bearer " + getLogToken()) - .content(reqData)) - .andDo(print()).andExpect(status().isOk()) - .andExpect(jsonPath("$.code").value(200)) - .andReturn() - .getResponse() - .getContentAsString(); - - StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); - - Assert.assertNotNull(startTaskRsp); - Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime())); - Assert.assertNotNull(startTaskRsp.getId()); - Assert.assertNotNull(startTaskRsp.getTaskId()); - Assert.assertNotNull(startTaskRsp.getStatus()); - Assert.assertNotNull(startTaskRsp.getMessage()); - - if (startTaskRsp.getStatus() == 0) { - Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); - } else if (startTaskRsp.getStatus() == 26) { - Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_TASKRUNNING.getCode())); - } - } - - - @Test - public void t2_NormalContainsNonEmptyTaskTest() throws Exception { + public void t1_NormalContainsNonEmptyTaskTest() throws Exception { String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":0, \\\"disposeIp\\\":\\\"192.168.5.4\\\", " + "\\\"disposeTime\\\":120, \\\"flowDirection\\\":2, \\\"attackType\\\":[0], " + @@ -116,7 +80,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { } @Test - public void t3_startTaskNoDisPoseIpExceptionTest() throws Exception { + public void t2_startTaskNoDisPoseIpExceptionTest() throws Exception { String reqDataNoIp = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":0, \\\"disposeIp\\\":, \\\"disposeTime\\\":120}\"}"; @@ -141,7 +105,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { @Test - public void t4_startTaskNullDisposeIpExceptionTest() throws Exception { + public void t3_startTaskNullDisposeIpExceptionTest() throws Exception { //disposeIp null String reqDataNullIp = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":0, \\\"disposeIp\\\":null, \\\"disposeTime\\\":120}\"}"; @@ -167,7 +131,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { @Test - public void t5_startTaskIntegerDisposeIpExceptionTest() throws Exception { + public void t4_startTaskIntegerDisposeIpExceptionTest() throws Exception { String reqDataIntegerIp = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":0, \\\"disposeIp\\\":192345, \\\"disposeTime\\\":120}\"}"; @@ -196,7 +160,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { } @Test - public void t6_startTaskNullIdExceptionTest() throws Exception { + public void t5_startTaskNullIdExceptionTest() throws Exception { //Id null String reqDataNullId = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":null," + "\\\"type\\\":0, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":120}\"}"; @@ -221,7 +185,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { } @Test - public void t7_startTaskNoTypeExceptionTest() throws Exception { + public void t6_startTaskNoTypeExceptionTest() throws Exception { //no type String reqDataNoType = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":120}\"}"; @@ -247,7 +211,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { @Test - public void t8_startTaskNullTypeExceptionTest() throws Exception { //null type + public void t7_startTaskNullTypeExceptionTest() throws Exception { //null type String reqDataNullType = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":null, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":120}\"}"; @@ -271,7 +235,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { } @Test - public void t9_startTaskNoDisposeTimeExceptionTest() throws Exception { + public void t8_startTaskNoDisposeTimeExceptionTest() throws Exception { //no disposeTime String reqDataNoDisposeTime = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":null, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":}\"}"; @@ -297,7 +261,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { @Test - public void t10_startTaskNullDisposeTimeExceptionTest() throws Exception { + public void t9_startTaskNullDisposeTimeExceptionTest() throws Exception { //null disposeTime String reqDataNullDisposeTime = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":0, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":null}\"}"; @@ -322,7 +286,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { } @Test - public void t11_startTaskStringDisposeTimeExceptionTest() throws Exception { + public void t10_startTaskStringDisposeTimeExceptionTest() throws Exception { //string disposeTime String reqDataStringDisposeTime = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"id\\\":-1," + "\\\"type\\\":null, \\\"disposeIp\\\":\\\"192.168.4.2\\\", \\\"disposeTime\\\":\\\"120\\\"}\"}"; @@ -346,54 +310,9 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); } - @Test - public void t12_NormalStopTaskTest() throws Exception { - String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + - "\"msgContent\":\"{\\\"taskId\\\":[\\\"236\\\", \\\"235\\\" ]}\"}"; - - String taskStop = mockMvc.perform(MockMvcRequestBuilders - .post("/task/stop") - .contentType(MediaType.APPLICATION_JSON) - .header("Authorization", "Bearer " + getLogToken()) - .content(reqData)) - .andDo(print()).andExpect(status().isOk()) - .andExpect(jsonPath("$.code").value(200)) - .andReturn() - .getResponse() - .getContentAsString(); - - String regex = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z"; - TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class); - List taskInfoList = startTaskRsp.getItems(); - for (TaskInfoData task : taskInfoList - ) { - Assert.assertNotNull(task.getId()); - Assert.assertNotNull(task.getTaskId()); - Assert.assertNotNull(task.getStatus()); - Assert.assertNotNull(task.getMessage()); - - if (task.getStatus() == 0) { - Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); - } else if (task.getStatus() == 30) { - Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode())); - } - - if (task.getType() != null) { - Assert.assertNotEquals(String.valueOf(task.getType()), -1); - } - - if (task.getDisposeIp() != null) { - Assert.assertTrue(task.getDisposeIp().matches(regex)); - } - - if (task.getDisposeTime() != null) { - Assert.assertNotEquals(String.valueOf(task.getDisposeTime()), -1); - } - } - } @Test - public void t13_NormalStopNoTaskIdTaskTest() throws Exception { + public void t11_stopTaskNoTaskIdExceptionTest() throws Exception { String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + "\"msgContent\":\"{\\\"taskId\\\":}\"}"; @@ -421,7 +340,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { } @Test - public void t14_NormalStopNullTaskIdTaskTest() throws Exception { + public void t12_stopTaskNullTaskIdExceptionTest() throws Exception { String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + "\"msgContent\":\"{\\\"taskId\\\":null}\"}"; @@ -449,7 +368,7 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { } @Test - public void t15_NormalIntegerTaskIdTaskTest() throws Exception { + public void t13_stopTaskIntegerTaskIdExceptionTest() throws Exception { String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + "\"msgContent\":\"{\\\"taskId\\\":[445, 235]}\"}"; @@ -472,7 +391,6 @@ public class TaskControllerExceptionSmokeTest extends InitTestEnvironment { Assert.assertNotNull(task.getTaskId()); Assert.assertNotNull(task.getStatus()); Assert.assertNotNull(task.getMessage()); - //Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode())); } } } diff --git a/src/test/java/com/dispose/controller/TaskControllerSmokeTest.java b/src/test/java/com/dispose/controller/TaskControllerSmokeTest.java new file mode 100644 index 00000000..dfdec119 --- /dev/null +++ b/src/test/java/com/dispose/controller/TaskControllerSmokeTest.java @@ -0,0 +1,212 @@ +package com.dispose.controller; + +import com.dispose.Global.InitTestEnvironment; +import com.dispose.common.ErrorCode; +import com.dispose.pojo.vo.common.TaskInfoData; +import com.dispose.pojo.vo.task.StartTaskRsp; +import com.dispose.pojo.vo.task.TaskInfoRsp; +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.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import javax.annotation.Resource; +import java.util.List; + +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@AutoConfigureMockMvc +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Slf4j +public class TaskControllerSmokeTest extends InitTestEnvironment { + /** + * The Mock mvc. + */ + @Resource + private MockMvc mockMvc; + /** + * The Object mapper. + */ + @Resource + private ObjectMapper objectMapper; + + @Test + public void t1_NormalTaskTest() throws Exception { + String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + + "\"msgContent\":\"{\\\"id\\\":-1," + + "\\\"type\\\":0, " + + "\\\"disposeIp\\\":\\\"192.168.5.5\\\", " + + "\\\"disposeTime\\\":120}\"}"; + + String taskStart = mockMvc.perform(MockMvcRequestBuilders + .post("/task/start") + .contentType(MediaType.APPLICATION_JSON) + .header("Authorization", "Bearer " + getLogToken()) + .content(reqData)) + .andDo(print()).andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andReturn() + .getResponse() + .getContentAsString(); + + StartTaskRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStart), StartTaskRsp.class); + + Assert.assertNotNull(startTaskRsp); + Assert.assertNotNull(String.valueOf(startTaskRsp.getExpireTime())); + Assert.assertNotNull(startTaskRsp.getId()); + Assert.assertNotNull(startTaskRsp.getTaskId()); + Assert.assertNotNull(startTaskRsp.getStatus()); + Assert.assertNotNull(startTaskRsp.getMessage()); + + if (startTaskRsp.getStatus() == 0) { + Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); + } else if (startTaskRsp.getStatus() == 26) { + Assert.assertEquals(Long.valueOf(startTaskRsp.getStatus()), Long.valueOf(ErrorCode.ERR_TASKRUNNING.getCode())); + } + } + + + @Test + public void t2_NormalStopTaskTest() throws Exception { + String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + + "\"msgContent\":\"{\\\"taskId\\\":[\\\"236\\\", \\\"235\\\" ]}\"}"; + + String taskStop = mockMvc.perform(MockMvcRequestBuilders + .post("/task/stop") + .contentType(MediaType.APPLICATION_JSON) + .header("Authorization", "Bearer " + getLogToken()) + .content(reqData)) + .andDo(print()).andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andReturn() + .getResponse() + .getContentAsString(); + + String regex = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z"; + TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStop), TaskInfoRsp.class); + List taskInfoList = startTaskRsp.getItems(); + for (TaskInfoData task : taskInfoList + ) { + Assert.assertNotNull(task.getId()); + Assert.assertNotNull(task.getTaskId()); + Assert.assertNotNull(task.getStatus()); + Assert.assertNotNull(task.getMessage()); + + if (task.getStatus() == 0) { + Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); + } else if (task.getStatus() == 30) { + Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode())); + } + + if (task.getType() != null) { + Assert.assertNotEquals(String.valueOf(task.getType()), -1); + } + + if (task.getDisposeIp() != null) { + Assert.assertTrue(task.getDisposeIp().matches(regex)); + } + + if (task.getDisposeTime() != null) { + Assert.assertNotEquals(String.valueOf(task.getDisposeTime()), -1); + } + } + } + + + @Test + public void t3_NormalStopTaskByDisposeIpTest() throws Exception { + String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\": \"{\\\"items\\\":" + + "[{\\\"id\\\":\\\"451\\\",\\\"type\\\":0,\\\"disposeIp\\\":\\\"192.168.3.4\\\"}]}\"}"; + + String taskStopByIp = mockMvc.perform(MockMvcRequestBuilders + .post("/task/stop_ip") + .contentType(MediaType.APPLICATION_JSON) + .header("Authorization", "Bearer " + getLogToken()) + .content(reqData)) + .andDo(print()).andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andReturn() + .getResponse() + .getContentAsString(); + + String regex = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z"; + TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(taskStopByIp), TaskInfoRsp.class); + List taskInfoList = startTaskRsp.getItems(); + for (TaskInfoData task : taskInfoList + ) { + Assert.assertNotNull(task.getId()); + Assert.assertNotNull(task.getTaskId()); + Assert.assertNotNull(task.getStatus()); + Assert.assertNotNull(task.getMessage()); + + if (task.getStatus() == 0) { + Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); + } else if (task.getStatus() == 30) { + Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode())); + } + + if (task.getType() != null) { + Assert.assertNotEquals(String.valueOf(task.getType()), -1); + } + + if (task.getDisposeIp() != null) { + Assert.assertTrue(task.getDisposeIp().matches(regex)); + } + + if (task.getDisposeTime() != null) { + Assert.assertNotEquals(String.valueOf(task.getDisposeTime()), -1); + } + } + } + + @Test + public void t4_NormalGetNodeDetailedInfoTest() throws Exception { + String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," + + "\"msgContent\":\"{\\\"taskId\\\":[\\\"277\\\"]}\"}"; + + String getNodeDetailedInfo = mockMvc.perform(MockMvcRequestBuilders + .post("/task/get") + .contentType(MediaType.APPLICATION_JSON) + .header("Authorization", "Bearer " + getLogToken()) + .content(reqData)) + .andDo(print()).andExpect(status().isOk()) + .andExpect(jsonPath("$.code").value(200)) + .andReturn() + .getResponse() + .getContentAsString(); + + TaskInfoRsp startTaskRsp = objectMapper.readValue(verifyResp(getNodeDetailedInfo), TaskInfoRsp.class); + + List taskInfoList = startTaskRsp.getItems(); + for (TaskInfoData task : taskInfoList + ) { + Assert.assertNotNull(task.getTaskId()); + Assert.assertNotNull(task.getTaskId()); + Assert.assertNotNull(task.getStartTime()); + Assert.assertNotNull(task.getDisposeTime()); + Assert.assertNotNull(task.getStatus()); + Assert.assertNotNull(task.getMessage()); + + if (task.getStatus() == 0) { + Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode())); + } else if (task.getStatus() == 30) { + Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode())); + } + } + } +}