fix: 部分缺陷

This commit is contained in:
wenyann 2021-04-26 19:24:50 +08:00 committed by 刘瑞斌
parent a0db35359c
commit caec40d1ff
5 changed files with 30 additions and 9 deletions

View File

@ -208,7 +208,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
//环境
String name = apiAutomationService.get(debugReportId).getName();
//时间
Long time = apiTestCaseWithBLOBs.getUpdateTime();
Long time = apiTestCaseWithBLOBs.getCreateTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String executionTime = null;
String time_ = String.valueOf(time);
@ -286,7 +286,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
String executionEnvironment = apiScenario.getScenarioDefinition();
JSONObject json = JSONObject.parseObject(executionEnvironment);
String name = "";
if (json.getString("environmentMap").length() > 0) {
if (json.getString("environmentMap").length() > 2) {
JSONObject environment = JSONObject.parseObject(json.getString("environmentMap"));
String environmentId = environment.get(apiScenario.getProjectId()).toString();
name = apiAutomationService.get(environmentId).getName();
@ -363,13 +363,13 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
String subject = "";
String event = "";
if (StringUtils.equals(ReportTriggerMode.API.name(), report.getTriggerMode())) {
successContext = "接口测试 API任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行成功" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "【接口定义暂无报告链接】" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测路径" + url + "\n" + "(新版)接口测试路径" + url2;
failedContext = "接口测试 API任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行失败" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "【接口定义暂无报告链接】" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
successContext = "接口测试 API任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行成功" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测路径" + url + "\n" + "(新版)接口测试路径" + url2;
failedContext = "接口测试 API任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行失败" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
subject = Translator.get("task_notification_jenkins");
}
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), report.getTriggerMode())) {
successContext = "接口测试定时任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行成功" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "【接口定义暂无报告链接】" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
failedContext = "接口测试定时任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行失败" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "【接口定义暂无报告链接】" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
successContext = "接口测试定时任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行成功" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
failedContext = "接口测试定时任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行失败" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
subject = Translator.get("task_notification");
}
if (StringUtils.equals("Success", report.getStatus())) {

View File

@ -14,6 +14,9 @@ public interface ExtTestPlanLoadCaseMapper {
List<TestPlanLoadCaseDTO> selectByIdIn(@Param("request") LoadCaseRequest request);
void updateCaseStatus(@Param("reportId") String reportId, @Param("status") String status);
void updateCaseStatusByApi(@Param("testPlanId") String testPlanId, @Param("loadCaseId") String loadCaseId, @Param("status") String status);
List<String> getStatusByTestPlanId(@Param("planId") String planId);
List<String> selectTestPlanLoadCaseId(@Param("request") LoadCaseRequest request);

View File

@ -6,16 +6,22 @@
set status = #{status}
where tplc.load_report_id = #{reportId}
</update>
<update id="updateCaseStatusByApi">
update test_plan_load_case tplc
set status = #{status}
where tplc.load_case_id = #{loadCaseId}
and tplc.test_plan_id = #{testPlanId}
</update>
<select id="selectIdsNotInPlan" resultType="java.lang.String">
select load_test.id
from load_test
where load_test.project_id = #{request.projectId}
<if test="request.name != null and request.name != ''">
and load_test.name like CONCAT('%', #{request.name},'%')
and load_test.name like CONCAT('%', #{request.name},'%')
</if>
and load_test.id not in (
select tplc.load_case_id from test_plan_load_case tplc where tplc.test_plan_id = #{request.testPlanId}
and load_test.id not in (
select tplc.load_case_id from test_plan_load_case tplc where tplc.test_plan_id = #{request.testPlanId}
)
</select>
<select id="selectTestPlanLoadCaseList" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO">

View File

@ -76,4 +76,9 @@ public class TestPlanLoadCaseController {
public void update(@RequestBody TestPlanLoadCase testPlanLoadCase) {
testPlanLoadCaseService.update(testPlanLoadCase);
}
@PostMapping("/update/api")
public void updateByApi(@RequestBody TestPlanLoadCase testPlanLoadCase) {
testPlanLoadCaseService.updateByApi(testPlanLoadCase);
}
}

View File

@ -221,6 +221,13 @@ public class TestPlanLoadCaseService {
}
}
public void updateByApi(TestPlanLoadCase testPlanLoadCase) {
String testPlanId = testPlanLoadCase.getTestPlanId();
String loadCaseId = testPlanLoadCase.getLoadCaseId();
String status = testPlanLoadCase.getStatus();
extTestPlanLoadCaseMapper.updateCaseStatusByApi(testPlanId, loadCaseId, status);
}
public List<String> getStatus(String planId) {
return extTestPlanLoadCaseMapper.getStatusByTestPlanId(planId);
}