Merge branch 'v2.0.0_dev' of git.komect.net:DDOSAQ/phoenix_ddos_handle into v2.0.0_dev
This commit is contained in:
commit
eeab55f940
|
@ -236,7 +236,7 @@ public class DisposeDeviceManagerController {
|
|||
*/
|
||||
@PostMapping("/device_list")
|
||||
@ResponseBody
|
||||
@ApiOperation("删除处置能力节点")
|
||||
@ApiOperation("获取处置能力节点")
|
||||
public ProtocolRespDTO<? extends BaseRespStatus> getAllDisposeDevice(
|
||||
@Validated(ValidGroups.ProtocolCommonValid.class)
|
||||
@RequestBody ProtocolReqDTO<GetDeviceReq> mr) {
|
||||
|
|
|
@ -340,9 +340,6 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(afterDev));
|
||||
|
||||
if (deviceInfoRsp.getStatus() == ErrorCode.ERR_OK.getCode()) {
|
||||
log.info("+++++++++++++++++++++before{}", beforeDev.get(0).getSecondParam());
|
||||
log.info("+++++++++++++++++++++after{}", afterDev.getVersion());
|
||||
|
||||
Assert.assertNotNull(deviceInfoRsp);
|
||||
Assert.assertNotNull(deviceInfoRsp.getId());
|
||||
Assert.assertNotNull(deviceInfoRsp.getMessage());
|
||||
|
@ -352,4 +349,60 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* D 1 get dispose device.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void d1_getAllDisposeDevice() throws Exception {
|
||||
List<DisposeDevice> deviceList = disposeDeviceMapper.selectAll();
|
||||
|
||||
GetDeviceReq getReq = new GetDeviceReq();
|
||||
|
||||
for (int i = 1; i < 5; i++) {
|
||||
getReq.setStartPage(i);
|
||||
getReq.setPageSize(String.valueOf(i * 10));
|
||||
|
||||
ProtocolReqDTO<GetDeviceReq> reqInfo = new ProtocolReqDTO<>();
|
||||
|
||||
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||
reqInfo.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode());
|
||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||
reqInfo.setMsgContent(getReq);
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/manager/device_list")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", ConstValue.STRING_HTTP_AUTH_HEAD + getLoginToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(HttpStatus.ok().status()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ProtocolRespDTO<GetDeviceRsp> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<GetDeviceRsp>>() {
|
||||
});
|
||||
|
||||
verifyRespProtocol(rspInfo);
|
||||
|
||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||
|
||||
double totalPages = Math.ceil(deviceList.size() / Double.parseDouble(getReq.getPageSize()));
|
||||
|
||||
Assert.assertEquals(rspInfo.getMsgContent().getCurPageNumber(), getReq.getStartPage());
|
||||
Assert.assertEquals(String.valueOf(rspInfo.getMsgContent().getPageSize()), String.valueOf(getReq.getPageSize()));
|
||||
Assert.assertEquals(String.valueOf(rspInfo.getMsgContent().getTotalItems()), String.valueOf(deviceList.size()));
|
||||
Assert.assertEquals(Double.valueOf(rspInfo.getMsgContent().getTotalPages()), Double.valueOf(totalPages));
|
||||
|
||||
if(totalPages >= (double)(getReq.getStartPage())){
|
||||
Assert.assertNotEquals(rspInfo.getMsgContent().getItems().size(), 0);
|
||||
}else{
|
||||
Assert.assertEquals(rspInfo.getMsgContent().getItems().size(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.dispose.test.service;
|
||||
|
||||
import com.dispose.common.*;
|
||||
import com.dispose.mapper.DisposeDeviceMapper;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.DisposeDeviceManagerService;
|
||||
|
@ -8,6 +9,7 @@ import com.dispose.service.UserAccountService;
|
|||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -56,6 +58,12 @@ public class DisposeDeviceManagerServiceTest extends InitTestEnvironment {
|
|||
*/
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
/**
|
||||
* The Object mapper.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeDeviceMapper disposeDeviceMapper;
|
||||
|
||||
/**
|
||||
* User login test.
|
||||
*
|
||||
|
@ -216,4 +224,60 @@ public class DisposeDeviceManagerServiceTest extends InitTestEnvironment {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A 4 get all dispose device test.
|
||||
*/
|
||||
@Test
|
||||
public void a4_getAllDisposeDeviceTest(){
|
||||
List<DisposeDevice> devs = disposeDeviceMapper.selectAll();
|
||||
|
||||
for (int i = 1; i < 5; i++) {
|
||||
Integer startPage = i;
|
||||
Integer pageSize = i * 2;
|
||||
|
||||
MulReturnType<PageInfo<DisposeDevice>, List<DisposeDevice>> ret = disposeDeviceManagerService.getAllDisposeDevice(startPage, pageSize);
|
||||
|
||||
PageInfo<DisposeDevice> pageInfo = ret.getFirstParam();
|
||||
List<DisposeDevice> deviceList = ret.getSecondParam();
|
||||
Assert.assertEquals(pageInfo.getPageNum(), (long) startPage);
|
||||
Assert.assertEquals(pageInfo.getPageSize(), (long) pageSize);
|
||||
|
||||
//数据库设备信息数据量比较大
|
||||
if (devs.size() >= (startPage * pageSize)) {
|
||||
if (pageInfo.getPageNum() != 1) {
|
||||
Assert.assertFalse(pageInfo.isIsFirstPage());
|
||||
Assert.assertTrue(pageInfo.isHasPreviousPage());
|
||||
Assert.assertEquals(pageInfo.getPrePage(), startPage - 1);
|
||||
} else {
|
||||
Assert.assertTrue(pageInfo.isIsFirstPage());
|
||||
Assert.assertFalse(pageInfo.isHasPreviousPage());
|
||||
}
|
||||
|
||||
if ((deviceList.size() - startPage * pageSize) / pageSize >= 0) {
|
||||
Assert.assertNotEquals(deviceList.size(), 0);
|
||||
} else {
|
||||
Assert.assertEquals(deviceList.size(), 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (pageInfo.getPageNum() != 1) {
|
||||
Assert.assertFalse(pageInfo.isIsFirstPage());
|
||||
Assert.assertTrue(pageInfo.isHasPreviousPage());
|
||||
Assert.assertEquals(pageInfo.getPrePage(), startPage - 1);
|
||||
} else {
|
||||
Assert.assertTrue(pageInfo.isIsFirstPage());
|
||||
Assert.assertFalse(pageInfo.isHasNextPage());
|
||||
}
|
||||
|
||||
if ((deviceList.size() - startPage * pageSize) / pageSize >= 0) {
|
||||
Assert.assertNotEquals(deviceList.size(), 0);
|
||||
} else {
|
||||
Assert.assertEquals(deviceList.size(), 0);
|
||||
}
|
||||
|
||||
Assert.assertFalse(pageInfo.isHasNextPage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue