refactor(接口测试): 场景增加执行历史查询
This commit is contained in:
parent
074787aaee
commit
5a67c18bda
|
@ -1,6 +1,5 @@
|
|||
package io.metersphere.sdk.file;
|
||||
|
||||
import io.metersphere.plugin.sdk.util.PluginUtils;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.minio.*;
|
||||
|
@ -50,7 +49,7 @@ public class MinioRepository implements FileRepository {
|
|||
try {
|
||||
Object serverUrl = minioConfig.get(ENDPOINT).toString();
|
||||
if (ObjectUtils.isNotEmpty(serverUrl)) {
|
||||
LogUtils.info("开始初始化MinIO插件。配置:{}", PluginUtils.toJSONString(minioConfig));
|
||||
LogUtils.info("开始初始化MinIO插件");
|
||||
// 创建 MinioClient 客户端
|
||||
client = MinioClient.builder()
|
||||
.endpoint(minioConfig.get(ENDPOINT).toString())
|
||||
|
|
|
@ -206,7 +206,7 @@ public class ApiTestCaseController {
|
|||
@Operation(summary = "接口测试-接口管理-接口用例-获取执行历史")
|
||||
@RequiresPermissions(logical = Logical.OR, value = {PermissionConstants.PROJECT_API_DEFINITION_CASE_READ, PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE})
|
||||
@CheckOwner(resourceId = "#request.getId()", resourceType = "api_test_case")
|
||||
public Pager<List<ApiCaseReportDTO>> getExecuteList(@Validated @RequestBody ApiCaseExecutePageRequest request) {
|
||||
public Pager<List<ExecuteReportDTO>> getExecuteList(@Validated @RequestBody ExecutePageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "start_time desc");
|
||||
return PageUtils.setPageInfo(page, apiTestCaseService.getExecuteList(request));
|
||||
|
|
|
@ -4,12 +4,16 @@ import com.github.pagehelper.Page;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.api.constants.ApiResource;
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.dto.definition.ExecutePageRequest;
|
||||
import io.metersphere.api.dto.definition.ExecuteReportDTO;
|
||||
import io.metersphere.api.dto.scenario.*;
|
||||
import io.metersphere.api.service.ApiValidateService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioLogService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioNoticeService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.dto.OperationHistoryDTO;
|
||||
import io.metersphere.system.dto.request.OperationHistoryRequest;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
|
@ -208,5 +212,24 @@ public class ApiScenarioController {
|
|||
apiScenarioService.editPos(request);
|
||||
}
|
||||
|
||||
@PostMapping("/execute/page")
|
||||
@Operation(summary = "接口测试-接口场景管理-场景-获取执行历史")
|
||||
@RequiresPermissions(logical = Logical.OR, value = {PermissionConstants.PROJECT_API_SCENARIO_READ, PermissionConstants.PROJECT_API_SCENARIO_UPDATE})
|
||||
@CheckOwner(resourceId = "#request.getId()", resourceType = "api_scenario")
|
||||
public Pager<List<ExecuteReportDTO>> getExecuteList(@Validated @RequestBody ExecutePageRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "start_time desc");
|
||||
return PageUtils.setPageInfo(page, apiScenarioService.getExecuteList(request));
|
||||
}
|
||||
|
||||
@PostMapping("/operation-history/page")
|
||||
@Operation(summary = "接口测试-接口场景管理-场景-接口变更历史")
|
||||
@RequiresPermissions(logical = Logical.OR, value = {PermissionConstants.PROJECT_API_SCENARIO_READ, PermissionConstants.PROJECT_API_SCENARIO_UPDATE})
|
||||
@CheckOwner(resourceId = "#request.getSourceId()", resourceType = "api_scenario")
|
||||
public Pager<List<OperationHistoryDTO>> operationHistoryList(@Validated @RequestBody OperationHistoryRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
||||
return PageUtils.setPageInfo(page, apiScenarioService.operationHistoryList(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@ import java.io.Serializable;
|
|||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ApiCaseExecutePageRequest extends BasePageRequest implements Serializable {
|
||||
public class ExecutePageRequest extends BasePageRequest implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "用例pk")
|
||||
@Schema(description = "用例id/场景id")
|
||||
@NotBlank(message = "{api_test_case.id.not_blank}")
|
||||
@Size(min = 1, max = 50, message = "{api_test_case.id.length_range}")
|
||||
private String id;
|
|
@ -6,7 +6,7 @@ import lombok.Data;
|
|||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ApiCaseReportDTO implements Serializable {
|
||||
public class ExecuteReportDTO implements Serializable {
|
||||
@Schema(description = "接口报告pk")
|
||||
private String id;
|
||||
|
|
@ -23,10 +23,12 @@ public class DebugListener {
|
|||
LogUtils.info("接收到执行结果:{}", record.key());
|
||||
if (ObjectUtils.isNotEmpty(record.value()) && WebSocketUtils.has(record.key().toString())) {
|
||||
SocketMsgDTO dto = JSON.parseObject(record.value(), SocketMsgDTO.class);
|
||||
|
||||
LogUtils.info("{} 推送执行结果类型【 {} 】", record.key(), dto.getMsgType());
|
||||
WebSocketUtils.sendMessageSingle(dto);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error("调试消息推送失败:{}", e);
|
||||
LogUtils.error("{} 调试消息推送失败:{}", record.key(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package io.metersphere.api.mapper;
|
||||
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.dto.definition.ExecutePageRequest;
|
||||
import io.metersphere.api.dto.definition.ExecuteReportDTO;
|
||||
import io.metersphere.api.dto.scenario.*;
|
||||
import io.metersphere.dto.TestCaseProviderDTO;
|
||||
import io.metersphere.project.dto.ModuleCountDTO;
|
||||
|
@ -40,4 +42,5 @@ public interface ExtApiScenarioMapper {
|
|||
|
||||
Long getLastPosEdit(@Param("projectId") String projectId, @Param("basePos") Long basePos);
|
||||
|
||||
List<ExecuteReportDTO> getExecuteList(@Param("request") ExecutePageRequest request);
|
||||
}
|
||||
|
|
|
@ -444,4 +444,47 @@
|
|||
</if>
|
||||
order by `pos` desc limit 1;
|
||||
</select>
|
||||
|
||||
<select id="getExecuteList" resultType="io.metersphere.api.dto.definition.ExecuteReportDTO">
|
||||
select
|
||||
api_scenario_report.id,
|
||||
api_scenario_report.name,
|
||||
api_scenario_report.status,
|
||||
api_scenario_report.start_time,
|
||||
api_scenario_report.create_user,
|
||||
api_scenario_report.trigger_mode,
|
||||
api_scenario_report.test_plan_id
|
||||
from api_scenario_report
|
||||
left join api_scenario_record t1 on t1.api_scenario_report_id = api_scenario_report.id
|
||||
where
|
||||
<if test="request.id != null and request.id != ''">
|
||||
t1.api_scenario_id = #{request.id}
|
||||
</if>
|
||||
<include refid="report_filters">
|
||||
<property name="filter" value="request.filter"/>
|
||||
</include>
|
||||
</select>
|
||||
|
||||
<sql id="report_filters">
|
||||
<if test="${filter} != null and ${filter}.size() > 0">
|
||||
<foreach collection="${filter}.entrySet()" index="key" item="values">
|
||||
<if test="values != null and values.size() > 0">
|
||||
<choose>
|
||||
<when test="key=='integrated'">
|
||||
and api_scenario_report.integrated in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='status'">
|
||||
and api_scenario_report.status in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
<when test="key=='triggerMode'">
|
||||
and api_scenario_report.trigger_mode in
|
||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
|
@ -10,12 +10,10 @@ import io.metersphere.request.AssociateOtherCaseRequest;
|
|||
import io.metersphere.request.TestCasePageProviderRequest;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author jianxing
|
||||
|
@ -59,7 +57,7 @@ public interface ExtApiTestCaseMapper {
|
|||
|
||||
List<ApiTestCase> getTagsByIds(@Param("ids") List<String> ids, @Param("deleted") boolean deleted);
|
||||
|
||||
List<ApiCaseReportDTO> getExecuteList(@Param("request") ApiCaseExecutePageRequest request);
|
||||
List<ExecuteReportDTO> getExecuteList(@Param("request") ExecutePageRequest request);
|
||||
|
||||
List<OptionDTO> selectVersionOptionByIds(@Param("ids") List<String> ids);
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getExecuteList" resultType="io.metersphere.api.dto.definition.ApiCaseReportDTO">
|
||||
<select id="getExecuteList" resultType="io.metersphere.api.dto.definition.ExecuteReportDTO">
|
||||
select
|
||||
api_report.id,
|
||||
api_report.name,
|
||||
|
|
|
@ -2,10 +2,7 @@ package io.metersphere.api.service.definition;
|
|||
|
||||
import io.metersphere.api.domain.*;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.mapper.ApiReportDetailMapper;
|
||||
import io.metersphere.api.mapper.ApiReportMapper;
|
||||
import io.metersphere.api.mapper.ApiReportStepMapper;
|
||||
import io.metersphere.api.mapper.ExtApiReportMapper;
|
||||
import io.metersphere.api.mapper.*;
|
||||
import io.metersphere.api.utils.ApiDataUtils;
|
||||
import io.metersphere.sdk.dto.api.result.RequestResult;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
|
@ -47,19 +44,25 @@ public class ApiReportService {
|
|||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
||||
public void insertApiReport(List<ApiReport> reports) {
|
||||
if (CollectionUtils.isNotEmpty(reports)) {
|
||||
public void insertApiReport(List<ApiReport> reports, List<ApiTestCaseRecord> records) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
if (CollectionUtils.isNotEmpty(reports)) {
|
||||
ApiReportMapper reportMapper = sqlSession.getMapper(ApiReportMapper.class);
|
||||
SubListUtils.dealForSubList(reports, 1000, subList -> {
|
||||
subList.forEach(reportMapper::insertSelective);
|
||||
});
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(records)) {
|
||||
ApiTestCaseRecordMapper detailMapper = sqlSession.getMapper(ApiTestCaseRecordMapper.class);
|
||||
SubListUtils.dealForSubList(records, 1000, subList -> {
|
||||
subList.forEach(detailMapper::insertSelective);
|
||||
});
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
if (sqlSessionFactory != null) {
|
||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
||||
public void insertApiReportStep(List<ApiReportStep> reportSteps) {
|
||||
|
|
|
@ -560,8 +560,8 @@ public class ApiTestCaseService {
|
|||
return apiTestCaseBlobMapper.selectByExampleWithBLOBs(example);
|
||||
}
|
||||
|
||||
public List<ApiCaseReportDTO> getExecuteList(ApiCaseExecutePageRequest request) {
|
||||
List<ApiCaseReportDTO> executeList = extApiTestCaseMapper.getExecuteList(request);
|
||||
public List<ExecuteReportDTO> getExecuteList(ExecutePageRequest request) {
|
||||
List<ExecuteReportDTO> executeList = extApiTestCaseMapper.getExecuteList(request);
|
||||
if (CollectionUtils.isEmpty(executeList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
|
|
@ -6,10 +6,7 @@ import io.metersphere.api.dto.definition.ApiReportPageRequest;
|
|||
import io.metersphere.api.dto.scenario.ApiScenarioReportDTO;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioReportDetailDTO;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioReportStepDTO;
|
||||
import io.metersphere.api.mapper.ApiScenarioReportDetailMapper;
|
||||
import io.metersphere.api.mapper.ApiScenarioReportMapper;
|
||||
import io.metersphere.api.mapper.ApiScenarioReportStepMapper;
|
||||
import io.metersphere.api.mapper.ExtApiScenarioReportMapper;
|
||||
import io.metersphere.api.mapper.*;
|
||||
import io.metersphere.api.utils.ApiDataUtils;
|
||||
import io.metersphere.sdk.dto.api.result.RequestResult;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
|
@ -50,19 +47,25 @@ public class ApiScenarioReportService {
|
|||
private ApiScenarioReportDetailMapper apiScenarioReportDetailMapper;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
||||
public void insertApiScenarioReport(List<ApiScenarioReport> reports) {
|
||||
if (CollectionUtils.isNotEmpty(reports)) {
|
||||
public void insertApiScenarioReport(List<ApiScenarioReport> reports, List<ApiScenarioRecord> records) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
if (CollectionUtils.isNotEmpty(reports)) {
|
||||
ApiScenarioReportMapper reportMapper = sqlSession.getMapper(ApiScenarioReportMapper.class);
|
||||
SubListUtils.dealForSubList(reports, 1000, subList -> {
|
||||
subList.forEach(reportMapper::insertSelective);
|
||||
});
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(records)) {
|
||||
ApiScenarioRecordMapper detailMapper = sqlSession.getMapper(ApiScenarioRecordMapper.class);
|
||||
SubListUtils.dealForSubList(records, 1000, subList -> {
|
||||
subList.forEach(detailMapper::insertSelective);
|
||||
});
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
if (sqlSessionFactory != null) {
|
||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
||||
public void insertApiScenarioReportStep(List<ApiScenarioReportStep> reportSteps) {
|
||||
|
|
|
@ -7,6 +7,8 @@ import io.metersphere.api.domain.*;
|
|||
import io.metersphere.api.dto.*;
|
||||
import io.metersphere.api.dto.debug.ApiFileResourceUpdateRequest;
|
||||
import io.metersphere.api.dto.debug.ApiResourceRunRequest;
|
||||
import io.metersphere.api.dto.definition.ExecutePageRequest;
|
||||
import io.metersphere.api.dto.definition.ExecuteReportDTO;
|
||||
import io.metersphere.api.dto.request.MsScenario;
|
||||
import io.metersphere.api.dto.request.http.MsHTTPElement;
|
||||
import io.metersphere.api.dto.response.ApiScenarioBatchOperationResponse;
|
||||
|
@ -54,6 +56,8 @@ import io.metersphere.sdk.util.*;
|
|||
import io.metersphere.system.domain.Schedule;
|
||||
import io.metersphere.system.domain.ScheduleExample;
|
||||
import io.metersphere.system.dto.LogInsertModule;
|
||||
import io.metersphere.system.dto.OperationHistoryDTO;
|
||||
import io.metersphere.system.dto.request.OperationHistoryRequest;
|
||||
import io.metersphere.system.dto.request.ScheduleConfig;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
|
@ -61,6 +65,7 @@ import io.metersphere.system.log.constants.OperationLogType;
|
|||
import io.metersphere.system.mapper.ScheduleMapper;
|
||||
import io.metersphere.system.schedule.ScheduleService;
|
||||
import io.metersphere.system.service.ApiPluginService;
|
||||
import io.metersphere.system.service.OperationHistoryService;
|
||||
import io.metersphere.system.service.UserLoginService;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import io.metersphere.system.uid.NumGenerator;
|
||||
|
@ -86,11 +91,11 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.metersphere.api.controller.result.ApiResultCode.API_SCENARIO_EXIST;
|
||||
|
||||
@Service
|
||||
|
@ -169,12 +174,16 @@ public class ApiScenarioService {
|
|||
@Resource
|
||||
private ApiDefinitionModuleService apiDefinitionModuleService;
|
||||
@Resource
|
||||
private OperationHistoryService operationHistoryService;
|
||||
@Resource
|
||||
private ApiCommonService apiCommonService;
|
||||
|
||||
|
||||
public static final String PRIORITY = "Priority";
|
||||
public static final String STATUS = "Status";
|
||||
public static final String TAGS = "Tags";
|
||||
public static final String ENVIRONMENT = "Environment";
|
||||
private static final String SCENARIO_TABLE = "api_scenario";
|
||||
|
||||
|
||||
public List<ApiScenarioDTO> getScenarioPage(ApiScenarioPageRequest request) {
|
||||
|
@ -2057,6 +2066,28 @@ public class ApiScenarioService {
|
|||
apiScenarioMapper::updateByPrimaryKeySelective);
|
||||
}
|
||||
|
||||
public List<ExecuteReportDTO> getExecuteList(ExecutePageRequest request) {
|
||||
List<ExecuteReportDTO> executeList = extApiScenarioMapper.getExecuteList(request);
|
||||
if (CollectionUtils.isEmpty(executeList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Set<String> userSet = executeList.stream()
|
||||
.flatMap(apiReport -> Stream.of(apiReport.getCreateUser()))
|
||||
.collect(Collectors.toSet());
|
||||
Map<String, String> userMap = userLoginService.getUserNameMap(new ArrayList<>(userSet));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
executeList.forEach(apiReport -> {
|
||||
apiReport.setOperationUser(userMap.get(apiReport.getCreateUser()));
|
||||
Date date = new Date(apiReport.getStartTime());
|
||||
apiReport.setNum(sdf.format(date));
|
||||
});
|
||||
return executeList;
|
||||
}
|
||||
|
||||
public List<OperationHistoryDTO> operationHistoryList(OperationHistoryRequest request) {
|
||||
return operationHistoryService.listWidthTable(request, SCENARIO_TABLE);
|
||||
}
|
||||
|
||||
public void handleFileAssociationUpgrade(FileAssociation originFileAssociation, FileMetadata newFileMetadata) {
|
||||
// 查询有步骤详情的请求类型的步骤
|
||||
List<String> stepIds = extApiScenarioStepMapper.getHasBlobRequestStepIds(originFileAssociation.getSourceId());
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.api.constants.ShareInfoType;
|
|||
import io.metersphere.api.domain.ApiReport;
|
||||
import io.metersphere.api.domain.ApiReportDetail;
|
||||
import io.metersphere.api.domain.ApiReportStep;
|
||||
import io.metersphere.api.domain.ApiTestCaseRecord;
|
||||
import io.metersphere.api.dto.definition.ApiReportBatchRequest;
|
||||
import io.metersphere.api.dto.definition.ApiReportDTO;
|
||||
import io.metersphere.api.dto.definition.ApiReportDetailDTO;
|
||||
|
@ -72,6 +73,7 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
@Order(1)
|
||||
public void testInsert() {
|
||||
List<ApiReport> reports = new ArrayList<>();
|
||||
List<ApiTestCaseRecord> records = new ArrayList<>();
|
||||
for (int i = 0; i < 2515; i++) {
|
||||
ApiReport apiReport = new ApiReport();
|
||||
apiReport.setId("api-report-id" + i);
|
||||
|
@ -92,8 +94,12 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
apiReport.setVersionId("api-version-id" + i);
|
||||
reports.add(apiReport);
|
||||
ApiTestCaseRecord record = new ApiTestCaseRecord();
|
||||
record.setApiTestCaseId("api-resource-id" + i);
|
||||
record.setApiReportId(apiReport.getId());
|
||||
records.add(record);
|
||||
}
|
||||
apiReportService.insertApiReport(reports);
|
||||
apiReportService.insertApiReport(reports, records);
|
||||
|
||||
List<ApiReportStep> steps = new ArrayList<>();
|
||||
for (int i = 0; i < 1515; i++) {
|
||||
|
@ -240,7 +246,10 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
apiReport.setTriggerMode("api-trigger-mode");
|
||||
apiReport.setVersionId("api-version-id");
|
||||
reports.add(apiReport);
|
||||
apiReportService.insertApiReport(reports);
|
||||
ApiTestCaseRecord record = new ApiTestCaseRecord();
|
||||
record.setApiTestCaseId("api-resource-id");
|
||||
record.setApiReportId(apiReport.getId());
|
||||
apiReportService.insertApiReport(reports, List.of(record));
|
||||
List<ApiReportStep> steps = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ApiReportStep apiReportStep = new ApiReportStep();
|
||||
|
@ -294,7 +303,7 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
List<ApiReportDetailDTO> data = ApiDataUtils.parseArray(JSON.toJSONString(parseResponse(mvcResult).get("data")), ApiReportDetailDTO.class);
|
||||
Assertions.assertNotNull(data);
|
||||
|
||||
mockMvc.perform(getRequestBuilder(DETAIL + "test"))
|
||||
mockMvc.perform(getRequestBuilder(DETAIL + "test" + "/test"))
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().is5xxServerError());
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.domain.ApiReport;
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.domain.ApiScenarioReport;
|
||||
import io.metersphere.api.domain.ApiTestCase;
|
||||
import io.metersphere.api.domain.*;
|
||||
import io.metersphere.api.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.api.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.api.service.ApiReportSendNoticeService;
|
||||
|
@ -78,6 +75,7 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
apiTestCaseMapper.insert(apiTestCase);
|
||||
|
||||
List<ApiReport> reports = new ArrayList<>();
|
||||
List<ApiTestCaseRecord> records = new ArrayList<>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ApiReport apiReport = new ApiReport();
|
||||
apiReport.setId("send-api-case-report-id" + i);
|
||||
|
@ -100,8 +98,12 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
apiReport.setVersionId("api-version-id" + i);
|
||||
reports.add(apiReport);
|
||||
ApiTestCaseRecord record = new ApiTestCaseRecord();
|
||||
record.setApiTestCaseId("send-api-resource-id" + i);
|
||||
record.setApiReportId(apiReport.getId());
|
||||
records.add(record);
|
||||
}
|
||||
apiReportService.insertApiReport(reports);
|
||||
apiReportService.insertApiReport(reports, records);
|
||||
ApiNoticeDTO noticeDTO = new ApiNoticeDTO();
|
||||
noticeDTO.setReportId("send-api-case-report-id0");
|
||||
noticeDTO.setReportStatus(ApiReportStatus.SUCCESS.name());
|
||||
|
@ -140,6 +142,7 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
apiScenarioMapper.insertSelective(apiScenario);
|
||||
|
||||
List<ApiScenarioReport> scenarioReports = new ArrayList<>();
|
||||
List<ApiScenarioRecord> scenarioRecords = new ArrayList<>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ApiScenarioReport scenarioReport = new ApiScenarioReport();
|
||||
scenarioReport.setId("send-scenario-report-id" + i);
|
||||
|
@ -162,8 +165,12 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
scenarioReport.setTriggerMode("api-trigger-mode" + i);
|
||||
scenarioReport.setVersionId("api-version-id" + i);
|
||||
scenarioReports.add(scenarioReport);
|
||||
ApiScenarioRecord record = new ApiScenarioRecord();
|
||||
record.setApiScenarioId("send-scenario-id" + i);
|
||||
record.setApiScenarioReportId(scenarioReport.getId());
|
||||
scenarioRecords.add(record);
|
||||
}
|
||||
apiScenarioReportService.insertApiScenarioReport(scenarioReports);
|
||||
apiScenarioReportService.insertApiScenarioReport(scenarioReports, scenarioRecords);
|
||||
|
||||
|
||||
noticeDTO = new ApiNoticeDTO();
|
||||
|
|
|
@ -5,9 +5,7 @@ import io.metersphere.api.domain.*;
|
|||
import io.metersphere.api.dto.ApiFile;
|
||||
import io.metersphere.api.dto.assertion.MsAssertionConfig;
|
||||
import io.metersphere.api.dto.debug.ModuleCreateRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionAddRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseAddRequest;
|
||||
import io.metersphere.api.dto.definition.HttpResponse;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.dto.request.http.Header;
|
||||
import io.metersphere.api.dto.request.http.MsHTTPElement;
|
||||
import io.metersphere.api.dto.request.http.QueryParam;
|
||||
|
@ -23,6 +21,7 @@ import io.metersphere.api.service.BaseResourcePoolTestService;
|
|||
import io.metersphere.api.service.definition.ApiDefinitionModuleService;
|
||||
import io.metersphere.api.service.definition.ApiDefinitionService;
|
||||
import io.metersphere.api.service.definition.ApiTestCaseService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioService;
|
||||
import io.metersphere.api.utils.ApiDataUtils;
|
||||
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
||||
|
@ -31,6 +30,7 @@ import io.metersphere.project.api.assertion.MsResponseCodeAssertion;
|
|||
import io.metersphere.project.api.assertion.MsScriptAssertion;
|
||||
import io.metersphere.project.api.processor.MsProcessor;
|
||||
import io.metersphere.project.api.processor.SQLProcessor;
|
||||
import io.metersphere.project.domain.ProjectVersion;
|
||||
import io.metersphere.project.dto.environment.EnvironmentConfig;
|
||||
import io.metersphere.project.dto.environment.EnvironmentGroupProjectDTO;
|
||||
import io.metersphere.project.dto.environment.EnvironmentGroupRequest;
|
||||
|
@ -43,6 +43,7 @@ import io.metersphere.project.dto.environment.processors.EnvRequestScriptProcess
|
|||
import io.metersphere.project.dto.environment.processors.EnvScenarioScriptProcessor;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileUploadRequest;
|
||||
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
||||
import io.metersphere.project.mapper.ProjectVersionMapper;
|
||||
import io.metersphere.project.service.EnvironmentGroupService;
|
||||
import io.metersphere.project.service.EnvironmentService;
|
||||
import io.metersphere.project.service.FileMetadataService;
|
||||
|
@ -61,10 +62,13 @@ import io.metersphere.system.base.BaseTest;
|
|||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.domain.Plugin;
|
||||
import io.metersphere.system.domain.Schedule;
|
||||
import io.metersphere.system.dto.OperationHistoryDTO;
|
||||
import io.metersphere.system.dto.request.OperationHistoryRequest;
|
||||
import io.metersphere.system.dto.request.PluginUpdateRequest;
|
||||
import io.metersphere.system.dto.sdk.request.PosRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.mapper.ScheduleMapper;
|
||||
import io.metersphere.system.service.OperationHistoryService;
|
||||
import io.metersphere.system.service.PluginService;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import io.metersphere.system.uid.NumGenerator;
|
||||
|
@ -80,6 +84,7 @@ import org.springframework.http.MediaType;
|
|||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.ResultMatcher;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -90,6 +95,7 @@ import java.util.stream.Collectors;
|
|||
import static io.metersphere.api.controller.result.ApiResultCode.API_SCENARIO_EXIST;
|
||||
import static io.metersphere.sdk.constants.InternalUserRole.ADMIN;
|
||||
import static io.metersphere.system.controller.handler.result.MsHttpResultCode.NOT_FOUND;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
|
@ -162,9 +168,16 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
@Resource
|
||||
private ApiDefinitionModuleService apiDefinitionModuleService;
|
||||
@Resource
|
||||
private ApiScenarioReportService apiScenarioReportService;
|
||||
@Resource
|
||||
private ProjectVersionMapper projectVersionMapper;
|
||||
@Resource
|
||||
private OperationHistoryService operationHistoryService;
|
||||
@Resource
|
||||
private BaseFileManagementTestService baseFileManagementTestService;
|
||||
@Resource
|
||||
private ApiCommonService apiCommonService;
|
||||
|
||||
private static String fileMetadataId;
|
||||
private static String localFileId;
|
||||
private static ApiScenario addApiScenario;
|
||||
|
@ -2194,6 +2207,125 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
public void testExecuteList() throws Exception {
|
||||
ApiScenario first = apiScenarioMapper.selectByExample(new ApiScenarioExample()).getFirst();
|
||||
List<ApiScenarioReport> reports = new ArrayList<>();
|
||||
List<ApiScenarioRecord> records = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ApiScenarioReport apiReport = new ApiScenarioReport();
|
||||
apiReport.setId(IDGenerator.nextStr());
|
||||
apiReport.setProjectId(DEFAULT_PROJECT_ID);
|
||||
apiReport.setName("api-scenario-name" + i);
|
||||
apiReport.setStartTime(System.currentTimeMillis());
|
||||
apiReport.setCreateUser("admin");
|
||||
apiReport.setUpdateUser("admin");
|
||||
apiReport.setUpdateTime(System.currentTimeMillis());
|
||||
apiReport.setPoolId("api-pool-id" + i);
|
||||
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||
apiReport.setRunMode("api-run-mode" + i);
|
||||
if (i % 2 == 0) {
|
||||
apiReport.setStatus(ApiReportStatus.SUCCESS.name());
|
||||
} else {
|
||||
apiReport.setStatus(ApiReportStatus.ERROR.name());
|
||||
}
|
||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
apiReport.setVersionId("api-version-id" + i);
|
||||
reports.add(apiReport);
|
||||
ApiScenarioRecord record = new ApiScenarioRecord();
|
||||
record.setApiScenarioId(first.getId());
|
||||
record.setApiScenarioReportId(apiReport.getId());
|
||||
records.add(record);
|
||||
}
|
||||
apiScenarioReportService.insertApiScenarioReport(reports, records);
|
||||
ExecutePageRequest request = new ExecutePageRequest();
|
||||
request.setId(first.getId());
|
||||
request.setPageSize(10);
|
||||
request.setCurrent(1);
|
||||
MvcResult mvcResult = responsePost(BASE_PATH + "execute/page", request);
|
||||
Pager<?> returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||
//返回值不为空
|
||||
Assertions.assertNotNull(returnPager);
|
||||
request.setFilter(new HashMap<>() {{
|
||||
put("status", List.of(ApiReportStatus.SUCCESS.name()));
|
||||
}});
|
||||
request.setSort(new HashMap<>() {{
|
||||
put("startTime", "desc");
|
||||
}});
|
||||
mvcResult = responsePost(BASE_PATH + "execute/page", request);
|
||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||
//返回值不为空
|
||||
Assertions.assertNotNull(returnPager);
|
||||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||
List<ExecuteReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ExecuteReportDTO.class);
|
||||
reportDTOS.forEach(apiReport -> {
|
||||
Assertions.assertEquals(apiReport.getStatus(), ApiReportStatus.SUCCESS.name());
|
||||
});
|
||||
request.setId("data-is-null");
|
||||
responsePost(BASE_PATH + "execute/page", request);
|
||||
}
|
||||
|
||||
public static <T> T parseObjectFromMvcResult(MvcResult mvcResult, Class<T> parseClass) {
|
||||
try {
|
||||
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
//返回请求正常
|
||||
Assertions.assertNotNull(resultHolder);
|
||||
return JSON.parseObject(JSON.toJSONString(resultHolder.getData()), parseClass);
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private MvcResult responsePost(String url, Object param) throws Exception {
|
||||
return mockMvc.perform(MockMvcRequestBuilders.post(url)
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.content(JSON.toJSONString(param))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
public void testGetHistory() throws Exception {
|
||||
ApiScenario first = apiScenarioMapper.selectByExample(new ApiScenarioExample()).getFirst();
|
||||
OperationHistoryRequest request = new OperationHistoryRequest();
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setSourceId(first.getId());
|
||||
request.setPageSize(10);
|
||||
request.setCurrent(1);
|
||||
|
||||
projectVersionMapper.deleteByPrimaryKey("1.0");
|
||||
ProjectVersion version = new ProjectVersion();
|
||||
version.setId("1.0");
|
||||
version.setName("1.0");
|
||||
version.setProjectId(DEFAULT_PROJECT_ID);
|
||||
version.setCreateTime(System.currentTimeMillis());
|
||||
version.setLatest(true);
|
||||
version.setCreateUser("admin");
|
||||
projectVersionMapper.insertSelective(version);
|
||||
|
||||
MvcResult mvcResult = responsePost(BASE_PATH + "operation-history/page", request);
|
||||
Pager<?> returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||
//返回值不为空
|
||||
Assertions.assertNotNull(returnPager);
|
||||
List<OperationHistoryDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), OperationHistoryDTO.class);
|
||||
reportDTOS.forEach(reportDTO -> Assertions.assertEquals(reportDTO.getSourceId(), first.getId()));
|
||||
|
||||
request = new OperationHistoryRequest();
|
||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||
request.setSourceId("data-is-null");
|
||||
request.setPageSize(10);
|
||||
request.setCurrent(1);
|
||||
request.setSort(new HashMap<>() {{
|
||||
put("createTime", "desc");
|
||||
}});
|
||||
responsePost(BASE_PATH + "operation-history/page", request);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(35)
|
||||
public void testGetSystemRequest() throws Exception {
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.constants.ShareInfoType;
|
||||
import io.metersphere.api.domain.ApiReport;
|
||||
import io.metersphere.api.domain.ApiScenarioReport;
|
||||
import io.metersphere.api.domain.ApiScenarioReportDetail;
|
||||
import io.metersphere.api.domain.ApiScenarioReportStep;
|
||||
import io.metersphere.api.domain.*;
|
||||
import io.metersphere.api.dto.definition.ApiReportBatchRequest;
|
||||
import io.metersphere.api.dto.definition.ApiReportPageRequest;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioDTO;
|
||||
|
@ -71,6 +68,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
@Order(1)
|
||||
public void testInsert() {
|
||||
List<ApiScenarioReport> reports = new ArrayList<>();
|
||||
List<ApiScenarioRecord> records = new ArrayList<>();
|
||||
for (int i = 0; i < 2515; i++) {
|
||||
ApiScenarioReport scenarioReport = new ApiScenarioReport();
|
||||
scenarioReport.setId("scenario-report-id" + i);
|
||||
|
@ -91,8 +89,12 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
scenarioReport.setTriggerMode("api-trigger-mode" + i);
|
||||
scenarioReport.setVersionId("api-version-id" + i);
|
||||
reports.add(scenarioReport);
|
||||
ApiScenarioRecord apiScenarioRecord = new ApiScenarioRecord();
|
||||
apiScenarioRecord.setApiScenarioId("scenario-record-id" + i);
|
||||
apiScenarioRecord.setApiScenarioReportId(scenarioReport.getId());
|
||||
records.add(apiScenarioRecord);
|
||||
}
|
||||
apiScenarioReportService.insertApiScenarioReport(reports);
|
||||
apiScenarioReportService.insertApiScenarioReport(reports, records);
|
||||
|
||||
List<ApiScenarioReportStep> steps = new ArrayList<>();
|
||||
for (int i = 0; i < 1515; i++) {
|
||||
|
@ -239,7 +241,10 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
scenarioReport.setTriggerMode("api-trigger-mode");
|
||||
scenarioReport.setVersionId("api-version-id");
|
||||
reports.add(scenarioReport);
|
||||
apiScenarioReportService.insertApiScenarioReport(reports);
|
||||
ApiScenarioRecord apiScenarioRecord = new ApiScenarioRecord();
|
||||
apiScenarioRecord.setApiScenarioId("test-scenario-record-id");
|
||||
apiScenarioRecord.setApiScenarioReportId(scenarioReport.getId());
|
||||
apiScenarioReportService.insertApiScenarioReport(reports, List.of(apiScenarioRecord));
|
||||
List<ApiScenarioReportStep> steps = new ArrayList<>();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
ApiScenarioReportStep apiScenarioReportStep = new ApiScenarioReportStep();
|
||||
|
@ -299,7 +304,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
List<ApiScenarioReportDTO> data = ApiDataUtils.parseArray(JSON.toJSONString(parseResponse(mvcResult).get("data")), ApiScenarioReportDTO.class);
|
||||
Assertions.assertNotNull(data);
|
||||
|
||||
mockMvc.perform(getRequestBuilder(DETAIL + "test"))
|
||||
mockMvc.perform(getRequestBuilder(DETAIL + "test" + "/" + "test"))
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().is5xxServerError());
|
||||
|
||||
|
@ -350,8 +355,6 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().is5xxServerError());
|
||||
|
||||
//TODO 过期的校验 未完成 需要补充
|
||||
//项目当前设置了分享时间 并且没有过期
|
||||
|
||||
shareInfo = new ShareInfo();
|
||||
shareInfo.setCustomData("test-scenario-report-id".getBytes());
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.domain.ApiReport;
|
||||
import io.metersphere.api.domain.ApiScenarioRecord;
|
||||
import io.metersphere.api.domain.ApiScenarioReport;
|
||||
import io.metersphere.api.domain.ApiTestCaseRecord;
|
||||
import io.metersphere.api.service.BaseResourcePoolTestService;
|
||||
import io.metersphere.api.service.definition.ApiReportService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||
|
@ -226,6 +228,7 @@ public class ApiTaskCenterControllerTests extends BaseTest {
|
|||
|
||||
public void testInsertData() {
|
||||
List<ApiReport> reports = new ArrayList<>();
|
||||
List<ApiTestCaseRecord> records = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ApiReport apiReport = new ApiReport();
|
||||
apiReport.setId("task-report-id" + i);
|
||||
|
@ -246,10 +249,15 @@ public class ApiTaskCenterControllerTests extends BaseTest {
|
|||
apiReport.setTriggerMode("task-MANUAL");
|
||||
apiReport.setVersionId("api-version-id" + i);
|
||||
reports.add(apiReport);
|
||||
ApiTestCaseRecord record = new ApiTestCaseRecord();
|
||||
record.setApiTestCaseId("task-api-resource-id" + i);
|
||||
record.setApiReportId(apiReport.getId());
|
||||
records.add(record);
|
||||
}
|
||||
apiReportService.insertApiReport(reports);
|
||||
apiReportService.insertApiReport(reports, records);
|
||||
|
||||
List<ApiScenarioReport> scenarioReports = new ArrayList<>();
|
||||
List<ApiScenarioRecord> scenarioRecords = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ApiScenarioReport scenarioReport = new ApiScenarioReport();
|
||||
scenarioReport.setId("task-report-id" + i);
|
||||
|
@ -270,8 +278,12 @@ public class ApiTaskCenterControllerTests extends BaseTest {
|
|||
scenarioReport.setTriggerMode("task-MANUAL");
|
||||
scenarioReport.setVersionId("api-version-id" + i);
|
||||
scenarioReports.add(scenarioReport);
|
||||
ApiScenarioRecord scenarioRecord = new ApiScenarioRecord();
|
||||
scenarioRecord.setApiScenarioId("task-api-resource-id" + i);
|
||||
scenarioRecord.setApiScenarioReportId(scenarioReport.getId());
|
||||
scenarioRecords.add(scenarioRecord);
|
||||
}
|
||||
apiScenarioReportService.insertApiScenarioReport(scenarioReports);
|
||||
apiScenarioReportService.insertApiScenarioReport(scenarioReports, scenarioRecords);
|
||||
|
||||
TestResourcePoolDTO testResourcePool = new TestResourcePoolDTO();
|
||||
testResourcePool.setId("api-pool-id");
|
||||
|
|
|
@ -624,9 +624,8 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
record.setApiReportId(apiReport.getId());
|
||||
records.add(record);
|
||||
}
|
||||
apiTestCaseRecordMapper.batchInsert(records);
|
||||
apiReportService.insertApiReport(reports);
|
||||
ApiCaseExecutePageRequest request = new ApiCaseExecutePageRequest();
|
||||
apiReportService.insertApiReport(reports, records);
|
||||
ExecutePageRequest request = new ExecutePageRequest();
|
||||
request.setId(first.getId());
|
||||
request.setPageSize(10);
|
||||
request.setCurrent(1);
|
||||
|
@ -642,7 +641,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
//返回值不为空
|
||||
Assertions.assertNotNull(returnPager);
|
||||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||
List<ApiCaseReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiCaseReportDTO.class);
|
||||
List<ExecuteReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ExecuteReportDTO.class);
|
||||
reportDTOS.forEach(apiReport -> {
|
||||
Assertions.assertEquals(apiReport.getStatus(), ApiReportStatus.SUCCESS.name());
|
||||
});
|
||||
|
@ -849,6 +848,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
request.setSourceId(first.getId());
|
||||
request.setPageSize(10);
|
||||
request.setCurrent(1);
|
||||
projectVersionMapper.deleteByPrimaryKey("1.0");
|
||||
ProjectVersion version = new ProjectVersion();
|
||||
version.setId("1.0");
|
||||
version.setName("1.0");
|
||||
|
|
|
@ -235,6 +235,7 @@ public class CleanupApiTests {
|
|||
|
||||
private void initReportData(String projectId) {
|
||||
List<ApiReport> reports = new ArrayList<>();
|
||||
List<ApiTestCaseRecord> records = new ArrayList<>();
|
||||
for (int i = 0; i < 2515; i++) {
|
||||
ApiReport apiReport = new ApiReport();
|
||||
apiReport.setId("clean-report-id" + projectId + i);
|
||||
|
@ -255,8 +256,12 @@ public class CleanupApiTests {
|
|||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
apiReport.setVersionId("api-version-id" + i);
|
||||
reports.add(apiReport);
|
||||
ApiTestCaseRecord record = new ApiTestCaseRecord();
|
||||
record.setApiTestCaseId("clean-resource-id" + i);
|
||||
record.setApiReportId(apiReport.getId());
|
||||
records.add(record);
|
||||
}
|
||||
apiReportService.insertApiReport(reports);
|
||||
apiReportService.insertApiReport(reports, records);
|
||||
List<ApiReportStep> steps = new ArrayList<>();
|
||||
for (int i = 0; i < 1515; i++) {
|
||||
ApiReportStep apiReportStep = new ApiReportStep();
|
||||
|
@ -269,6 +274,7 @@ public class CleanupApiTests {
|
|||
apiReportService.insertApiReportStep(steps);
|
||||
|
||||
List<ApiScenarioReport> scenarioReports = new ArrayList<>();
|
||||
List<ApiScenarioRecord> scenarioRecords = new ArrayList<>();
|
||||
for (int i = 0; i < 2515; i++) {
|
||||
ApiScenarioReport scenarioReport = new ApiScenarioReport();
|
||||
scenarioReport.setId("clean-scenario-report-id" + projectId + i);
|
||||
|
@ -289,8 +295,12 @@ public class CleanupApiTests {
|
|||
scenarioReport.setTriggerMode("api-trigger-mode" + i);
|
||||
scenarioReport.setVersionId("api-version-id" + i);
|
||||
scenarioReports.add(scenarioReport);
|
||||
ApiScenarioRecord record = new ApiScenarioRecord();
|
||||
record.setApiScenarioId("clean-scenario-id" + i);
|
||||
record.setApiScenarioReportId(scenarioReport.getId());
|
||||
scenarioRecords.add(record);
|
||||
}
|
||||
apiScenarioReportService.insertApiScenarioReport(scenarioReports);
|
||||
apiScenarioReportService.insertApiScenarioReport(scenarioReports, scenarioRecords);
|
||||
|
||||
List<ApiScenarioReportStep> scenarioReportSteps = new ArrayList<>();
|
||||
for (int i = 0; i < 1515; i++) {
|
||||
|
|
Loading…
Reference in New Issue