fix: 测试用例关联Jira缺陷页面没有显示ID

This commit is contained in:
chenjianxing 2021-05-25 18:50:05 +08:00 committed by jianxing
parent b3fb62cdab
commit 6c329d3f1e
6 changed files with 55 additions and 48 deletions

View File

@ -123,13 +123,15 @@ public class CustomFieldService {
.collect(Collectors.toMap(CustomField::getId, item -> item));
List<CustomFieldDao> result = new ArrayList<>();
customFields.forEach((item) -> {
CustomFieldDao customFieldDao = new CustomFieldDao();
CustomField customField = fieldMap.get(item.getFieldId());
BeanUtils.copyBean(customFieldDao, customField);
BeanUtils.copyBean(customFieldDao, item);
result.add(customFieldDao);
});
if (CollectionUtils.isNotEmpty(customFields)) {
customFields.forEach((item) -> {
CustomFieldDao customFieldDao = new CustomFieldDao();
CustomField customField = fieldMap.get(item.getFieldId());
BeanUtils.copyBean(customFieldDao, customField);
BeanUtils.copyBean(customFieldDao, item);
result.add(customFieldDao);
});
}
return result;
}

View File

@ -65,9 +65,10 @@ public class JiraPlatform extends AbstractIssuePlatform {
JiraConfig config = getConfig();
JiraClient.setConfig(config);
List<String> issuesIds = issues.stream().map(Issues::getId).collect(Collectors.toList());
issuesIds.forEach(issuesId -> {
IssuesDao dto = parseIssue(JiraClient.getIssues(issuesId));
if (StringUtils.isBlank(dto.getId())) {
issues.forEach(item -> {
String issuesId = item.getId();
parseIssue(item, JiraClient.getIssues(issuesId));
if (StringUtils.isBlank(item.getId())) {
// 缺陷不存在解除用例和缺陷的关联
TestCaseIssuesExample issuesExample = new TestCaseIssuesExample();
issuesExample.createCriteria()
@ -77,15 +78,15 @@ public class JiraPlatform extends AbstractIssuePlatform {
issuesMapper.deleteByPrimaryKey(issuesId);
} else {
// 缺陷状态为 完成则不显示
if (!StringUtils.equals("done", dto.getStatus())) {
list.add(dto);
if (!StringUtils.equals("done", item.getStatus())) {
list.add(item);
}
}
});
return list;
}
public IssuesDao parseIssue(JiraIssue jiraIssue) {
public void parseIssue(IssuesDao item, JiraIssue jiraIssue) {
String lastmodify = "";
String status = "";
JSONObject fields = jiraIssue.getFields();
@ -106,15 +107,13 @@ public class JiraPlatform extends AbstractIssuePlatform {
if (assignee != null) {
lastmodify = assignee.getString("displayName");
}
IssuesDao issues = new IssuesDao();
issues.setId(jiraIssue.getKey());
issues.setTitle(fields.getString("summary"));
issues.setCreateTime(fields.getLong("created"));
issues.setLastmodify(lastmodify);
issues.setDescription(description);
issues.setStatus(status);
issues.setPlatform(IssuesManagePlatform.Jira.toString());
return issues;
item.setId(jiraIssue.getKey());
item.setTitle(fields.getString("summary"));
item.setCreateTime(fields.getLong("created"));
item.setLastmodify(lastmodify);
item.setDescription(description);
item.setStatus(status);
item.setPlatform(IssuesManagePlatform.Jira.toString());
}
public HttpHeaders getAuthHeader(JSONObject object) {

View File

@ -42,9 +42,6 @@ public class TapdPlatform extends AbstractIssuePlatform {
List<IssuesDao> list = new ArrayList<>();
String tapdId = getProjectId(issuesRequest.getProjectId());
// TestCaseIssuesExample example = new TestCaseIssuesExample();
// example.createCriteria().andTestCaseIdEqualTo(testCaseId);
issuesRequest.setPlatform(IssuesManagePlatform.Tapd.toString());
List<IssuesDao> issues;
if (StringUtils.isNotBlank(issuesRequest.getProjectId())) {
@ -53,9 +50,10 @@ public class TapdPlatform extends AbstractIssuePlatform {
issues = extIssuesMapper.getIssuesByCaseId(issuesRequest);
}
List<String> issuesIds = issues.stream().map(Issues::getId).collect(Collectors.toList());
issuesIds.forEach(issuesId -> {
issues.forEach(item -> {
String issuesId = item.getId();
IssuesDao dto = getTapdIssues(tapdId, issuesId);
dto.setNum(item.getNum());
if (StringUtils.isBlank(dto.getId())) {
// 缺陷不存在解除用例和缺陷的关联
TestCaseIssuesExample issuesExample = new TestCaseIssuesExample();

View File

@ -23,8 +23,10 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public class ZentaoPlatform extends AbstractIssuePlatform {
/**
@ -72,9 +74,6 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
public List<IssuesDao> getIssue(IssuesRequest issuesRequest) {
List<IssuesDao> list = new ArrayList<>();
// TestCaseIssuesExample example = new TestCaseIssuesExample();
// example.createCriteria().andTestCaseIdEqualTo(testCaseId);
issuesRequest.setPlatform(IssuesManagePlatform.Zentao.toString());
@ -85,9 +84,10 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
issues = extIssuesMapper.getIssuesByCaseId(issuesRequest);
}
List<String> issuesIds = issues.stream().map(Issues::getId).collect(Collectors.toList());
issuesIds.forEach(issuesId -> {
issues.forEach(item -> {
String issuesId = item.getId();
IssuesDao dto = getZentaoIssues(issuesId);
dto.setNum(item.getNum());
if (StringUtils.isBlank(dto.getId())) {
// 缺陷不存在解除用例和缺陷的关联
TestCaseIssuesExample issuesExample = new TestCaseIssuesExample();

View File

@ -9,9 +9,9 @@
</el-tooltip>
<ms-table
v-loading="result.loading"
v-loading="page.result.loading"
:show-select-all="false"
:data="issues"
:data="page.data"
:enable-selection="false"
@refresh="getIssues">
@ -49,14 +49,14 @@
<el-tooltip :content="$t('test_track.issue.close')"
placement="top" :enterable="false">
<el-button type="danger" icon="el-icon-circle-close" size="mini"
circle v-if="scope.row.platform === 'Local'"
circle :disabled="scope.row.platform !== 'Local'"
@click="closeIssue(scope.row)"
/>
</el-tooltip>
<el-tooltip :content="$t('test_track.issue.delete')"
placement="top" :enterable="false">
<el-button type="danger" icon="el-icon-delete" size="mini"
circle v-if="scope.row.platform === 'Local'"
circle :disabled="scope.row.platform !== 'Local'"
@click="deleteIssue(scope.row)"
/>
</el-tooltip>
@ -77,13 +77,16 @@ import MsTableColumn from "@/business/components/common/components/table/Ms-tabl
import IssueDescriptionTableItem from "@/business/components/track/issue/IssueDescriptionTableItem";
import {ISSUE_STATUS_MAP} from "@/common/js/table-constants";
import IssueRelateList from "@/business/components/track/case/components/IssueRelateList";
import {getIssuesByCaseId} from "@/network/Issue";
export default {
name: "TestCaseIssueRelate",
components: {IssueRelateList, IssueDescriptionTableItem, MsTableColumn, MsTable, TestPlanIssueEdit},
data() {
return {
issues: [],
result: {},
page: {
data: [],
result: {},
},
}
},
props: ['caseId', 'readOnly','planId'],
@ -94,11 +97,7 @@ export default {
},
methods: {
getIssues() {
if (this.caseId) {
this.result = this.$get("/issues/get/" + this.caseId, (response) => {
this.issues = response.data;
});
}
this.page.result = getIssuesByCaseId(this.caseId, this.page);
},
appIssue() {
if (!this.caseId) {
@ -118,14 +117,14 @@ export default {
if (row.status === 'closed') {
this.$success(this.$t('test_track.issue.close_success'));
} else {
this.result = this.$get("/issues/close/" + row.id, () => {
this.page.result = this.$get("/issues/close/" + row.id, () => {
this.getIssues();
this.$success(this.$t('test_track.issue.close_success'));
});
}
},
deleteIssue(row) {
this.result = this.$post("/issues/delete", {id: row.id, caseId: this.caseId}, () => {
this.page.result = this.$post("/issues/delete", {id: row.id, caseId: this.caseId}, () => {
this.getIssues();
this.$success(this.$t('commons.delete_success'));
})

View File

@ -1,4 +1,4 @@
import {post} from "@/common/js/ajax";
import {post, get} from "@/common/js/ajax";
import {getPageDate} from "@/common/js/tableUtils";
export function buildIssues(page) {
@ -19,6 +19,15 @@ export function getIssues(page) {
});
}
export function getIssuesByCaseId(caseId, page) {
if (caseId) {
return get('issues/get/' + caseId, (response) => {
page.data = response.data;
buildIssues(page);
});
}
}
export function buildPlatformIssue(data) {
return post("issues/get/platform/issue", data).then(response => {
let issues = response.data.data;