OCT
REM: 1. 拆分TaskController QA测试用例与TaskController冒烟测试用例 2. 移除TaskController冒烟测试用例中非冒烟测试用例 3. 添加askController QA测试用例
This commit is contained in:
parent
cbdfb653a7
commit
315f15386e
|
@ -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 {
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<TaskInfoData> 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()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<TaskInfoData> 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<TaskInfoData> 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<TaskInfoData> 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue