fix: 重构邮箱代码,修复一键运行报错

This commit is contained in:
wenyann 2020-09-27 11:26:28 +08:00
parent ea9a2cef59
commit 666532bd8c
10 changed files with 251 additions and 190 deletions

View File

@ -119,18 +119,14 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
queue.clear();
super.teardownTest(context);
NoticeService noticeService = CommonBeanFactory.getBean(NoticeService.class);
List<NoticeDetail> notice = null;
try {
notice = noticeService.queryNotice(testResult.getTestId());
} catch (Exception e) {
LogUtil.error(e);
}
MailService mailService = CommonBeanFactory.getBean(MailService.class);
try {
mailService.sendHtml(report.getId(), notice, report.getStatus(), "api");
List<NoticeDetail> noticeList = noticeService.queryNotice(testResult.getTestId());
MailService mailService = CommonBeanFactory.getBean(MailService.class);
mailService.sendApiNotification(report, noticeList);
} catch (Exception e) {
LogUtil.error(e);
}
}
private RequestResult getRequestResult(SampleResult result) {

View File

@ -2,8 +2,10 @@ package io.metersphere.notice.service;
import io.metersphere.api.dto.APIReportResult;
import io.metersphere.base.domain.ApiTestReportDetail;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import io.metersphere.base.domain.Schedule;
import io.metersphere.base.mapper.ApiTestReportDetailMapper;
import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.base.mapper.ext.ExtApiTestReportMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
import io.metersphere.commons.constants.ScheduleGroup;
@ -28,6 +30,8 @@ public class ApiAndPerformanceHelper {
private ApiTestReportDetailMapper apiTestReportDetailMapper;
@Resource
private ScheduleService scheduleService;
@Resource
private LoadTestReportMapper loadTestReportMapper;
public APIReportResult getApi(String reportId) {
APIReportResult result = extApiTestReportMapper.get(reportId);
@ -50,5 +54,9 @@ public class ApiAndPerformanceHelper {
}
return null;
}
public LoadTestReportWithBLOBs getLoadTestReport(String id) {
return loadTestReportMapper.selectByPrimaryKey(id);
}
}

View File

@ -1,13 +1,13 @@
package io.metersphere.notice.service;
import io.metersphere.api.dto.APIReportResult;
import io.metersphere.base.domain.ApiTestReport;
import io.metersphere.base.domain.LoadTestWithBLOBs;
import io.metersphere.base.domain.SystemParameter;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.ParamConstants;
import io.metersphere.commons.utils.EncryptUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.notice.domain.NoticeDetail;
import io.metersphere.service.SystemParameterService;
@ -24,6 +24,7 @@ import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
@ -38,86 +39,99 @@ public class MailService {
@Resource
private SystemParameterService systemParameterService;
public void sendHtml(String id, List<NoticeDetail> notice, String status, String type) {
public void sendPerformanceNotification(List<NoticeDetail> noticeList, String status, LoadTestWithBLOBs loadTest) {
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
JavaMailSenderImpl javaMailSender = getMailSender();
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
String testName = "";
if (type.equals("api")) {
APIReportResult reportResult = apiAndPerformanceHelper.getApi(id);
testName = reportResult.getTestName();
} else if (type.equals("performance")) {
LoadTestDTO performanceResult = apiAndPerformanceHelper.getPerformance(id);
testName = performanceResult.getName();
}
Map<String, String> context = new HashMap<>();
context.put("title", type + Translator.get("timing_task_result_notification"));
context.put("testName", testName);
context.put("title", "Performance" + Translator.get("timing_task_result_notification"));
context.put("testName", loadTest.getName());
context.put("id", loadTest.getId());
context.put("url", baseSystemConfigDTO.getUrl());
context.put("id", id);
context.put("type", type);
String performanceTemplate = "";
try {
String failTemplate = IOUtils.toString(this.getClass().getResource("/mail/fail.html"), StandardCharsets.UTF_8);
String successTemplate = IOUtils.toString(this.getClass().getResource("/mail/success.html"), StandardCharsets.UTF_8);
String successPerformanceTemplate = IOUtils.toString(this.getClass().getResource("/mail/successPerformance.html"), StandardCharsets.UTF_8);
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(javaMailSender.getUsername());
helper.setSubject(Translator.get("timing_task_result_notification"));
String[] users;
List<String> successEmailList = new ArrayList<>();
List<String> failEmailList = new ArrayList<>();
if (notice.size() > 0) {
for (NoticeDetail n : notice) {
if (n.getEnable().equals("true") && n.getEvent().equals("执行成功")) {
successEmailList = userService.queryEmail(n.getNames());
}
if (n.getEnable().equals("true") && n.getEvent().equals("执行失败")) {
failEmailList = userService.queryEmail(n.getNames());
}
}
} else {
LogUtil.error("Recipient information is empty");
if (status.equals("Completed")) {
performanceTemplate = IOUtils.toString(this.getClass().getResource("/mail/successPerformance.html"), StandardCharsets.UTF_8);
} else if (status.equals("Error")) {
performanceTemplate = IOUtils.toString(this.getClass().getResource("/mail/failPerformance.html"), StandardCharsets.UTF_8);
}
if (status.equals("Success")) {
users = successEmailList.toArray(new String[0]);
helper.setText(getContent(successTemplate, context), true);
} else if (status.equals("Starting") && type.equals("performance")) {
users = successEmailList.toArray(new String[0]);
helper.setText(getContent(successPerformanceTemplate, context), true);
} else {
users = failEmailList.toArray(new String[0]);
helper.setText(getContent(failTemplate, context), true);
}
helper.setTo(users);
sendHtmlTimeTasks(noticeList, status, context, performanceTemplate);
} catch (Exception e) {
LogUtil.error(e);
}
}
public void sendApiNotification(ApiTestReport apiTestReport, List<NoticeDetail> noticeList) {
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
Map<String, String> context = new HashMap<>();
context.put("title", "api" + Translator.get("timing_task_result_notification"));
context.put("testName", apiTestReport.getName());
context.put("type", "Api");
context.put("url", baseSystemConfigDTO.getUrl());
context.put("id", apiTestReport.getId());
String apiTemplate = "";
try {
javaMailSender.send(mimeMessage);
} catch (MailException e) {
if (apiTestReport.getStatus().equals("Success")) {
apiTemplate = IOUtils.toString(this.getClass().getResource("/mail/success.html"), StandardCharsets.UTF_8);
} else if (apiTestReport.getStatus().equals("Error")) {
apiTemplate = IOUtils.toString(this.getClass().getResource("/mail/fail.html"), StandardCharsets.UTF_8);
}
sendHtmlTimeTasks(noticeList, apiTestReport.getStatus(), context, apiTemplate);
} catch (Exception e) {
LogUtil.error(e);
}
}
private String getContent(String template, Map<String, String> context) {
if (MapUtils.isNotEmpty(context)) {
for (String k : context.keySet()) {
if (StringUtils.isNotBlank(context.get(k))) {
template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", context.get(k));
}
}
private void sendHtmlTimeTasks(List<NoticeDetail> noticeList, String status, Map<String, String> context, String template) throws MessagingException {
JavaMailSenderImpl javaMailSender = getMailSender();
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(javaMailSender.getUsername());
helper.setSubject(Translator.get("timing_task_result_notification"));
helper.setText(getContent(template, context), true);
helper.setTo(getRecipientEmail(noticeList, status));
try {
javaMailSender.send(mimeMessage);
} catch (MailException e) {
LogUtil.error("Failed to send mail");
}
return template;
}
public void sendEndNotice(List<String> userIds, SaveTestCaseReviewRequest reviewRequest) {
Map<String, String> context = getReviewContext(reviewRequest);
try {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/end.html"), StandardCharsets.UTF_8);
sendReviewNotice(userIds, context, endTemplate);
} catch (Exception e) {
LogUtil.error(e);
}
}
public void sendHtml(List<String> userIds, String type, SaveTestCaseReviewRequest reviewRequest, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
public void sendCommentNotice(List<String> userIds, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
Map<String, String> context = new HashMap<>();
context.put("maintainer", testCaseWithBLOBs.getMaintainer());
context.put("testCaseName", testCaseWithBLOBs.getName());
context.put("description", request.getDescription());
context.put("url", baseSystemConfigDTO.getUrl());
context.put("id", testCaseWithBLOBs.getId());
try {
String commentTemplate = IOUtils.toString(this.getClass().getResource("/mail/comment.html"), StandardCharsets.UTF_8);
sendReviewNotice(userIds, context, commentTemplate);
} catch (Exception e) {
LogUtil.error(e);
}
}
public void sendReviewerNotice(List<String> userIds, SaveTestCaseReviewRequest reviewRequest) {
Map<String, String> context = getReviewContext(reviewRequest);
try {
String reviewerTemplate = IOUtils.toString(this.getClass().getResource("/mail/reviewer.html"), StandardCharsets.UTF_8);
sendReviewNotice(userIds, context, reviewerTemplate);
} catch (Exception e) {
LogUtil.error(e);
}
}
private Map<String, String> getReviewContext(SaveTestCaseReviewRequest reviewRequest) {
Long startTime = reviewRequest.getCreateTime();
Long endTime = reviewRequest.getEndTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -131,60 +145,35 @@ public class MailService {
if (!eTime.equals("null")) {
end = sdf.format(new Date(Long.parseLong(eTime)));
}
JavaMailSenderImpl javaMailSender = getMailSender();
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
Map<String, String> context = new HashMap<>();
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
context.put("url", baseSystemConfigDTO.getUrl());
context.put("creator", reviewRequest.getCreator());
context.put("maintainer", testCaseWithBLOBs.getMaintainer());
context.put("testCaseName", testCaseWithBLOBs.getName());
context.put("reviewName", reviewRequest.getName());
context.put("description", request.getDescription());
context.put("start", start);
context.put("end", end);
context.put("url", baseSystemConfigDTO.getUrl());
context.put("id", reviewRequest.getId());
return context;
}
private void sendReviewNotice(List<String> userIds, Map<String, String> context, String Template) throws MessagingException {
JavaMailSenderImpl javaMailSender = getMailSender();
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(javaMailSender.getUsername());
helper.setSubject(Translator.get("test_review_task_notice"));
String[] users;
List<String> emails = new ArrayList<>();
try {
String reviewerTemplate = IOUtils.toString(this.getClass().getResource("/mail/reviewer.html"), StandardCharsets.UTF_8);
String commentTemplate = IOUtils.toString(this.getClass().getResource("/mail/comment.html"), StandardCharsets.UTF_8);
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/end.html"), StandardCharsets.UTF_8);
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(javaMailSender.getUsername());
helper.setSubject(Translator.get("test_review_task_notice"));
String[] users;
List<String> emails = new ArrayList<>();
try {
emails = userService.queryEmailByIds(userIds);
} catch (Exception e) {
LogUtil.error("Recipient information is empty");
}
users = emails.toArray(new String[0]);
switch (type) {
case "reviewer":
helper.setText(getContent(reviewerTemplate, context), true);
break;
case "comment":
helper.setText(getContent(commentTemplate, context), true);
break;
case "end":
helper.setText(getContent(endTemplate, context), true);
break;
default:
break;
}
helper.setTo(users);
emails = userService.queryEmailByIds(userIds);
} catch (Exception e) {
LogUtil.error(e);
}
try {
javaMailSender.send(mimeMessage);
} catch (MailException e) {
LogUtil.error(e);
LogUtil.error("Recipient information is empty");
}
users = emails.toArray(new String[0]);
helper.setText(getContent(Template, context), true);
helper.setTo(users);
javaMailSender.send(mimeMessage);
}
private JavaMailSenderImpl getMailSender() {
@ -215,5 +204,42 @@ public class MailService {
javaMailSender.setJavaMailProperties(props);
return javaMailSender;
}
private String getContent(String template, Map<String, String> context) {
if (MapUtils.isNotEmpty(context)) {
for (String k : context.keySet()) {
if (StringUtils.isNotBlank(context.get(k))) {
template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", context.get(k));
}
}
}
return template;
}
private String[] getRecipientEmail(List<NoticeDetail> noticeList, String status) {
String[] recipientEmails;
List<String> successEmailList = new ArrayList<>();
List<String> failEmailList = new ArrayList<>();
if (noticeList.size() > 0) {
for (NoticeDetail n : noticeList) {
if (n.getEnable().equals("true") && n.getEvent().equals("执行成功")) {
successEmailList = userService.queryEmail(n.getNames());
}
if (n.getEnable().equals("true") && n.getEvent().equals("执行失败")) {
failEmailList = userService.queryEmail(n.getNames());
}
}
} else {
LogUtil.error("Recipient information is empty");
}
if (status.equals("Success") || status.equals("Completed")) {
recipientEmails = successEmailList.toArray(new String[0]);
} else {
recipientEmails = failEmailList.toArray(new String[0]);
}
return recipientEmails;
}
}

View File

@ -23,46 +23,30 @@ public class NoticeService {
List<Notice> notices = noticeMapper.selectByExample(example);
if (notices.size() > 0) {
noticeMapper.deleteByExample(example);
noticeRequest.getNotices().forEach(n -> {
if (n.getNames().length > 0) {
for (String x : n.getNames()) {
notice.setEvent(n.getEvent());
notice.setEmail(n.getEmail());
notice.setEnable(n.getEnable());
notice.setTestId(noticeRequest.getTestId());
notice.setName(x);
noticeMapper.insert(notice);
}
} else {
notice.setEvent(n.getEvent());
notice.setEmail(n.getEmail());
notice.setEnable(n.getEnable());
notice.setTestId(noticeRequest.getTestId());
notice.setName("");
noticeMapper.insert(notice);
}
});
} else {
noticeRequest.getNotices().forEach(n -> {
if (n.getNames().length > 0) {
for (String x : n.getNames()) {
notice.setEvent(n.getEvent());
notice.setEmail(n.getEmail());
notice.setEnable(n.getEnable());
notice.setTestId(noticeRequest.getTestId());
notice.setName(x);
noticeMapper.insert(notice);
}
} else {
notice.setEvent(n.getEvent());
notice.setEmail(n.getEmail());
notice.setEnable(n.getEnable());
notice.setTestId(noticeRequest.getTestId());
notice.setName("");
noticeMapper.insert(notice);
}
});
}
saveNotice(noticeRequest, notice);
}
private void saveNotice(NoticeRequest noticeRequest, Notice notice) {
noticeRequest.getNotices().forEach(n -> {
if (n.getNames().length > 0) {
for (String x : n.getNames()) {
notice.setEvent(n.getEvent());
notice.setEmail(n.getEmail());
notice.setEnable(n.getEnable());
notice.setTestId(noticeRequest.getTestId());
notice.setName(x);
noticeMapper.insert(notice);
}
} else {
notice.setEvent(n.getEvent());
notice.setEmail(n.getEmail());
notice.setEnable(n.getEnable());
notice.setTestId(noticeRequest.getTestId());
notice.setName("");
noticeMapper.insert(notice);
}
});
}
public List<NoticeDetail> queryNotice(String id) {
@ -72,8 +56,8 @@ public class NoticeService {
List<NoticeDetail> notice = new ArrayList<>();
List<String> success = new ArrayList<>();
List<String> fail = new ArrayList<>();
String[] successArray = new String[success.size()];
String[] failArray = new String[fail.size()];
String[] successArray;
String[] failArray;
NoticeDetail notice1 = new NoticeDetail();
NoticeDetail notice2 = new NoticeDetail();
if (notices.size() > 0) {

View File

@ -238,6 +238,15 @@ public class PerformanceTestService {
}
startEngine(loadTest, engine, request.getTriggerMode());
List<NoticeDetail> noticeList = null;
if (request.getTriggerMode().equals("SCHEDULE")) {
try {
noticeList = noticeService.queryNotice(loadTest.getId());
mailService.sendPerformanceNotification(noticeList, PerformanceTestStatus.Completed.name(), loadTest);
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
}
}
return engine.getReportId();
}
@ -280,7 +289,7 @@ public class PerformanceTestService {
testReport.setUserId(SessionUtils.getUser().getId());
}
// 启动测试
List<NoticeDetail> noticeList = null;
try {
engine.start();
// 启动正常修改状态 starting
@ -305,24 +314,15 @@ public class PerformanceTestService {
reportResult.setReportKey(ReportKeys.ResultStatus.name());
reportResult.setReportValue("Ready"); // 初始化一个 result_status, 这个值用在data-streaming中
loadTestReportResultMapper.insertSelective(reportResult);
if (triggerMode.equals("SCHEDULE")) {
List<NoticeDetail> notice = null;
try {
notice = noticeService.queryNotice(loadTest.getId());
} catch (Exception e) {
LogUtil.error(e);
}
try {
mailService.sendHtml(engine.getReportId(), notice, loadTest.getStatus(), "performance");
} catch (Exception e) {
LogUtil.error(e);
}
}
} catch (MSException e) {
LogUtil.error(e);
loadTest.setStatus(PerformanceTestStatus.Error.name());
loadTest.setDescription(e.getMessage());
loadTestMapper.updateByPrimaryKeySelective(loadTest);
if (triggerMode.equals("SCHEDULE")) {
noticeList = noticeService.queryNotice(loadTest.getId());
mailService.sendPerformanceNotification(noticeList, loadTest.getStatus(), loadTest);
}
throw e;
}
}
@ -445,6 +445,17 @@ public class PerformanceTestService {
reportService.stopEngine(loadTest, engine);
// 停止测试之后设置报告的状态
reportService.updateStatus(reportId, PerformanceTestStatus.Completed.name());
List<NoticeDetail> noticeList = null;
if (loadTestReport.getTriggerMode().equals("SCHEDULE")) {
try {
noticeList = noticeService.queryNotice(loadTest.getId());
mailService.sendPerformanceNotification(noticeList, loadTestReport.getStatus(), loadTest);
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
}
}
}
}

View File

@ -49,7 +49,7 @@ public class TestCaseCommentService {
SaveTestCaseReviewRequest caseReviewRequest = new SaveTestCaseReviewRequest();
List<String> userIds = new ArrayList<>();
userIds.add(testCaseWithBLOBs.getMaintainer());
mailService.sendHtml(userIds, "comment", caseReviewRequest, request, testCaseWithBLOBs);
mailService.sendCommentNotice(userIds, request, testCaseWithBLOBs);
}

View File

@ -20,7 +20,10 @@ import io.metersphere.service.UserService;
import io.metersphere.track.dto.TestCaseReviewDTO;
import io.metersphere.track.dto.TestReviewCaseDTO;
import io.metersphere.track.dto.TestReviewDTOWithMetric;
import io.metersphere.track.request.testreview.*;
import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
import io.metersphere.track.request.testreview.QueryTestReviewRequest;
import io.metersphere.track.request.testreview.ReviewRelevanceRequest;
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
@ -31,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.stream.Collectors;
@ -73,7 +75,6 @@ public class TestCaseReviewService {
String reviewId = UUID.randomUUID().toString();
List<String> projectIds = reviewRequest.getProjectIds();
List<String> userIds = reviewRequest.getUserIds();
projectIds.forEach(projectId -> {
TestCaseReviewProject testCaseReviewProject = new TestCaseReviewProject();
testCaseReviewProject.setProjectId(projectId);
@ -94,9 +95,11 @@ public class TestCaseReviewService {
reviewRequest.setCreator(SessionUtils.getUser().getId());
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
testCaseReviewMapper.insert(reviewRequest);
SaveCommentRequest request = new SaveCommentRequest();
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
mailService.sendHtml(userIds, "reviewer", reviewRequest, request, testCaseWithBLOBs);
try {
mailService.sendReviewerNotice(userIds, reviewRequest);
} catch (Exception e) {
LogUtil.error(e);
}
}
@ -153,9 +156,11 @@ public class TestCaseReviewService {
testCaseReview.setUpdateTime(System.currentTimeMillis());
checkCaseReviewExist(testCaseReview);
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
SaveCommentRequest request = new SaveCommentRequest();
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
mailService.sendHtml(testCaseReview.getUserIds(), "reviewer", testCaseReview, request, testCaseWithBLOBs);
try {
mailService.sendReviewerNotice(testCaseReview.getUserIds(), testCaseReview);
} catch (Exception e) {
LogUtil.error(e);
}
}
private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) {
@ -342,22 +347,17 @@ public class TestCaseReviewService {
}
}
testCaseReview.setStatus(TestPlanStatus.Completed.name());
SaveCommentRequest request = new SaveCommentRequest();
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
SaveTestCaseReviewRequest testCaseReviewRequest = new SaveTestCaseReviewRequest();
TestCaseReview _testCaseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId);
List<String> userIds = new ArrayList<>();
userIds.add(_testCaseReview.getCreator());
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
try {
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
} catch (IllegalAccessException e) {
LogUtil.error(e);
} catch (InvocationTargetException e) {
mailService.sendEndNotice(userIds, testCaseReviewRequest);
} catch (Exception e) {
LogUtil.error(e);
}
mailService.sendHtml(userIds, "end", testCaseReviewRequest, request, testCaseWithBLOBs);
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
}
public List<TestReviewDTOWithMetric> listRelateAll(String type) {

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MeterSphere</title>
</head>
<body>
<div>
<div style="text-align: left">
<h3>${title}</h3>
</div>
<div style="text-align: left">
<p>尊敬的用户:</p>
<p style="margin-left: 60px">您好:
</div>
<div style="margin-left: 100px">
<p>您所执行的 ${testName} 启动失败<br/>
</div>
</div>
</body>
</html>

View File

@ -22,11 +22,12 @@
<script>
import MsDialogFooter from '../../common/components/MsDialogFooter'
import {Scenario, Test} from "./model/ScenarioModel"
import {Test} from "./model/ScenarioModel"
import MsApiScenarioConfig from "./components/ApiScenarioConfig";
import MsApiReportStatus from "../report/ApiReportStatus";
import MsApiReportDialog from "./ApiReportDialog";
import {getUUID} from "@/common/js/utils";
import {parseEnvironment} from "./model/EnvironmentModel";
export default {
@ -105,11 +106,17 @@
let environments = response.data;
let environmentMap = new Map();
environments.forEach(environment => {
parseEnvironment(environment);
environmentMap.set(environment.id, environment);
});
this.test.scenarioDefinition.forEach(scenario => {
if (scenario.environmentId) {
scenario.environment = environmentMap.get(scenario.environmentId);
let env = environmentMap.get(scenario.environmentId);
if (!env) {
scenario.environmentId = undefined;
} else {
scenario.environment = env;
}
}
}
)

View File

@ -174,6 +174,13 @@ export default {
this.result = this.$get('notice/query/' + this.testId, response => {
if (response.data.length > 0) {
this.tableData = response.data
this.tableData[0].email="邮箱"
this.tableData[0].event="执行成功"
this.tableData[1].email="邮箱"
this.tableData[1].event="执行失败"
}else{
this.tableData[0].names=[]
this.tableData[1].names=[]
}
})
}