parent
cc4c0a010b
commit
90041e41f0
|
@ -83,10 +83,9 @@ public class InitTestEnvironment {
|
|||
/**
|
||||
* Check response body.
|
||||
*/
|
||||
public EnumMap<ErrorCode, String> verifyRep(String data, Long reqTime) throws JSONException {
|
||||
public String verifyRep(String data, Long reqTime) throws JSONException {
|
||||
Long verValue = 2L;
|
||||
ErrorCode err = ErrorCode.ERR_OK;
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<>(ErrorCode.class);
|
||||
|
||||
JSONObject jsonObject = new JSONObject(data);
|
||||
Iterator it = jsonObject.keys();
|
||||
|
@ -102,25 +101,26 @@ public class InitTestEnvironment {
|
|||
if ((jsonObject.getString("timeStamp").length() == 0) || (repTime - reqTime) > HTTP_CONNECT_TIMEOUT) {
|
||||
err = ErrorCode.ERR_REQTIMEOUT;
|
||||
}
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
Long ver = Long.valueOf(jsonObject.getString("ver"));
|
||||
if ((jsonObject.getString("ver").length() == 0) || (!ver.equals(verValue))) {
|
||||
err = ErrorCode.ERR_VERSION;
|
||||
}
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
long cryptoType = Long.parseLong(jsonObject.getString("cryptoType"));
|
||||
if ((String.valueOf(cryptoType).length() == 0) || (cryptoType < 0)) {
|
||||
err = ErrorCode.ERR_INPUTMISS;
|
||||
}
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
if((jsonObject.getString("code").length() == 0) ||
|
||||
Long.parseLong(jsonObject.getString("code")) != 200){
|
||||
err = ErrorCode.ERR_UNKNOWNCMD;
|
||||
}
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = jsonObject.getString("msgContent");
|
||||
|
||||
ret.put(err, msgContent);
|
||||
return ret;
|
||||
return jsonObject.getString("msgContent");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import com.dispose.pojo.entity.DisposeDevice;
|
|||
import com.dispose.pojo.po.DisposeDeviceCapacity;
|
||||
import com.dispose.pojo.vo.common.DisposeCapacity;
|
||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||
import com.dispose.pojo.vo.common.TaskInfoData;
|
||||
import com.dispose.pojo.vo.common.TaskInfoDetail;
|
||||
import com.dispose.pojo.vo.information.DeviceCapacityData;
|
||||
import com.dispose.pojo.vo.information.DisposeNodeData;
|
||||
import com.dispose.service.DisposeNodeManager;
|
||||
|
@ -129,12 +131,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(ver, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(ver, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
JSONArray json = JSONArray.fromObject(msgContent);
|
||||
|
@ -193,12 +190,8 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(verAll, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(verAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
JSONArray json = JSONArray.fromObject(msgContent);
|
||||
|
@ -243,12 +236,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(deviceInfo, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(deviceInfo, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
|
@ -332,23 +320,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(deviceInfoAll, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(deviceInfoAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
Iterator it = jsonObject.keys();
|
||||
System.out.println();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
String value = jsonObject.getString(key);
|
||||
System.out.println("key: " + key + ",value:" + value);
|
||||
}
|
||||
|
||||
String items = jsonObject.getString("items");
|
||||
System.out.print("items=" + items);
|
||||
|
||||
|
@ -419,23 +394,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(capacity, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(capacity, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
Iterator it = jsonObject.keys();
|
||||
System.out.println();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
String value = jsonObject.getString(key);
|
||||
System.out.println("key: " + key + ",value:" + value);
|
||||
}
|
||||
|
||||
String items = jsonObject.getString("items");
|
||||
System.out.println("items=" + items);
|
||||
|
||||
|
@ -450,19 +412,19 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
) {
|
||||
String status = Content.getString("status");
|
||||
String message = Content.getString("message");
|
||||
//Mysql存在能力节点标识符,status"0" message"成功" 有对应的设备型号
|
||||
|
||||
if (String.valueOf(v.getId()).equals(id)) {
|
||||
Assert.assertEquals(status, "0");
|
||||
Assert.assertEquals(message, "成功");
|
||||
String capacity1 = Content.getString("capacity");
|
||||
//解析capacity 数组
|
||||
//解析capacityArray
|
||||
System.out.print("capacity=" + capacity1);
|
||||
JSONArray json1 = JSONArray.fromObject(capacity1);
|
||||
for (int j = 0; j < json1.size(); j++) {
|
||||
JSONObject capContent = json1.getJSONObject(j);
|
||||
Assert.assertNotEquals(capContent.getString("type") ,"-1");
|
||||
Assert.assertNotEquals(capContent.getString("type"), "-1");
|
||||
Assert.assertNotEquals(capContent.getString("tolCapacity"), "-1");
|
||||
Assert.assertNotEquals( capContent.getString("usedCapacity"), "-1");
|
||||
Assert.assertNotEquals(capContent.getString("usedCapacity"), "-1");
|
||||
}
|
||||
} else {
|
||||
Assert.assertNotEquals(status, "0");
|
||||
|
@ -502,12 +464,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(capacityAll, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(capacityAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
|
@ -525,7 +482,6 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
if (decs != null && decs.size() > 0) {
|
||||
for (DisposeDevice v : decs
|
||||
) {
|
||||
//Mysql存在能力节点标识符,status"0" message"成功" 有对应的设备型号
|
||||
if (String.valueOf(v.getId()).equals(id)) {
|
||||
Assert.assertEquals(status, "0");
|
||||
Assert.assertEquals(message, "成功");
|
||||
|
@ -546,7 +502,6 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -579,12 +534,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.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";
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(protectedIp, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(protectedIp, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
|
@ -616,7 +566,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
Assert.assertNotEquals(String.valueOf(dis.getDisposeIp()), null);
|
||||
//String[] disposeIps = dis.getDisposeIp().split(",");
|
||||
//for (String disposeIp : disposeIps) {
|
||||
//Assert.assertTrue(disposeIp.matches(regex));
|
||||
//Assert.assertTrue(disposeIp.matches(regex));
|
||||
//}
|
||||
}
|
||||
} else {
|
||||
|
@ -658,12 +608,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.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";
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(protectedIpAll, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(protectedIpAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
|
@ -737,23 +682,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.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";
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(nodeList, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(nodeList, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
Iterator it = jsonObject.keys();
|
||||
System.out.println();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
String value = jsonObject.getString(key);
|
||||
System.out.println("key: " + key + ",value:" + value);
|
||||
}
|
||||
|
||||
String items = jsonObject.getString("items");
|
||||
System.out.print("items=" + items);
|
||||
|
||||
|
@ -816,23 +748,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.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";
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(nodeListAll, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(nodeListAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
Iterator it = jsonObject.keys();
|
||||
System.out.println();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
String value = jsonObject.getString(key);
|
||||
System.out.println("key: " + key + ",value:" + value);
|
||||
}
|
||||
|
||||
String items = jsonObject.getString("items");
|
||||
System.out.print("items=" + items);
|
||||
|
||||
|
@ -896,23 +815,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
|
||||
String cap = null;
|
||||
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";
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(disposeNodeDetails, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(disposeNodeDetails, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
Iterator it = jsonObject.keys();
|
||||
System.out.println();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
String value = jsonObject.getString(key);
|
||||
System.out.println("key: " + key + ",value:" + value);
|
||||
}
|
||||
|
||||
String items = jsonObject.getString("items");
|
||||
System.out.print("items=" + items);
|
||||
|
||||
|
@ -937,7 +843,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(Content.getString("version"));
|
||||
Assert.assertNotNull(Content.getString("readme"));
|
||||
|
||||
//解析capacity 数组
|
||||
//解析capacityArray
|
||||
if (Content.getString("capacity") != null) {
|
||||
cap = Content.getString("capacity");
|
||||
}
|
||||
|
@ -1001,23 +907,10 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
|
||||
String cap = null;
|
||||
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";
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(disposeNodeDetailsAll, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(disposeNodeDetailsAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
Iterator it = jsonObject.keys();
|
||||
System.out.println();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
String value = jsonObject.getString(key);
|
||||
System.out.println("key: " + key + ",value:" + value);
|
||||
}
|
||||
|
||||
String items = jsonObject.getString("items");
|
||||
System.out.print("items=" + items);
|
||||
|
||||
|
@ -1042,7 +935,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
Assert.assertNotNull(Content.getString("version"));
|
||||
Assert.assertNotNull(Content.getString("readme"));
|
||||
|
||||
//解析capacity 数组
|
||||
//解析capacityArray
|
||||
if (Content.getString("capacity") != null) {
|
||||
cap = Content.getString("capacity");
|
||||
}
|
||||
|
@ -1100,11 +993,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.getContentAsString();
|
||||
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(linkstatus, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(linkstatus, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
net.sf.json.JSONArray json = JSONArray.fromObject(msgContent);
|
||||
|
@ -1157,12 +1046,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<ErrorCode, String>(ErrorCode.class);
|
||||
ret = verifyRep(linkStatusAll, reqTimeStamp);
|
||||
ErrorCode err = ret.keySet().iterator().next();
|
||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||
|
||||
String msgContent = ret.get(err);
|
||||
String msgContent = verifyRep(linkStatusAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
net.sf.json.JSONArray json = JSONArray.fromObject(msgContent);
|
||||
|
@ -1191,18 +1075,19 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void t8_getNodeAllRunTaskAll() throws Exception {
|
||||
public void t8_getNodeAllRunTask() throws Exception {
|
||||
IDArrayReq reqData = IDArrayReq.builder()
|
||||
.id(new String[]{})
|
||||
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
||||
.build();
|
||||
|
||||
Long reqTimeStamp = System.currentTimeMillis();
|
||||
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||
reqInfo.setTimeStamp(reqTimeStamp);
|
||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
String runTask = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
|
@ -1212,21 +1097,141 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
String taskArray = null;
|
||||
String msgContent = verifyRep(runTask, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
String items = jsonObject.getString("items");
|
||||
System.out.print("items=" + items);
|
||||
|
||||
net.sf.json.JSONArray json = JSONArray.fromObject(items);
|
||||
for (int i = 0; i < json.size(); i++) {
|
||||
JSONObject Content = json.getJSONObject(i);
|
||||
String status = Content.getString("status");
|
||||
String message = Content.getString("message");
|
||||
String id = Content.getString("id");
|
||||
|
||||
List<DisposeDevice> decs = disposeNodeManager.getAllDisposeDevice();
|
||||
if (decs != null && decs.size() > 0) {
|
||||
for (DisposeDevice v : decs) {
|
||||
if (String.valueOf(v.getId()).equals(id)) {
|
||||
//解析taskArray
|
||||
if (Content.getString("taskArray") != null) {
|
||||
taskArray = Content.getString("taskArray");
|
||||
}
|
||||
|
||||
net.sf.json.JSONArray taskInfos = JSONArray.fromObject(taskArray);
|
||||
List<?> list = JSONArray.toList(taskInfos, new TaskInfoData(), new JsonConfig());
|
||||
for (Object o : list) {
|
||||
TaskInfoData taskInfo = (TaskInfoData) o;
|
||||
Assert.assertNotEquals(taskInfo.getTaskId(), -1);
|
||||
Assert.assertNotEquals(String.valueOf(taskInfo.getType()), -1);
|
||||
Assert.assertNotEquals(String.valueOf(taskInfo.getStartTime()), -1);
|
||||
Assert.assertNotEquals(String.valueOf(taskInfo.getDisposeTime()), -1);
|
||||
Assert.assertNotEquals(taskInfo.getDisposeIp().length(), 0);
|
||||
Assert.assertNotNull(taskInfo.getFlowAttack());
|
||||
Assert.assertNotNull(taskInfo.getFlowClean());
|
||||
Assert.assertEquals(status, "0");
|
||||
Assert.assertEquals(message, "成功");
|
||||
}
|
||||
} else {
|
||||
Assert.assertNotEquals(status, "0");
|
||||
Assert.assertNotEquals(message, "成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void t8_getNodeAllRunTaskAll() throws Exception {
|
||||
IDArrayReq reqData = IDArrayReq.builder()
|
||||
.id(new String[]{})
|
||||
.build();
|
||||
|
||||
Long reqTimeStamp = System.currentTimeMillis();
|
||||
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||
reqInfo.setTimeStamp(reqTimeStamp);
|
||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||
|
||||
String runTaskAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/run_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(200))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
String taskArray = null;
|
||||
String msgContent = verifyRep(runTaskAll, reqTimeStamp);
|
||||
System.out.print("msgContent=" + msgContent);
|
||||
|
||||
org.json.JSONObject jsonObject = new org.json.JSONObject(msgContent);
|
||||
String items = jsonObject.getString("items");
|
||||
System.out.print("items=" + items);
|
||||
|
||||
net.sf.json.JSONArray json = JSONArray.fromObject(items);
|
||||
for (int i = 0; i < json.size(); i++) {
|
||||
JSONObject Content = json.getJSONObject(i);
|
||||
String status = Content.getString("status");
|
||||
String message = Content.getString("message");
|
||||
String id = Content.getString("id");
|
||||
|
||||
List<DisposeDevice> decs = disposeNodeManager.getAllDisposeDevice();
|
||||
if (decs != null && decs.size() > 0) {
|
||||
for (DisposeDevice v : decs) {
|
||||
if (String.valueOf(v.getId()).equals(id)) {
|
||||
//解析taskArray
|
||||
if (Content.getString("taskArray") != null) {
|
||||
taskArray = Content.getString("taskArray");
|
||||
}
|
||||
|
||||
net.sf.json.JSONArray taskInfos = JSONArray.fromObject(taskArray);
|
||||
List<?> list = JSONArray.toList(taskInfos, new TaskInfoData(), new JsonConfig());
|
||||
for (Object o : list) {
|
||||
TaskInfoData taskInfo = (TaskInfoData) o;
|
||||
Assert.assertNotEquals(taskInfo.getTaskId(), -1);
|
||||
Assert.assertNotEquals(String.valueOf(taskInfo.getType()), -1);
|
||||
Assert.assertNotEquals(String.valueOf(taskInfo.getStartTime()), -1);
|
||||
Assert.assertNotEquals(String.valueOf(taskInfo.getDisposeTime()), -1);
|
||||
Assert.assertNotEquals(taskInfo.getDisposeIp().length(), 0);
|
||||
Assert.assertNotNull(taskInfo.getFlowAttack());
|
||||
Assert.assertNotNull(taskInfo.getFlowClean());
|
||||
Assert.assertEquals(status, "0");
|
||||
Assert.assertEquals(message, "成功");
|
||||
}
|
||||
} else {
|
||||
Assert.assertNotEquals(status, "0");
|
||||
Assert.assertNotEquals(message, "成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void t9_getNodeAllTask() throws Exception {
|
||||
IDArrayReq reqData = IDArrayReq.builder()
|
||||
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
||||
.build();
|
||||
|
||||
Long reqTimeStamp = System.currentTimeMillis();
|
||||
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||
reqInfo.setTimeStamp(reqTimeStamp);
|
||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
String taskAll = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/information/all_task")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer " + getLogToken())
|
||||
|
@ -1238,6 +1243,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
|||
.getContentAsString();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void t9_getNodeAllTaskAll() throws Exception {
|
||||
IDArrayReq reqData = IDArrayReq.builder()
|
||||
|
|
Loading…
Reference in New Issue