refactor(接口测试): 优化报告结构
This commit is contained in:
parent
33b110cd22
commit
cd57414bd2
|
@ -15,10 +15,12 @@ import io.metersphere.sdk.constants.ApiReportStatus;
|
|||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.domain.EnvironmentGroup;
|
||||
import io.metersphere.sdk.dto.api.result.RequestResult;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.mapper.EnvironmentGroupMapper;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.sdk.util.*;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.SubListUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
||||
import io.metersphere.system.mapper.UserMapper;
|
||||
import io.metersphere.system.service.UserLoginService;
|
||||
|
@ -195,10 +197,16 @@ public class ApiScenarioReportService {
|
|||
List<ApiScenarioReportStepDTO> deatilList = extApiScenarioReportMapper.selectStepDeatilByReportId(id);
|
||||
//根据stepId进行分组
|
||||
Map<String, List<ApiScenarioReportStepDTO>> detailMap = deatilList.stream().collect(Collectors.groupingBy(ApiScenarioReportStepDTO::getStepId));
|
||||
//只处理请求的
|
||||
List<String> stepTypes = Arrays.asList(ApiScenarioStepType.API_CASE.name(),
|
||||
ApiScenarioStepType.API.name(),
|
||||
ApiScenarioStepType.CUSTOM_REQUEST.name());
|
||||
scenarioReportSteps.parallelStream().forEach(step -> {
|
||||
if (stepTypes.contains(step.getStepType())) {
|
||||
List<ApiScenarioReportStepDTO> details = detailMap.get(step.getStepId());
|
||||
if (CollectionUtils.isNotEmpty(details)) {
|
||||
if (CollectionUtils.isNotEmpty(details) && details.size() > 1) {
|
||||
details.sort(Comparator.comparingLong(ApiScenarioReportStepDTO::getLoopIndex));
|
||||
if (details.size() > 1) {
|
||||
//需要重新处理sort
|
||||
for (int i = 0; i < details.size(); i++) {
|
||||
ApiScenarioReportStepDTO detail = details.get(i);
|
||||
|
@ -207,12 +215,7 @@ public class ApiScenarioReportService {
|
|||
detail.setStepType(step.getStepType());
|
||||
detail.setName(detail.getRequestName());
|
||||
}
|
||||
step.setChildren(details);
|
||||
//只处理请求的
|
||||
List<String> stepTypes = Arrays.asList(ApiScenarioStepType.API_CASE.name(),
|
||||
ApiScenarioStepType.API.name(),
|
||||
ApiScenarioStepType.CUSTOM_REQUEST.name());
|
||||
if (stepTypes.contains(step.getStepType())) {
|
||||
|
||||
step.setRequestTime(details.stream().mapToLong(ApiScenarioReportStepDTO::getRequestTime).sum());
|
||||
step.setResponseSize(details.stream().mapToLong(ApiScenarioReportStepDTO::getResponseSize).sum());
|
||||
List<String> requestStatus = details.stream().map(ApiScenarioReportStepDTO::getStatus).toList();
|
||||
|
@ -227,6 +230,15 @@ public class ApiScenarioReportService {
|
|||
step.setStatus(ApiReportStatus.PENDING.name());
|
||||
}
|
||||
}
|
||||
step.setChildren(details);
|
||||
} else if (CollectionUtils.isNotEmpty(details)){
|
||||
step.setName(details.getFirst().getRequestName());
|
||||
step.setReportId(details.getFirst().getReportId());
|
||||
step.setRequestTime(details.getFirst().getRequestTime());
|
||||
step.setResponseSize(details.getFirst().getResponseSize());
|
||||
step.setStatus(details.getFirst().getStatus());
|
||||
step.setScriptIdentifier(details.getFirst().getScriptIdentifier());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -235,6 +247,7 @@ public class ApiScenarioReportService {
|
|||
// TODO 查询修改
|
||||
List<ApiScenarioReportStepDTO> steps = Optional.ofNullable(scenarioReportStepMap.get("NONE")).orElse(new ArrayList<>(0));
|
||||
steps.sort(Comparator.comparingLong(ApiScenarioReportStepDTO::getSort));
|
||||
|
||||
getStepTree(steps, scenarioReportStepMap);
|
||||
|
||||
scenarioReportDTO.setStepTotal(steps.size());
|
||||
|
|
|
@ -24,10 +24,10 @@ public class OperationLogModule {
|
|||
public static final String API_TEST_MANAGEMENT_MOCK = "API_TEST_MANAGEMENT_MOCK";
|
||||
public static final String API_TEST_MANAGEMENT_CASE = "API_TEST_MANAGEMENT_CASE";
|
||||
// 场景管理
|
||||
public static final String API_SCENARIO_MANAGEMENT_SCENARIO = "API_SCENARIO_MANAGEMENT_SCENARIO";
|
||||
public static final String API_SCENARIO_MANAGEMENT_SCENARIO = "API_TEST_SCENARIO";
|
||||
public static final String API_SCENARIO_MANAGEMENT_MODULE = "API_SCENARIO_MANAGEMENT_MODULE";
|
||||
|
||||
public static final String API_REPORT = "API_REPORT";
|
||||
public static final String API_REPORT = "API_TEST_REPORT";
|
||||
public static final String AUTH_TITLE = "AUTH_TITLE";
|
||||
public static final String PROJECT_ENVIRONMENT_SETTING = "PROJECT_ENVIRONMENT_SETTING";
|
||||
public static final String PROJECT_PROJECT_MANAGER = "PROJECT_PROJECT_MANAGER";
|
||||
|
|
|
@ -95,7 +95,7 @@ export const pathMap: PathMapItem[] = [
|
|||
},
|
||||
{
|
||||
key: 'API_TEST_MANAGEMENT_RECYCLE', // 接口测试-回收站
|
||||
locale: 'menu.apiTest.management.bugRecycle',
|
||||
locale: 'menu.bugManagement.bugRecycle',
|
||||
route: RouteEnum.API_TEST_MANAGEMENT_RECYCLE,
|
||||
permission: [],
|
||||
level: MENU_LEVEL[2],
|
||||
|
@ -103,7 +103,7 @@ export const pathMap: PathMapItem[] = [
|
|||
],
|
||||
},
|
||||
{
|
||||
key: 'API_TEST_SCENARIO', // 接口测试-场景
|
||||
key: 'API_SCENARIO_MANAGEMENT_SCENARIO', // 接口测试-场景
|
||||
locale: 'menu.apiTest.scenario',
|
||||
route: RouteEnum.API_TEST_SCENARIO,
|
||||
permission: [],
|
||||
|
@ -111,7 +111,7 @@ export const pathMap: PathMapItem[] = [
|
|||
children: [
|
||||
{
|
||||
key: 'API_TEST_SCENARIO_RECYCLE', // 接口测试-回收站
|
||||
locale: 'menu.apiTest.scenario.bugRecycle',
|
||||
locale: 'menu.bugManagement.bugRecycle',
|
||||
route: RouteEnum.API_TEST_SCENARIO_RECYCLE,
|
||||
permission: [],
|
||||
level: MENU_LEVEL[2],
|
||||
|
|
Loading…
Reference in New Issue