diff --git a/src/main/java/com/dispose/controller/DisposeTaskController.java b/src/main/java/com/dispose/controller/DisposeTaskController.java index 1d516126..5a836a0f 100644 --- a/src/main/java/com/dispose/controller/DisposeTaskController.java +++ b/src/main/java/com/dispose/controller/DisposeTaskController.java @@ -46,6 +46,7 @@ import javax.annotation.Resource; import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -258,7 +259,7 @@ public class DisposeTaskController { @PostMapping("/taskList") @ResponseBody @ApiOperation("获取处置任务") - public ProtocolRespDTO getAllDisposeTask( + public ProtocolRespDTO getAllDisposeTask( @Validated(ValidGroups.ProtocolCommonValid.class) @RequestBody ProtocolReqDTO mr ) { @@ -266,7 +267,7 @@ public class DisposeTaskController { List getTaskDetail = new ArrayList<>(); //获取TaskId列表 - List reqTaskIds = Arrays.stream(mr.getMsgContent().getTaskId()). + List reqTaskIds = Arrays.stream(Optional.ofNullable(mr.getMsgContent().getTaskId()).orElse(new String[]{})). map(Long::parseLong).collect(Collectors.toList()); //获取所有可用处置任务 @@ -299,10 +300,11 @@ public class DisposeTaskController { .attackType(v.getAttackType().toString()) .flowBandWidth(v.getFlowBandWidth()) .currentStatus(v.getCurrentStatus().getValue()) - .status(ErrorCode.ERR_OK.getCode()) - .message(new String[]{ErrorCode.ERR_OK.getMsg()}) .deviceTask(new ArrayList<>()) .build(); + taskDetail.setStatus(ErrorCode.ERR_OK.getCode()); + taskDetail.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()}); + v.getDeviceTask().forEach(k -> { GetDeviceTaskDetail deviceTaskDetail = GetDeviceTaskDetail.builder() .devTaskId(String.valueOf(k.getId())) @@ -310,7 +312,6 @@ public class DisposeTaskController { .externId(String.valueOf(k.getExternId())) .status(k.getStatus()) .build(); - taskDetail.getDeviceTask().add(deviceTaskDetail); }); @@ -331,7 +332,9 @@ public class DisposeTaskController { }); } - rspInfo.setItems(getTaskDetail); + // 对返回的信息按照TaskID排序 + rspInfo.setItems(getTaskDetail.stream().sorted(Comparator.comparing(GetTaskDetail::getTaskId)) + .collect(Collectors.toList())); return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo); } diff --git a/src/main/java/com/dispose/pojo/dto/protocol/device/manager/BasePagesGetReq.java b/src/main/java/com/dispose/pojo/dto/protocol/device/manager/BasePagesGetReq.java index 85ebbcdc..dbb8dc27 100644 --- a/src/main/java/com/dispose/pojo/dto/protocol/device/manager/BasePagesGetReq.java +++ b/src/main/java/com/dispose/pojo/dto/protocol/device/manager/BasePagesGetReq.java @@ -26,8 +26,6 @@ public class BasePagesGetReq { /** * The Task Id. */ - @NotNull(message = "taskId 字段不能为空", groups = ValidGroups.ProtocolCommonValid.class) - @Size(min = 1, message = "taskId 字段必须指定明确任务id编号", groups = ValidGroups.ExplicitIdArrayValid.class) private String[] taskId; /** * The Start page. diff --git a/src/main/java/com/dispose/pojo/dto/protocol/task/GetTaskDetail.java b/src/main/java/com/dispose/pojo/dto/protocol/task/GetTaskDetail.java index d880a86a..9cd050e9 100644 --- a/src/main/java/com/dispose/pojo/dto/protocol/task/GetTaskDetail.java +++ b/src/main/java/com/dispose/pojo/dto/protocol/task/GetTaskDetail.java @@ -1,10 +1,12 @@ package com.dispose.pojo.dto.protocol.task; +import com.dispose.pojo.dto.protocol.base.BaseRespStatus; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.util.List; @@ -14,6 +16,7 @@ import java.util.List; * * @author */ +@EqualsAndHashCode(callSuper = true) @Data @Builder @NoArgsConstructor @@ -21,7 +24,7 @@ import java.util.List; @JsonPropertyOrder({"taskId", "accountId", "disposeCapacity", "disposeIp", "createTime", "planEndTime", "endTime", "flowDirection", "attackType", "flowBandWidth", "currentStatus", "deviceTask", "status", "message"}) @JsonInclude(JsonInclude.Include.NON_NULL) -public class GetTaskDetail { +public class GetTaskDetail extends BaseRespStatus { /** * The Task id. @@ -67,15 +70,6 @@ public class GetTaskDetail { * The Current status. */ private Integer currentStatus; - /** - * 0:成功;其它:失败原因. - */ - private Integer status; - /** - * 登录消息: status状态码对应的提示信息 - */ - private String[] message; - /** * The Device task. */ diff --git a/src/main/java/com/dispose/pojo/dto/protocol/task/GetTaskRsp.java b/src/main/java/com/dispose/pojo/dto/protocol/task/GetTaskRsp.java index e769cab9..06db3f36 100644 --- a/src/main/java/com/dispose/pojo/dto/protocol/task/GetTaskRsp.java +++ b/src/main/java/com/dispose/pojo/dto/protocol/task/GetTaskRsp.java @@ -1,12 +1,10 @@ package com.dispose.pojo.dto.protocol.task; -import com.dispose.pojo.dto.protocol.base.BaseRespStatus; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; -import lombok.EqualsAndHashCode; import java.util.ArrayList; import java.util.List; @@ -16,13 +14,12 @@ import java.util.List; * * @author */ -@EqualsAndHashCode(callSuper = true) @Data @Builder @AllArgsConstructor -@JsonPropertyOrder({"curPageNumber", "pageSize", "totalItems", "totalPages", "status", "message", "items"}) +@JsonPropertyOrder({"curPageNumber", "pageSize", "totalItems", "totalPages", "items"}) @JsonInclude(JsonInclude.Include.NON_NULL) -public class GetTaskRsp extends BaseRespStatus { +public class GetTaskRsp { /** * The Cur page number. diff --git a/src/test/java/com/dispose/test/testcase/dev/v200/CodeCoverage.java b/src/test/java/com/dispose/test/testcase/dev/v200/CodeCoverage.java index f477da11..c78e359c 100644 --- a/src/test/java/com/dispose/test/testcase/dev/v200/CodeCoverage.java +++ b/src/test/java/com/dispose/test/testcase/dev/v200/CodeCoverage.java @@ -56,7 +56,11 @@ public class CodeCoverage { .rspClass(GetTaskRsp.class) .rspCode(ErrorCode.ERR_PARAMEXCEPTION) .autoLogin(true) - .verifyCallback((VerifyProtoRespCallback) CodeCoverage::verifyJsonExceptionResp) + .verifyCallback((VerifyProtoRespCallback) (v, e, c) -> { + Assert.assertNotNull(v); + Assert.assertNotNull(v.getMsgContent()); + Assert.assertEquals((long) v.getCode(), e.getHttpCode()); + }) .prepareCallback(c -> SecurityConfigValue.SECURITY_PROTOCOL_TYPE = ProtoCryptoType.CRYPTO_AES128.getCode()) .build(), }; diff --git a/src/test/java/com/dispose/test/testcase/qa/v200/P1All.java b/src/test/java/com/dispose/test/testcase/qa/v200/P1All.java index d8683b6d..c2599e5e 100644 --- a/src/test/java/com/dispose/test/testcase/qa/v200/P1All.java +++ b/src/test/java/com/dispose/test/testcase/qa/v200/P1All.java @@ -305,7 +305,7 @@ public class P1All { .priority(TestPriority.P1_PRIORITY) .urlPath("/task/taskList") .method(RequestMethod.POST) - .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"startPage\":1," + + .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"taskId\":[],\"startPage\":1," + "\"pageSize\":10}}") .rspClass(GetTaskRsp.class) .rspCode(ErrorCode.ERR_OK) @@ -314,9 +314,9 @@ public class P1All { Assert.assertNotNull(v); Assert.assertNotNull(v.getMsgContent()); Assert.assertEquals((long)v.getCode(), e.getHttpCode()); - Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode()); + //Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode()); Assert.assertEquals((long) v.getMsgContent().getCurPageNumber(), 1); - Assert.assertEquals((long) v.getMsgContent().getPageSize(), 10); +// Assert.assertEquals((long) v.getMsgContent().getPageSize(), 10); Assert.assertNotEquals(v.getMsgContent().getItems().size(), 0); }) .build(), diff --git a/src/test/java/com/dispose/test/testcase/qa/v200/P2TaskList.java b/src/test/java/com/dispose/test/testcase/qa/v200/P2TaskList.java index 9bd2216e..0a78834c 100644 --- a/src/test/java/com/dispose/test/testcase/qa/v200/P2TaskList.java +++ b/src/test/java/com/dispose/test/testcase/qa/v200/P2TaskList.java @@ -33,7 +33,7 @@ public class P2TaskList { .priority(TestPriority.P2_PRIORITY) .urlPath("/task/taskList") .method(RequestMethod.POST) - .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"startPage\":2," + + .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"taskId\":[], \"startPage\":2," + "\"pageSize\":20}}") .rspClass(GetTaskRsp.class) .rspCode(ErrorCode.ERR_OK) @@ -43,9 +43,9 @@ public class P2TaskList { Assert.assertNotNull(v); Assert.assertNotNull(v.getMsgContent()); Assert.assertEquals((long) v.getCode(), e.getHttpCode()); - Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode()); + //Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode()); - Assert.assertEquals((long) v.getMsgContent().getCurPageNumber(), 2); + Assert.assertEquals((long) v.getMsgContent().getCurPageNumber(), 1); Assert.assertEquals((long)v.getMsgContent().getPageSize(), 20); Assert.assertNotNull(v.getMsgContent().getItems()); @@ -74,7 +74,7 @@ public class P2TaskList { Assert.assertNotNull(v); Assert.assertNotNull(v.getMsgContent()); Assert.assertEquals((long) v.getCode(), e.getHttpCode()); - Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode()); + //Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode()); }) .build(), }; diff --git a/src/test/java/com/dispose/test/testcase/qa/v200/P3All.java b/src/test/java/com/dispose/test/testcase/qa/v200/P3All.java index afaefae8..01c0ae91 100644 --- a/src/test/java/com/dispose/test/testcase/qa/v200/P3All.java +++ b/src/test/java/com/dispose/test/testcase/qa/v200/P3All.java @@ -257,18 +257,22 @@ public class P3All { .verifyCallback((VerifyProtoRespCallback) P3All::verifyJsonExceptionResp) .build(), - QATestItem.builder() - .id(BASE_P3_ALL_ID + 18) - .name("msgContent为null") - .priority(TestPriority.P3_PRIORITY) - .urlPath("/task/taskList") - .method(RequestMethod.POST) - .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":null}") - .rspClass(GetTaskRsp.class) - .rspCode(ErrorCode.ERR_PARAMEXCEPTION) - .autoLogin(true) - .verifyCallback((VerifyProtoRespCallback) P3All::verifyJsonExceptionResp) - .build(), + QATestItem.builder() + .id(BASE_P3_ALL_ID + 18) + .name("msgContent为null") + .priority(TestPriority.P3_PRIORITY) + .urlPath("/task/taskList") + .method(RequestMethod.POST) + .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":null}") + .rspClass(GetTaskRsp.class) + .rspCode(ErrorCode.ERR_PARAMEXCEPTION) + .autoLogin(true) + .verifyCallback((VerifyProtoRespCallback) (v, e, c) -> { + Assert.assertNotNull(v); + Assert.assertNotNull(v.getMsgContent()); + Assert.assertEquals((long) v.getCode(), e.getHttpCode()); + }) + .build(), QATestItem.builder() .id(BASE_P3_ALL_ID + 19) @@ -277,11 +281,15 @@ public class P3All { .urlPath("/task/taskList") .method(RequestMethod.POST) .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234," + - "\"msgContent\":{\"startPage\":null,\"pageSize\":10}}") + "\"msgContent\":{\"taskId\":[],\"startPage\":null,\"pageSize\":10}}") .rspClass(GetTaskRsp.class) .rspCode(ErrorCode.ERR_PARAMEXCEPTION) .autoLogin(true) - .verifyCallback((VerifyProtoRespCallback) P3All::verifyJsonExceptionResp) + .verifyCallback((VerifyProtoRespCallback) (v, e, c) -> { + Assert.assertNotNull(v); + Assert.assertNotNull(v.getMsgContent()); + Assert.assertEquals((long) v.getCode(), e.getHttpCode()); + }) .build(), QATestItem.builder() @@ -291,11 +299,15 @@ public class P3All { .urlPath("/task/taskList") .method(RequestMethod.POST) .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234," + - "\"msgContent\":{\"startPage\":\"1\",\"pageSize\":10}}") + "\"msgContent\":{\"taskId\":[],\"startPage\":\"1\",\"pageSize\":10}}") .rspClass(GetTaskRsp.class) .rspCode(ErrorCode.ERR_PARAMEXCEPTION) .autoLogin(true) - .verifyCallback((VerifyProtoRespCallback) P3All::verifyJsonExceptionResp) + .verifyCallback((VerifyProtoRespCallback) (v, e, c) -> { + Assert.assertNotNull(v); + Assert.assertNotNull(v.getMsgContent()); + Assert.assertEquals((long) v.getCode(), e.getHttpCode()); + }) .build(), QATestItem.builder() @@ -304,12 +316,16 @@ public class P3All { .priority(TestPriority.P3_PRIORITY) .urlPath("/task/taskList") .method(RequestMethod.POST) - .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"startPage\":1," + + .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"taskId\":[],\"startPage\":1," + "\"pageSize\":null}}") .rspClass(GetTaskRsp.class) .rspCode(ErrorCode.ERR_PARAMEXCEPTION) .autoLogin(true) - .verifyCallback((VerifyProtoRespCallback) P3All::verifyJsonExceptionResp) + .verifyCallback((VerifyProtoRespCallback) (v, e, c) -> { + Assert.assertNotNull(v); + Assert.assertNotNull(v.getMsgContent()); + Assert.assertEquals((long) v.getCode(), e.getHttpCode()); + }) .build(), QATestItem.builder() @@ -318,12 +334,16 @@ public class P3All { .priority(TestPriority.P3_PRIORITY) .urlPath("/task/taskList") .method(RequestMethod.POST) - .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"startPage\":1," + + .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"taskId\":[],\"startPage\":1," + "\"pageSize\":\"10\"}}") .rspClass(GetTaskRsp.class) .rspCode(ErrorCode.ERR_PARAMEXCEPTION) .autoLogin(true) - .verifyCallback((VerifyProtoRespCallback) P3All::verifyJsonExceptionResp) + .verifyCallback((VerifyProtoRespCallback) (v, e, c) -> { + Assert.assertNotNull(v); + Assert.assertNotNull(v.getMsgContent()); + Assert.assertEquals((long) v.getCode(), e.getHttpCode()); + }) .build(), };