REM:
1. 修改能力节点信息相关接口断言
2. 修改处置任务相关接口断言
3. 获取指定能力节点处置任务列表接口中入参数组id可以为空字符串,表示查询所有能力节点,删除空字符串判断
This commit is contained in:
chenlinghy 2020-05-28 16:05:50 +08:00
parent 8e11ed64dc
commit 367f80979d
4 changed files with 108 additions and 137 deletions

View File

@ -394,16 +394,16 @@ public class DisposeTaskController {
GetTaskReq reqInfo = mr.getRequestObject(GetTaskReq.class);
NodeTaskRsp rspInfo = new NodeTaskRsp();
if (reqInfo.getId().length == 0 || reqInfo.getId() == null || reqInfo.getType() == null) {
if (reqInfo.getId() == null || reqInfo.getType() == null) {
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
for (String deviceId : reqInfo.getId()
) {
if (deviceId.length() == 0) {
return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
}
}
// for (String deviceId : reqInfo.getId()
// ) {
// if (deviceId.length() == 0) {
// return ProtocolRespDTO.result(ErrorCode.ERR_PARAMS);
// }
// }
List<DisposeDevice> valuableData = disposeNodeManager.getAllDisposeDevice()
.stream()

View File

@ -286,17 +286,24 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
String msgContent = verifyResp(ver);
VersionRsp versionRsp = objectMapper.readValue(msgContent, new TypeReference<VersionRsp>() {
VersionListRsp versionListRsp = objectMapper.readValue(msgContent, new TypeReference<VersionListRsp>() {
});
Assert.assertEquals(String.valueOf(versionRsp.getStatus()),
String.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
List<VersionRsp> verList = versionListRsp.getItems();
Assert.assertEquals(verList.size(), 1);
for (VersionRsp versionRsp : verList
) {
Assert.assertNotNull(versionRsp.getId());
Assert.assertEquals(String.valueOf(versionRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(versionRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
}
}
/**
@ -505,17 +512,24 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(deviceInfo), ReturnStatus.class);
String msgContent = verifyResp(deviceInfo);
DeviceInfoRsp deviceInfoRsp = objectMapper.readValue(msgContent, new TypeReference<DeviceInfoRsp>() {
});
Assert.assertNotNull(rspInfo.getStatus());
Assert.assertNotNull(rspInfo.getMessage());
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
List<DeviceInfoData> verList = deviceInfoRsp.getItems();
Assert.assertEquals(verList.size(), 1);
for (DeviceInfoData deviceInfoData : verList
) {
Assert.assertNotNull(deviceInfoData.getId());
Assert.assertEquals(String.valueOf(deviceInfoData.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(deviceInfoData.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
}
}
/**
@ -738,17 +752,24 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(linkstatus), ReturnStatus.class);
String msgContent = verifyResp(linkstatus);
LinkStatusListRsp linkStatusListRsp = objectMapper.readValue(msgContent, new TypeReference<LinkStatusListRsp>() {
});
Assert.assertNotNull(rspInfo.getStatus());
Assert.assertNotNull(rspInfo.getMessage());
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
List<LinkStatusRsp> linkStatusRspList = linkStatusListRsp.getItems();
Assert.assertEquals(linkStatusRspList.size(), 1);
for (LinkStatusRsp linkStatusRsp : linkStatusRspList
) {
Assert.assertNotNull(linkStatusRsp.getId());
Assert.assertEquals(String.valueOf(linkStatusRsp.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(linkStatusRsp.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
}
}
/**
@ -965,16 +986,24 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(521))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(capacity), ReturnStatus.class);
String msgContent = verifyResp(capacity);
DeviceCapacityRsp deviceCapacityRsp = objectMapper.readValue(msgContent, new TypeReference<DeviceCapacityRsp>() {
});
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
List<DeviceCapacityData> deviceCapacityDataList = deviceCapacityRsp.getItems();
Assert.assertEquals(deviceCapacityDataList.size(), 1);
for (DeviceCapacityData deviceCapacityData : deviceCapacityDataList
) {
Assert.assertNotNull(deviceCapacityData.getId());
Assert.assertEquals(String.valueOf(deviceCapacityData.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(deviceCapacityData.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
}
}
@ -1865,32 +1894,16 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
Assert.assertNotNull(rspInfo);
if (rspInfo.getItems().size() > 0) {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
if (disposeNodeData.getStatus() == 0) {
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getName());
Assert.assertNotNull(disposeNodeData.getIp());
} else {
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
}
}
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
}
@ -1910,35 +1923,20 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
Assert.assertNotNull(rspInfo);
if (rspInfo.getItems().size() > 0) {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
if (disposeNodeData.getStatus() == 0) {
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getName());
Assert.assertNotNull(disposeNodeData.getIp());
} else {
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
}
}
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
}
/**
* H 6 id null 目前默认这种情况是允许的获取所有节点列表信息
* H 6 id null 不允许
*
* @throws Exception the exception
*/
@ -1953,31 +1951,16 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
Assert.assertNotNull(rspInfo);
if (rspInfo.getItems().size() > 0) {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
if (disposeNodeData.getStatus() == 0) {
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getName());
Assert.assertNotNull(disposeNodeData.getIp());
} else {
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
}
}
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
}
/**
@ -1996,16 +1979,21 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
List<DisposeNodeData> disposeNodeDataList = rspInfo.getItems();
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(disposeNodeDataList.size(), 1);
for (DisposeNodeData disposeNodeData : disposeNodeDataList
) {
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertEquals(String.valueOf(disposeNodeData.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(disposeNodeData.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
}
}
/**
@ -2036,21 +2024,21 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
if(disposeNodeData.getStatus() == 0){
if (disposeNodeData.getStatus() == 0) {
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getIp());
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(disposeNodeData.getCapacity());
for (DisposeCapacity disposeCapacity:disposeNodeData.getCapacity()
) {
for (DisposeCapacity disposeCapacity : disposeNodeData.getCapacity()
) {
Assert.assertNotNull(disposeCapacity.getType());
Assert.assertNotNull(disposeCapacity.getDisposeIp());
}
}else{
} else {
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -2087,7 +2075,7 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
for (DisposeNodeData disposeNodeData : rspInfo.getItems()
) {
Assert.assertNotNull(disposeNodeData);
if(disposeNodeData.getStatus() == 0){
if (disposeNodeData.getStatus() == 0) {
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertNotNull(String.valueOf(disposeNodeData.getType()));
Assert.assertNotNull(disposeNodeData.getIp());
@ -2096,12 +2084,12 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
Assert.assertEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
Assert.assertNotNull(disposeNodeData.getCapacity());
for (DisposeCapacity disposeCapacity:disposeNodeData.getCapacity()
for (DisposeCapacity disposeCapacity : disposeNodeData.getCapacity()
) {
Assert.assertNotNull(disposeCapacity.getType());
Assert.assertNotNull(disposeCapacity.getDisposeIp());
}
}else{
} else {
Assert.assertNotNull(disposeNodeData.getStatus());
Assert.assertNotNull(disposeNodeData.getMessage());
Assert.assertNotEquals(Long.valueOf(disposeNodeData.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
@ -2185,17 +2173,21 @@ public class DeviceNodeInfoControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), ReturnStatus.class);
DisposeNodeListRsp rspInfo = objectMapper.readValue(verifyResp(ret), DisposeNodeListRsp.class);
List<DisposeNodeData> disposeNodeDataList = rspInfo.getItems();
Assert.assertNotNull(rspInfo.getStatus());
Assert.assertNotNull(rspInfo.getMessage());
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
Assert.assertEquals(disposeNodeDataList.size(), 1);
for (DisposeNodeData disposeNodeData : disposeNodeDataList
) {
Assert.assertNotNull(disposeNodeData.getId());
Assert.assertEquals(String.valueOf(disposeNodeData.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
Assert.assertEquals(disposeNodeData.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
}
}

View File

@ -1142,38 +1142,16 @@ public class TaskControllerQATest extends InitTestEnvironment {
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMS.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
NodeTaskRsp nodeTaskRsp = objectMapper.readValue(verifyResp(getNodeTaskInfo), NodeTaskRsp.class);
ReturnStatus returnStatus = objectMapper.readValue(verifyResp(getNodeTaskInfo), ReturnStatus.class);
List<NodeTaskData> taskInfoList = nodeTaskRsp.getItems();
for (NodeTaskData task : taskInfoList
) {
Assert.assertNotNull(task.getStatus());
Assert.assertNotNull(task.getMessage());
if (task.getStatus() == 0) {
Assert.assertNotNull(task.getId());
Assert.assertNotNull(task.getTaskArray());
for (TaskInfoData taskInfoData : task.getTaskArray()
) {
Assert.assertNotNull(taskInfoData.getTaskId());
Assert.assertNotNull(taskInfoData.getType());
Assert.assertNotNull(taskInfoData.getStartTime());
Assert.assertNotNull(taskInfoData.getDisposeTime());
Assert.assertNotNull(taskInfoData.getDisposeIp());
}
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else if (task.getStatus() == 19) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
} else if (task.getStatus() == 30) {
Assert.assertEquals(Long.valueOf(task.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHTASK.getCode()));
}
}
Assert.assertNotNull(returnStatus.getStatus());
Assert.assertNotNull(returnStatus.getMessage());
Assert.assertEquals(Long.valueOf(returnStatus.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMS.getCode()));
}
/**

View File

@ -808,6 +808,7 @@ public class TaskControllerTest extends InitTestEnvironment {
Assert.assertTrue(task.getDisposeIp().matches(regex));
}
}
Assert.assertEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
} else {
Assert.assertNotEquals(Long.valueOf(taskNode.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));