Merge remote-tracking branch 'origin/v2.0.0_dev' into v2.0.0_dev
This commit is contained in:
commit
7b90ef9005
|
@ -19,6 +19,7 @@ import com.dispose.pojo.dto.protocol.device.manager.AddDeviceReq;
|
|||
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceRet;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceRsp;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.BasePagesGetReq;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.CommDeviceListRsp;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.DeviceInfoRsp;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceRsp;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
|
@ -219,8 +220,8 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ProtocolRespDTO<List<DeviceInfoRsp>> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<List<DeviceInfoRsp>>>() {
|
||||
ProtocolRespDTO<CommDeviceListRsp> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<CommDeviceListRsp>>() {
|
||||
});
|
||||
|
||||
verifyRespProtocol(rspInfo);
|
||||
|
@ -229,7 +230,7 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
|
||||
List<DisposeDevice> decsAfter = disposeDeviceMapper.selectAll();
|
||||
|
||||
for (DeviceInfoRsp d : rspInfo.getMsgContent()
|
||||
for (DeviceInfoRsp d : rspInfo.getMsgContent().getItems()
|
||||
) {
|
||||
//before: device information exists after: no device information
|
||||
boolean before = false;
|
||||
|
@ -258,10 +259,10 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
|
||||
if (before && after) {
|
||||
Assert.assertEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(d.getDevStatus(), ObjectStatus.DELETED);
|
||||
Assert.assertEquals(d.getDevStatus(), ObjectStatus.DELETED.getValue());
|
||||
} else {
|
||||
Assert.assertNotEquals(Long.valueOf(d.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertNotEquals(d.getDevStatus(), ObjectStatus.DELETED);
|
||||
Assert.assertNotEquals(d.getDevStatus(), ObjectStatus.DELETED.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -335,15 +336,15 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ProtocolRespDTO<List<DeviceInfoRsp>> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<List<DeviceInfoRsp>>>() {
|
||||
ProtocolRespDTO<CommDeviceListRsp> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<CommDeviceListRsp>>() {
|
||||
});
|
||||
|
||||
verifyRespProtocol(rspInfo);
|
||||
|
||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||
|
||||
for (DeviceInfoRsp deviceInfoRsp : rspInfo.getMsgContent()
|
||||
for (DeviceInfoRsp deviceInfoRsp : rspInfo.getMsgContent().getItems()
|
||||
) {
|
||||
|
||||
List<MulReturnType<Long, String>> beforeDev = beforeRed.stream()
|
||||
|
@ -409,8 +410,6 @@ public class DisposeDeviceManagerControllerTest extends InitTestEnvironment {
|
|||
|
||||
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);
|
||||
|
|
|
@ -23,7 +23,6 @@ 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;
|
||||
|
@ -44,7 +43,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
@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 DisposeInfoControllerTest extends InitTestEnvironment {
|
||||
|
@ -71,34 +69,34 @@ public class DisposeInfoControllerTest extends InitTestEnvironment {
|
|||
*/
|
||||
@Test
|
||||
public void a1_getAllDisposeDeviceAreaInfo() throws Exception {
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.get("/info/areaInfo")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", ConstValue.STRING_HTTP_AUTH_HEAD + getLoginToken())
|
||||
.content(objectMapper.writeValueAsString(null)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(HttpStatus.ok().status()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ProtocolRespDTO<GetAreaInfoRsp> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<GetAreaInfoRsp>>() {
|
||||
});
|
||||
|
||||
verifyRespProtocol(rspInfo);
|
||||
|
||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||
|
||||
Assert.assertEquals(String.valueOf(rspInfo.getMsgContent().getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMsgContent().getMessage()[0], ErrorCode.ERR_OK.getMsg());
|
||||
|
||||
rspInfo.getMsgContent().getItems().forEach(v -> {
|
||||
Assert.assertNotNull(v.getNodeId());
|
||||
Assert.assertNotNull(v.getTotalNetflow());
|
||||
Assert.assertNotNull(v.getOnlineDevices());
|
||||
Assert.assertNotNull(v.getCapacityType());
|
||||
});
|
||||
// String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
// .get("/info/areaInfo")
|
||||
// .contentType(MediaType.APPLICATION_JSON)
|
||||
// .header("Authorization", ConstValue.STRING_HTTP_AUTH_HEAD + getLoginToken())
|
||||
// .content(objectMapper.writeValueAsString(null)))
|
||||
// .andDo(print()).andExpect(status().isOk())
|
||||
// .andExpect(jsonPath("$.code").value(HttpStatus.ok().status()))
|
||||
// .andReturn()
|
||||
// .getResponse()
|
||||
// .getContentAsString();
|
||||
//
|
||||
// ProtocolRespDTO<GetAreaInfoRsp> rspInfo = objectMapper.readValue(ret,
|
||||
// new TypeReference<ProtocolRespDTO<GetAreaInfoRsp>>() {
|
||||
// });
|
||||
//
|
||||
// verifyRespProtocol(rspInfo);
|
||||
//
|
||||
// log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||
//
|
||||
// Assert.assertEquals(String.valueOf(rspInfo.getMsgContent().getStatus()), String.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
// Assert.assertEquals(rspInfo.getMsgContent().getMessage()[0], ErrorCode.ERR_OK.getMsg());
|
||||
//
|
||||
// rspInfo.getMsgContent().getItems().forEach(v -> {
|
||||
// Assert.assertNotNull(v.getNodeId());
|
||||
// Assert.assertNotNull(v.getTotalNetflow());
|
||||
// Assert.assertNotNull(v.getOnlineDevices());
|
||||
// Assert.assertNotNull(v.getCapacityType());
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,9 +7,9 @@ import com.dispose.common.DisposeConfigValue;
|
|||
import com.dispose.common.DisposeTaskStatus;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.NetflowDirection;
|
||||
import com.dispose.common.ObjectStatus;
|
||||
import com.dispose.common.ProtoCryptoType;
|
||||
import com.dispose.mapper.DisposeTaskMapper;
|
||||
import com.dispose.pojo.dto.protocol.base.BaseIdResp;
|
||||
import com.dispose.pojo.dto.protocol.base.IdArraysReq;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
|
@ -17,7 +17,9 @@ import com.dispose.pojo.dto.protocol.device.manager.BasePagesGetReq;
|
|||
import com.dispose.pojo.dto.protocol.task.GetTaskRsp;
|
||||
import com.dispose.pojo.dto.protocol.task.TaskStartMulRsp;
|
||||
import com.dispose.pojo.dto.protocol.task.TaskStartReq;
|
||||
import com.dispose.pojo.dto.protocol.task.TaskStartRsp;
|
||||
import com.dispose.pojo.dto.protocol.task.TaskStopItem;
|
||||
import com.dispose.pojo.dto.protocol.task.TaskStopRsp;
|
||||
import com.dispose.pojo.entity.DisposeTask;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.DisposeDeviceManagerService;
|
||||
|
@ -46,6 +48,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
|
@ -126,8 +129,8 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ProtocolRespDTO<BaseIdResp> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<BaseIdResp>>() {
|
||||
ProtocolRespDTO<TaskStartRsp> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<TaskStartRsp>>() {
|
||||
});
|
||||
|
||||
verifyRespProtocol(rspInfo);
|
||||
|
@ -187,14 +190,14 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
|
|||
.getContentAsString();
|
||||
|
||||
|
||||
ProtocolRespDTO<BaseIdResp> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<BaseIdResp>>() {
|
||||
ProtocolRespDTO<TaskStartRsp> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<TaskStartRsp>>() {
|
||||
});
|
||||
|
||||
verifyRespProtocol(rspInfo);
|
||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMsgContent().getStatus());
|
||||
Assert.assertNotNull(rspInfo.getMsgContent());
|
||||
|
||||
if (disposeTask.getCurrentStatus() == DisposeTaskStatus.TASK_FINISHED ||
|
||||
disposeTask.getCurrentStatus() == DisposeTaskStatus.TASK_CANCELED ||
|
||||
|
@ -217,7 +220,10 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
|
|||
List<String> taskIds = new ArrayList<>();
|
||||
List<String> runTaskIds = new ArrayList<>();
|
||||
|
||||
disposeTaskMapper.selectAll().forEach(v -> taskIds.add(String.valueOf(v.getId())));
|
||||
List<DisposeTask> devices = disposeTaskMapper.selectAll().stream().limit(20)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
devices.forEach(v -> taskIds.add(String.valueOf(v.getId())));
|
||||
|
||||
disposeTaskMapper.selectAll().forEach(v -> {
|
||||
if (v.getCurrentStatus() == DisposeTaskStatus.TASK_NEW ||
|
||||
|
@ -251,14 +257,13 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
|
|||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ProtocolRespDTO<List<TaskStopItem>> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<List<TaskStopItem>>>() {
|
||||
ProtocolRespDTO<TaskStopRsp> rspInfo = objectMapper.readValue(ret, new TypeReference<ProtocolRespDTO<TaskStopRsp>>() {
|
||||
});
|
||||
|
||||
verifyRespProtocol(rspInfo);
|
||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||
|
||||
for (TaskStopItem t : rspInfo.getMsgContent()
|
||||
for (TaskStopItem t : rspInfo.getMsgContent().getItems()
|
||||
) {
|
||||
Assert.assertNotNull(t.getTaskId());
|
||||
Assert.assertNotNull(t.getStatus());
|
||||
|
|
|
@ -84,8 +84,8 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
|||
// 初始化设备
|
||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||
|
||||
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS.getValue(), -1L);
|
||||
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.2", DisposeCapacityType.CLEANUP,
|
||||
NetflowDirection.DIRECTION_BI, DDoSAttackType.CLDAP_AMPLIFICATION.getValue(), -1L);
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
}
|
||||
|
@ -126,8 +126,9 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
|||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||
|
||||
Assert.assertTrue(db.getDeviceLinkStatus());
|
||||
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
NetflowDirection.DIRECTION_BI, DDoSAttackType.ALL_ATTACKS.getValue(), -1L);
|
||||
|
||||
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.2", DisposeCapacityType.CLEANUP,
|
||||
NetflowDirection.DIRECTION_BI, DDoSAttackType.CLDAP_AMPLIFICATION.getValue(), -1L);
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
}
|
||||
|
|
|
@ -158,8 +158,6 @@ public class DisposeCapacityMapperTest {
|
|||
Assert.assertEquals(disposeCapacityMapper.addNewDisposeCapacity(newCapList), newCapList.size());
|
||||
|
||||
Assert.assertNotEquals(disposeCapacityMapper.delDeviceDisposeCapacity(newCapList.get(0).getDeviceId()), 0);
|
||||
|
||||
Assert.assertEquals(0, disposeCapacityMapper.selectAll().size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,8 +193,6 @@ public class DisposeCapacityMapperTest {
|
|||
|
||||
List<DisposeCapacity> capList = disposeCapacityMapper.getDeviceDisposeCapacity(newCapList.get(0).getDeviceId());
|
||||
|
||||
Assert.assertEquals(capList.size(), caps.size() + newCapList.size());
|
||||
|
||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(capList));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,21 +112,22 @@ public class DisposeTaskServiceTest extends InitTestEnvironment {
|
|||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
Assert.assertNotNull(ret.getSecondParam());
|
||||
Assert.assertEquals(String.valueOf(ret.getSecondParam().getDisposeCapacity()), String.valueOf(DisposeCapacityType.CLEANUP));
|
||||
} else {
|
||||
Assert.assertNotEquals(ret.getFirstParam().getCode(), ErrorCode.ERR_OK.getCode());
|
||||
}
|
||||
|
||||
Assert.assertEquals(ret.getSecondParam().getId(), disposeTaskManager.getDisposeTask(newTask.getDeviceId(),
|
||||
newTask.getDisposeIp(), newTask.getDisposeCapacity()).getId());
|
||||
disposeTaskManager.getExpiredTasks().forEach(v->{
|
||||
disposeTaskManager.changeDisposeTaskStatus(v.getId(), DisposeTaskStatus.TASK_NEW);
|
||||
|
||||
ret = disposeTaskService.createTask(newTask);
|
||||
MulReturnType<ErrorCode, DisposeTask> result = disposeTaskService.createTask(v);
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam().getCode(), ErrorCode.ERR_TASKRUNNING.getCode());
|
||||
Assert.assertEquals(ret.getSecondParam().getId(), disposeTaskManager.getDisposeTask(newTask.getDeviceId(),
|
||||
Assert.assertEquals(result.getFirstParam().getCode(), ErrorCode.ERR_TASKRUNNING.getCode());
|
||||
Assert.assertEquals(result.getSecondParam().getId(), disposeTaskManager.getDisposeTask(newTask.getDeviceId(),
|
||||
newTask.getDisposeIp(), newTask.getDisposeCapacity()).getId());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* creat task mul return type.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue