parent
a5fec56ecc
commit
c922aa6b39
|
@ -369,7 +369,7 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void b6_loginUsernameTypeExceptionTest() throws Exception {
|
||||
public void b6_loginUsernameIntExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
|
||||
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":1}\"}";
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package com.dispose.test.controller;
|
||||
|
||||
import com.dispose.common.GlobalVar;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.vo.common.IDReturnStatus;
|
||||
import com.dispose.pojo.vo.device.AddNodeRsp;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.vo.device.AddNodeRetData;
|
||||
import com.dispose.service.DisposeNodeManager;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
|
@ -25,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||
|
@ -575,7 +579,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040,\"msgContent\":\"{\\\"id\\\":123}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.delete("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
|
@ -585,11 +589,12 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
AddNodeRetData rspInfo = objectMapper.readValue(verifyResp(ret), AddNodeRetData.class);
|
||||
IDReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), IDReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
}
|
||||
/**
|
||||
* B 6 del device node id empty exception test.
|
||||
|
@ -601,7 +606,7 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040,\"msgContent\":\"{\\\"id\\\":[]}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.put("/manager/device")
|
||||
.delete("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
|
@ -611,10 +616,107 @@ public class DeviceNodeManagerControllerQATest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
AddNodeRetData rspInfo = objectMapper.readValue(verifyResp(ret), AddNodeRetData.class);
|
||||
IDReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), IDReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
}
|
||||
/**
|
||||
* B 7 del device node id not exit exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void b7_delDeviceNodeIdNotExitExceptionTest() throws Exception {
|
||||
//String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040,\"msgContent\":\"{\\\"id\\\":[\\\"1\\\",\\\"666\\\"]}\"}";
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040,\"msgContent\":\"{\\\"id\\\":[\\\"555\\\"]}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.delete("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.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();
|
||||
|
||||
List<IDReturnStatus> delNodeList = objectMapper.readValue(verifyResp(ret), new TypeReference<List<IDReturnStatus>>() {});
|
||||
|
||||
for (IDReturnStatus rspInfo : delNodeList) {
|
||||
Assert.assertNotNull(rspInfo);
|
||||
Assert.assertNotNull(rspInfo.getId());
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
if (verifyDeviceIdExists(rspInfo.getId())) {
|
||||
Assert.assertEquals(String.valueOf(rspInfo.getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
} else {
|
||||
Assert.assertEquals(String.valueOf(rspInfo.getStatus()), String.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
}
|
||||
|
||||
// if (rspInfo.getStatus() == 0) {
|
||||
// Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
// Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_OK.getMsg());
|
||||
// } else if (rspInfo.getStatus() == 19) {
|
||||
// Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_NOSUCHDEVICE.getCode()));
|
||||
// Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_NOSUCHDEVICE.getMsg());
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* B 8 del device node id string character exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void b8_delDeviceNodeIdStingChaExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604308040,\"msgContent\":\"{\\\"id\\\":[\\\"bbb\\\"]}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.delete("/manager/device")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
IDReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), IDReturnStatus.class);
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
}
|
||||
/**
|
||||
* Verify device id exists boolean.
|
||||
*
|
||||
* @param deviceId the device id
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean verifyDeviceIdExists(String deviceId) {
|
||||
boolean exists = false;
|
||||
List<DisposeDevice> decs = disposeNodeManager.getAllDisposeDevice();
|
||||
|
||||
if (decs != null && decs.size() > 0) {
|
||||
for (DisposeDevice d : decs) {
|
||||
if (String.valueOf(d.getId()).equals(deviceId)) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue