This commit is contained in:
chenjianxing 2020-09-27 20:35:37 +08:00
commit 7e97818cf2
14 changed files with 189 additions and 105 deletions

View File

@ -4,8 +4,10 @@ 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.APITestStatus;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.ParamConstants;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.utils.EncryptUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.BaseSystemConfigDTO;
@ -46,12 +48,13 @@ public class MailService {
context.put("title", "Performance" + Translator.get("timing_task_result_notification"));
context.put("testName", loadTest.getName());
context.put("id", loadTest.getId());
context.put("type", "performance");
context.put("url", baseSystemConfigDTO.getUrl());
String performanceTemplate = "";
try {
if (status.equals("Completed")) {
if (StringUtils.equals(status, PerformanceTestStatus.Completed.name())) {
performanceTemplate = IOUtils.toString(this.getClass().getResource("/mail/successPerformance.html"), StandardCharsets.UTF_8);
} else if (status.equals("Error")) {
} else if (StringUtils.equals(status, PerformanceTestStatus.Error.name())) {
performanceTemplate = IOUtils.toString(this.getClass().getResource("/mail/failPerformance.html"), StandardCharsets.UTF_8);
}
sendHtmlTimeTasks(noticeList, status, context, performanceTemplate);
@ -65,14 +68,14 @@ public class MailService {
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("type", "api");
context.put("url", baseSystemConfigDTO.getUrl());
context.put("id", apiTestReport.getId());
String apiTemplate = "";
try {
if (apiTestReport.getStatus().equals("Success")) {
if (StringUtils.equals(APITestStatus.Success.name(), apiTestReport.getStatus())) {
apiTemplate = IOUtils.toString(this.getClass().getResource("/mail/success.html"), StandardCharsets.UTF_8);
} else if (apiTestReport.getStatus().equals("Error")) {
} else if (StringUtils.equals(APITestStatus.Error.name(), apiTestReport.getStatus())) {
apiTemplate = IOUtils.toString(this.getClass().getResource("/mail/fail.html"), StandardCharsets.UTF_8);
}
sendHtmlTimeTasks(noticeList, apiTestReport.getStatus(), context, apiTemplate);
@ -183,17 +186,21 @@ public class MailService {
javaMailSender.setDefaultEncoding("UTF-8");
javaMailSender.setProtocol("smtps");
for (SystemParameter p : paramList) {
if (p.getParamKey().equals("smtp.host")) {
javaMailSender.setHost(p.getParamValue());
}
if (p.getParamKey().equals("smtp.port")) {
javaMailSender.setPort(Integer.parseInt(p.getParamValue()));
}
if (p.getParamKey().equals("smtp.account")) {
javaMailSender.setUsername(p.getParamValue());
}
if (p.getParamKey().equals("smtp.password")) {
javaMailSender.setPassword(EncryptUtils.aesDecrypt(p.getParamValue()).toString());
switch (p.getParamKey()) {
case "smtp.host":
javaMailSender.setHost(p.getParamValue());
break;
case "smtp.port":
javaMailSender.setPort(Integer.parseInt(p.getParamValue()));
break;
case "smtp.account":
javaMailSender.setUsername(p.getParamValue());
break;
case "smtp.password":
javaMailSender.setPassword(EncryptUtils.aesDecrypt(p.getParamValue()).toString());
break;
default:
break;
}
}
Properties props = new Properties();
@ -223,10 +230,10 @@ public class MailService {
List<String> failEmailList = new ArrayList<>();
if (noticeList.size() > 0) {
for (NoticeDetail n : noticeList) {
if (n.getEnable().equals("true") && n.getEvent().equals(NoticeConstants.EXECUTE_SUCCESSFUL)) {
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_SUCCESSFUL)) {
successEmailList = userService.queryEmail(n.getNames());
}
if (n.getEnable().equals("true") && n.getEvent().equals(NoticeConstants.EXECUTE_FAILED)) {
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_FAILED)) {
failEmailList = userService.queryEmail(n.getNames());
}
}
@ -234,7 +241,7 @@ public class MailService {
LogUtil.error("Recipient information is empty");
}
if (status.equals("Success") || status.equals("Completed")) {
if (StringUtils.equalsAny(status, PerformanceTestStatus.Completed.name(), APITestStatus.Success.name())) {
recipientEmails = successEmailList.toArray(new String[0]);
} else {
recipientEmails = failEmailList.toArray(new String[0]);

View File

@ -230,7 +230,7 @@ public class TestCaseNodeService {
return list;
}
private List<TestCaseNodeDTO> getNodeDTO(String projectId, String planId) {
TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample();
testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(planId);
@ -355,50 +355,45 @@ public class TestCaseNodeService {
}
public Map<String, String> createNodeByTestCases(List<TestCaseWithBLOBs> testCases, String projectId) {
List<TestCaseNodeDTO> nodeTrees = getNodeTreeByProjectId(projectId);
Map<String, String> pathMap = new HashMap<>();
List<String> nodePaths = testCases.stream()
.map(TestCase::getNodePath)
.collect(Collectors.toList());
nodePaths.forEach(path -> {
return this.createNodes(nodePaths, projectId);
}
if (path == null) {
public Map<String, String> createNodes(List<String> nodePaths, String projectId) {
List<TestCaseNodeDTO> nodeTrees = getNodeTreeByProjectId(projectId);
Map<String, String> pathMap = new HashMap<>();
for(String item : nodePaths){
if (item == null) {
throw new ExcelException(Translator.get("test_case_module_not_null"));
}
List<String> nodeNameList = new ArrayList<>(Arrays.asList(path.split("/")));
Iterator<String> pathIterator = nodeNameList.iterator();
List<String> nodeNameList = new ArrayList<>(Arrays.asList(item.split("/")));
Iterator<String> itemIterator = nodeNameList.iterator();
Boolean hasNode = false;
String rootNodeName = null;
if (nodeNameList.size() <= 1) {
throw new ExcelException(Translator.get("test_case_create_module_fail") + ":" + path);
throw new ExcelException(Translator.get("test_case_create_module_fail") + ":" + item);
} else {
pathIterator.next();
pathIterator.remove();
rootNodeName = pathIterator.next().trim();
itemIterator.next();
itemIterator.remove();
rootNodeName = itemIterator.next().trim();
//原来没有新建的树nodeTrees也不包含
for (TestCaseNodeDTO nodeTree : nodeTrees) {
if (StringUtils.equals(rootNodeName, nodeTree.getName())) {
hasNode = true;
createNodeByPathIterator(pathIterator, "/" + rootNodeName, nodeTree,
createNodeByPathIterator(itemIterator, "/" + rootNodeName, nodeTree,
pathMap, projectId, 2);
}
;
}
}
if (!hasNode) {
createNodeByPath(pathIterator, rootNodeName, null, projectId, 1, "", pathMap);
createNodeByPath(itemIterator, rootNodeName, null, projectId, 1, "", pathMap);
}
});
}
return pathMap;
}

View File

@ -285,6 +285,9 @@ public class TestCaseService {
errList.add(excelErrData);
excelResponse.setErrList(errList);
} else {
if (!xmindParser.getNodePaths().isEmpty()) {
testCaseNodeService.createNodes(xmindParser.getNodePaths(), projectId);
}
if (!xmindParser.getTestCase().isEmpty()) {
this.saveImportData(xmindParser.getTestCase(), projectId);
xmindParser.clear();

View File

@ -40,6 +40,9 @@ public class XmindCaseParser {
// 案例详情重写了hashCode方法去重用
private List<TestCaseExcelData> compartDatas;
// 记录没有用例的目录
private List<String> nodePaths;
public XmindCaseParser(TestCaseService testCaseService, String userId, String projectId, Set<String> testCaseNames) {
this.testCaseService = testCaseService;
this.maintainer = userId;
@ -48,6 +51,7 @@ public class XmindCaseParser {
testCases = new LinkedList<>();
compartDatas = new ArrayList<>();
process = new StringBuffer();
nodePaths = new ArrayList<>();
}
// 这里清理是为了 加快jvm 回收
@ -55,26 +59,55 @@ public class XmindCaseParser {
compartDatas.clear();
testCases.clear();
testCaseNames.clear();
nodePaths.clear();
}
public List<TestCaseWithBLOBs> getTestCase() {
return this.testCases;
}
public List<String> getNodePaths() {
return this.nodePaths;
}
private final Map<String, String> caseTypeMap = ImmutableMap.of("功能测试", "functional", "性能测试", "performance", "接口测试", "api");
public void validate() {
nodePaths.forEach(nodePath -> {
String[] nodes = nodePath.split("/");
if (nodes.length > TestCaseConstants.MAX_NODE_DEPTH + 1) {
process.append(Translator.get("test_case_node_level_tip") +
TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level") + "; ");
}
for (int i = 0; i < nodes.length; i++) {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
process.append(Translator.get("module_not_null") + "; ");
break;
}
}
});
}
// 递归处理案例数据
private void recursion(StringBuffer processBuffer, Attached parent, int level, String nodePath, List<Attached> attacheds) {
private void recursion(StringBuffer processBuffer, Attached parent, int level, List<Attached> attacheds) {
for (Attached item : attacheds) {
if (isAvailable(item.getTitle(), "(?:tc|tc:|tc)")) { // 用例
item.setParent(parent);
this.newTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null);
} else {
nodePath = parent.getPath() + "/" + item.getTitle();
String nodePath = parent.getPath() + "/" + item.getTitle();
item.setPath(nodePath);
item.setParent(parent);
if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) {
item.setParent(parent);
recursion(processBuffer, item, level + 1, nodePath, item.getChildren().getAttached());
recursion(processBuffer, item, level + 1, item.getChildren().getAttached());
} else {
if (!nodePath.startsWith("/")) {
nodePath = "/" + nodePath;
}
if (nodePath.endsWith("/")) {
nodePath = nodePath.substring(0, nodePath.length() - 1);
}
nodePaths.add(nodePath); // 没有用例的路径
}
}
}
@ -243,11 +276,12 @@ public class XmindCaseParser {
item.setPath(item.getTitle());
if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) {
item.setPath(item.getTitle());
recursion(processBuffer, item, 1, item.getPath(), item.getChildren().getAttached());
recursion(processBuffer, item, 1, item.getChildren().getAttached());
}
}
}
}
this.validate();
} catch (Exception ex) {
processBuffer.append(Translator.get("incorrect_format"));
LogUtil.error(ex.getMessage());

@ -1 +1 @@
Subproject commit cf6b06526324326a563d933e07118fac014a63b4
Subproject commit c2dacf960cdb1ed35664bdd3432120b1203b73d8

View File

@ -12,7 +12,10 @@
<el-input :disabled="isReadOnly" v-model="form.cronValue" class="inp"
:placeholder="$t('schedule.please_input_cron_expression')"/>
<!-- <el-button type="primary" @click="showCronDialog">{{$t('schedule.generate_expression')}}</el-button>-->
<el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{ $t('commons.save') }}</el-button>
<el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{
$t('commons.save')
}}
</el-button>
</el-form-item>
<el-form-item>
<el-link :disabled="isReadOnly" type="primary" @click="showCronDialog">
@ -21,8 +24,10 @@
</el-form-item>
<crontab-result :ex="form.cronValue" ref="crontabResult"/>
</el-form>
<el-dialog width="60%" :title="$t('schedule.generate_expression')" :visible.sync="showCron" :modal="false">
<crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.value" ref="crontab"/>
<el-dialog width="60%" :title="$t('schedule.generate_expression')" :visible.sync="showCron"
:modal="false">
<crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.value"
ref="crontab"/>
</el-dialog>
</el-tab-pane>
<el-tab-pane :label="$t('schedule.task_notification')" name="second">
@ -42,11 +47,12 @@
<el-table-column
prop="name"
:label="$t('schedule.receiver')"
width="200"
width="240"
>
<template v-slot:default="{row}">
<el-select v-model="row.names" filterable multiple :placeholder="$t('commons.please_select')"
@click.native="userList()">
<el-select v-model="row.names" filterable multiple
:placeholder="$t('commons.please_select')"
@click.native="userList()" style="width: 100%;">
<el-option
v-for="item in options"
:key="item.id"
@ -269,4 +275,10 @@ export default {
margin-bottom: 10px;
}
/deep/ .el-select__tags {
flex-wrap: unset;
overflow: auto;
}
</style>

View File

@ -165,7 +165,7 @@
this.$refs[form].validate(valid => {
if (valid) {
let formatUrl = this.form.url;
let formatUrl = this.form.url.trim();
if (!formatUrl.endsWith('/')) {
formatUrl = formatUrl + '/';
}

View File

@ -19,6 +19,8 @@
:content="$t('test_track.plan_view.create_report')" @click="openTestReport"/>
<ms-table-button :is-tester-permission="true" v-if="testPlan.reportId" icon="el-icon-document"
:content="$t('test_track.plan_view.view_report')" @click="openReport"/>
<ms-table-button :is-tester-permission="true" icon="el-icon-document-remove"
:content="$t('test_track.plan_view.cancel_all_relevance')" @click="handleDeleteBatch"/>
</template>
</ms-table-header>
</template>
@ -413,26 +415,47 @@
});
},
handleDeleteBatch() {
if (this.tableData.length < 1) {
this.$warning(this.$t('test_track.plan_view.no_case_relevance'));
return;
}
this.$alert(this.$t('test_track.plan_view.confirm_cancel_relevance') + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/test/plan/case/batch/delete', {ids: ids}, () => {
// this.selectIds.clear();
this.selectRows.clear();
this.$emit("refresh");
this.$success(this.$t('commons.delete_success'));
});
if (this.selectRows.size > 0) {
let ids = Array.from(this.selectRows).map(row => row.id);
this._handleBatchDelete(ids);
} else {
if (this.planId) {
this.condition.planId = this.planId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
this.condition.nodeIds = this.selectNodeIds;
}
//
this.$post('/test/plan/case/list/all', this.condition, res => {
let data = res.data;
let ids = data.map(d => d.id);
this._handleBatchDelete(ids);
})
}
}
}
});
},
_handleBatchDelete(ids) {
this.result = this.$post('/test/plan/case/batch/delete', {ids:ids}, () => {
this.selectRows.clear();
this.$emit("refresh");
this.$success(this.$t('test_track.cancel_relevance_success'));
});
},
_handleDelete(testCase) {
let testCaseId = testCase.id;
this.$post('/test/plan/case/delete/' + testCaseId, {}, () => {
this.result = this.$post('/test/plan/case/delete/' + testCaseId, {}, () => {
this.$emit("refresh");
this.$success(this.$t('commons.delete_success'));
this.$success(this.$t('test_track.cancel_relevance_success'));
});
},
handleSelectAll(selection) {

View File

@ -2,16 +2,18 @@
<div class="main">
<div class="comment-left">
<div class="icon-title">
{{comment.author.substring(0,1)}}
{{ comment.author.substring(0, 1) }}
</div>
</div>
<div class="comment-right">
<span style="font-size: 14px;color: #909399;font-weight: bold">{{comment.author}}</span>
<span style="font-size: 14px;color: #909399;font-weight: bold">{{ comment.author }}</span>
<span style="color: #8a8b8d; margin-left: 8px; font-size: 12px">
{{comment.createTime | timestampFormatDate}}
{{ comment.createTime | timestampFormatDate }}
</span>
<br/>
<div class="comment-desc" style="font-size: 10px;color: #303133">{{comment.description}}</div>
<div class="comment-desc" style="font-size: 10px;color: #303133">
<pre>{{ comment.description }}</pre>
</div>
</div>
</div>
</template>
@ -29,41 +31,45 @@ export default {
</script>
<style scoped>
.main {
overflow-y: scroll;
display: flex;
align-items: center;
margin-top: 10px;
}
.main {
overflow-y: scroll;
display: flex;
align-items: center;
margin-top: 10px;
}
.comment-left {
float: left;
width: 50px;
height: 100%;
}
.comment-left {
float: left;
width: 50px;
height: 100%;
}
.comment-right {
float: left;
width: 90%;
padding: 0;
line-height: 25px;
}
.comment-right {
float: left;
width: 90%;
padding: 0;
line-height: 25px;
}
.icon-title {
color: #fff;
width: 30px;
background-color: #72dc91;
height: 30px;
line-height: 30px;
text-align: center;
border-radius: 30px;
font-size: 14px;
}
.icon-title {
color: #fff;
width: 30px;
background-color: #72dc91;
height: 30px;
line-height: 30px;
text-align: center;
border-radius: 30px;
font-size: 14px;
}
.comment-desc {
overflow-wrap: break-word;
word-break: break-all;
border-bottom: 1px solid #ced3de;
}
.comment-desc {
overflow-wrap: break-word;
word-break: break-all;
border-bottom: 1px solid #ced3de;
}
pre {
margin: 0 0;
}
</style>

View File

@ -29,7 +29,6 @@
:placeholder="$t('test_track.review.input_review_project')"
multiple
style="width: 100%"
collapse-tags
filterable>
<el-option
v-for="item in projects"
@ -49,7 +48,6 @@
v-model="form.userIds"
:placeholder="$t('test_track.review.input_reviewer')"
filterable multiple
collapse-tags
>
<el-option
v-for="item in reviewerOptions"

@ -1 +1 @@
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1
Subproject commit cc38137a69a0f20fadece9c0f9f50a9468c4ace9

View File

@ -798,6 +798,7 @@ export default {
plan_view: {
plan: "Plan",
relevance_test_case: "Relevance case",
cancel_all_relevance: "Unlink all",
executor: "Executor",
execute_result: "Result",
pass: "Pass",
@ -842,7 +843,8 @@ export default {
report_template: "Report template",
test_detail: "Test detail",
failure_case: "Failure case",
export_report: "Export Report"
export_report: "Export Report",
no_case_relevance: "No related use cases",
},
issue: {
issue: "Issue",

View File

@ -804,6 +804,7 @@ export default {
plan_view: {
plan: "计划",
relevance_test_case: "关联测试用例",
cancel_all_relevance: "取消全部关联",
executor: "执行人",
execute_result: "执行结果",
pass: "通过",
@ -848,7 +849,8 @@ export default {
report_template: "测试报告模版",
test_detail: "测试详情",
failure_case: "失败用例",
export_report: "导出报告"
export_report: "导出报告",
no_case_relevance: "没有关联用例",
},
issue: {
issue: "缺陷",

View File

@ -800,6 +800,7 @@ export default {
plan_view: {
plan: "計劃",
relevance_test_case: "關聯測試用例",
cancel_all_relevance: "取消全部關聯",
executor: "執行人",
execute_result: "執行結果",
pass: "通過",
@ -844,7 +845,8 @@ export default {
report_template: "測試報告模版",
test_detail: "測試詳情",
failure_case: "失敗用例",
export_report: "導出報告"
export_report: "導出報告",
no_case_relevance: "沒有關聯用例",
},
issue: {
issue: "缺陷",