This commit is contained in:
shiziyuan9527 2020-09-27 14:10:58 +08:00
commit b63eef6e87
17 changed files with 366 additions and 226 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

@ -7,6 +7,7 @@ import io.metersphere.base.domain.TestResource;
import io.metersphere.commons.utils.CompressUtils;
import io.metersphere.commons.utils.MybatisInterceptorConfig;
import io.metersphere.interceptor.MybatisInterceptor;
import io.metersphere.interceptor.UserDesensitizationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
@ -47,4 +48,9 @@ public class MybatisConfig {
interceptor.setInterceptorConfigList(configList);
return interceptor;
}
@Bean
public UserDesensitizationInterceptor userDesensitizationInterceptor() {
return new UserDesensitizationInterceptor();
}
}

View File

@ -0,0 +1,59 @@
package io.metersphere.interceptor;
import io.metersphere.base.domain.User;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
/**
* 用户 password 字段脱敏
*/
@Intercepts({
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}),
})
public class UserDesensitizationInterceptor implements Interceptor {
@Override
public Object intercept(Invocation invocation) throws Throwable {
Object returnValue = invocation.proceed();
Object result = returnValue;
if (returnValue instanceof ArrayList<?>) {
List<Object> list = new ArrayList<>();
boolean isDecrypted = false;
for (Object val : (ArrayList<?>) returnValue) {
if (val instanceof User) {
isDecrypted = true;
((User) val).setPassword(null);
list.add(val);
}
}
if (isDecrypted) {
result = list;
}
} else {
if (result instanceof User) {
((User) result).setPassword(null);
}
}
return result;
}
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
@Override
public void setProperties(Properties properties) {
}
}

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

@ -5,24 +5,24 @@ export default {
name: "api",
redirect: "/api/home",
components: {
content: () => import(/* webpackChunkName: "api" */ '@/business/components/api/ApiTest')
content: () => import('@/business/components/api/ApiTest')
},
children: [
{
path: 'home',
name: 'fucHome',
component: () => import(/* webpackChunkName: "api" */ '@/business/components/api/home/ApiTestHome'),
component: () => import('@/business/components/api/home/ApiTestHome'),
},
{
path: "test/:type",
name: "ApiTestConfig",
component: () => import(/* webpackChunkName: "api" */ '@/business/components/api/test/ApiTestConfig'),
component: () => import('@/business/components/api/test/ApiTestConfig'),
props: (route) => ({id: route.query.id})
},
{
path: "test/list/:projectId",
name: "ApiTestList",
component: () => import(/* webpackChunkName: "api" */ '@/business/components/api/test/ApiTestList'),
component: () => import('@/business/components/api/test/ApiTestList'),
},
{
path: "project/:type",
@ -32,12 +32,12 @@ export default {
{
path: "report/list/:testId",
name: "ApiReportList",
component: () => import(/* webpackChunkName: "api" */ '@/business/components/api/report/ApiReportList'),
component: () => import('@/business/components/api/report/ApiReportList'),
},
{
path: "report/view/:reportId",
name: "ApiReportView",
component: () => import(/* webpackChunkName: "api" */ '@/business/components/api/report/ApiReportView'),
component: () => import('@/business/components/api/report/ApiReportView'),
}
]
}

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=[]
}
})
}

View File

@ -1,12 +1,12 @@
import MsProject from "@/business/components/project/MsProject";
const PerformanceTest = () => import(/* webpackChunkName: "performance" */ '@/business/components/performance/PerformanceTest')
const PerformanceTestHome = () => import(/* webpackChunkName: "performance" */ '@/business/components/performance/home/PerformanceTestHome')
const EditPerformanceTestPlan = () => import(/* webpackChunkName: "performance" */ '@/business/components/performance/test/EditPerformanceTestPlan')
const PerformanceTestPlan = () => import(/* webpackChunkName: "performance" */ '@/business/components/performance/test/PerformanceTestPlan')
const PerformanceTestReport = () => import(/* webpackChunkName: "performance" */ '@/business/components/performance/report/PerformanceTestReport')
const PerformanceChart = () => import(/* webpackChunkName: "performance" */ '@/business/components/performance/report/components/PerformanceChart')
const PerformanceReportView = () => import(/* webpackChunkName: "performance" */ '@/business/components/performance/report/PerformanceReportView')
const PerformanceTest = () => import('@/business/components/performance/PerformanceTest')
const PerformanceTestHome = () => import('@/business/components/performance/home/PerformanceTestHome')
const EditPerformanceTestPlan = () => import('@/business/components/performance/test/EditPerformanceTestPlan')
const PerformanceTestPlan = () => import('@/business/components/performance/test/PerformanceTestPlan')
const PerformanceTestReport = () => import('@/business/components/performance/report/PerformanceTestReport')
const PerformanceChart = () => import('@/business/components/performance/report/components/PerformanceChart')
const PerformanceReportView = () => import('@/business/components/performance/report/PerformanceReportView')
export default {
path: "/performance",

View File

@ -4,69 +4,69 @@ export default {
path: "/setting",
name: "Setting",
components: {
content: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/Setting')
content: () => import('@/business/components/settings/Setting')
},
children: [
{
path: 'user',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/system/User'),
component: () => import('@/business/components/settings/system/User'),
meta: {system: true, title: 'commons.user'}
},
{
path: 'organization',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/system/Organization'),
component: () => import('@/business/components/settings/system/Organization'),
meta: {system: true, title: 'commons.organization'}
},
{
path: 'systemworkspace',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/system/SystemWorkspace'),
component: () => import('@/business/components/settings/system/SystemWorkspace'),
meta: {system: true, title: 'commons.workspace'}
},
{
path: 'testresourcepool',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/system/TestResourcePool'),
component: () => import('@/business/components/settings/system/TestResourcePool'),
meta: {system: true, title: 'commons.test_resource_pool'}
},
{
path: 'systemparametersetting',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/system/SystemParameterSetting'),
component: () => import('@/business/components/settings/system/SystemParameterSetting'),
meta: {system: true, title: 'commons.system_parameter_setting'}
},
...requireContext.keys().map(key => requireContext(key).system),...requireContext.keys().map(key => requireContext(key).license),
{
path: 'organizationmember',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/organization/OrganizationMember'),
component: () => import('@/business/components/settings/organization/OrganizationMember'),
meta: {organization: true, title: 'commons.member'}
},
{
path: 'organizationworkspace',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/organization/OrganizationWorkspace'),
component: () => import('@/business/components/settings/organization/OrganizationWorkspace'),
meta: {organization: true, title: 'commons.workspace'}
},
{
path: 'serviceintegration',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/organization/ServiceIntegration'),
component: () => import('@/business/components/settings/organization/ServiceIntegration'),
meta: {organization: true, title: 'organization.service_integration'}
},
{
path: 'member',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/workspace/WorkspaceMember'),
component: () => import('@/business/components/settings/workspace/WorkspaceMember'),
meta: {workspace: true, title: 'commons.member'}
},
{
path: 'testcase/report/template',
name: 'testCaseReportTemplate',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/workspace/TestCaseReportTemplate'),
component: () => import('@/business/components/settings/workspace/TestCaseReportTemplate'),
meta: {workspace: true, title: 'test_track.plan_view.report_template'}
},
{
path: 'personsetting',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/personal/PersonSetting'),
component: () => import('@/business/components/settings/personal/PersonSetting'),
meta: {person: true, title: 'commons.personal_setting'}
},
{
path: 'apikeys',
component: () => import(/* webpackChunkName: "setting" */ '@/business/components/settings/personal/ApiKeys'),
component: () => import('@/business/components/settings/personal/ApiKeys'),
meta: {
person: true,
title: 'commons.api_keys',

View File

@ -1,12 +1,12 @@
import MsProject from "@/business/components/project/MsProject";
const TestTrack = () => import(/* webpackChunkName: "track" */ '@/business/components/track/TestTrack')
const TrackHome = () => import(/* webpackChunkName: "track" */ '@/business/components/track/home/TrackHome')
const TestCase = () => import(/* webpackChunkName: "track" */ '@/business/components/track/case/TestCase')
const TestPlan = () => import(/* webpackChunkName: "track" */ '@/business/components/track/plan/TestPlan')
const TestCaseReview = () => import(/* webpackChunkName: "track" */ '@/business/components/track/review/TestCaseReview')
const TestCaseReviewView = () => import(/* webpackChunkName: "track" */ '@/business/components/track/review/view/TestCaseReviewView')
const TestPlanView = () => import(/* webpackChunkName: "track" */ '@/business/components/track/plan/view/TestPlanView')
const TestTrack = () => import('@/business/components/track/TestTrack')
const TrackHome = () => import('@/business/components/track/home/TrackHome')
const TestCase = () => import('@/business/components/track/case/TestCase')
const TestPlan = () => import('@/business/components/track/plan/TestPlan')
const TestCaseReview = () => import('@/business/components/track/review/TestCaseReview')
const TestCaseReviewView = () => import('@/business/components/track/review/view/TestCaseReviewView')
const TestPlanView = () => import('@/business/components/track/plan/view/TestPlanView')
export default {
path: "/track",

View File

@ -1,8 +1,11 @@
const path = require('path')
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
productionSourceMap: true,
configureWebpack: {
devtool: 'source-map'
},
devServer: {
port: 8080,
proxy: {
@ -23,5 +26,16 @@ module.exports = {
template: "src/login/login.html",
filename: "login.html"
}
},
configureWebpack: {
devtool: 'source-map',
resolve: {
alias: {
'@': resolve('src')
}
}
},
chainWebpack(config) {
config.plugins.delete('prefetch')
}
};