feat(测试跟踪): 集成Zentao
This commit is contained in:
parent
92c5a0b704
commit
55f933aa55
|
@ -2,6 +2,7 @@ package io.metersphere.track.controller;
|
|||
|
||||
import io.metersphere.base.domain.Issues;
|
||||
import io.metersphere.track.issue.PlatformUser;
|
||||
import io.metersphere.track.issue.ZentaoBuild;
|
||||
import io.metersphere.track.service.IssuesService;
|
||||
import io.metersphere.track.request.testcase.IssuesRequest;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -42,8 +43,19 @@ public class TestCaseIssuesController {
|
|||
}
|
||||
|
||||
@GetMapping("/tapd/user/{caseId}")
|
||||
public List<PlatformUser> getPlatformUsers(@PathVariable String caseId) {
|
||||
public List<PlatformUser> getTapdUsers(@PathVariable String caseId) {
|
||||
return issuesService.getTapdProjectUsers(caseId);
|
||||
}
|
||||
|
||||
@GetMapping("/zentao/user/{caseId}")
|
||||
public List<PlatformUser> getZentaoUsers(@PathVariable String caseId) {
|
||||
return issuesService.getZentaoUsers(caseId);
|
||||
}
|
||||
|
||||
@GetMapping("/zentao/builds/{caseId}")
|
||||
public List<ZentaoBuild> getZentaoBuilds(@PathVariable String caseId) {
|
||||
return issuesService.getZentaoBuilds(caseId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package io.metersphere.track.issue;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ZentaoBuild {
|
||||
private String id;
|
||||
private String name;
|
||||
}
|
|
@ -13,6 +13,7 @@ import org.springframework.http.HttpEntity;
|
|||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
@ -131,9 +132,18 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
||||
paramMap.add("product", projectId);
|
||||
paramMap.add("title", issuesRequest.getTitle());
|
||||
paramMap.add("openedBuild", "123");
|
||||
paramMap.add("steps", issuesRequest.getContent());
|
||||
paramMap.add("assignedTo", "admin");
|
||||
if (!CollectionUtils.isEmpty(issuesRequest.getZentaoBuilds())) {
|
||||
List<String> builds = issuesRequest.getZentaoBuilds();
|
||||
builds.forEach(build -> {
|
||||
paramMap.add("openedBuild[]", build);
|
||||
});
|
||||
} else {
|
||||
paramMap.add("openedBuild", "trunk");
|
||||
}
|
||||
if (StringUtils.isNotBlank(issuesRequest.getZentaoUser())) {
|
||||
paramMap.add("assignedTo", issuesRequest.getZentaoUser());
|
||||
}
|
||||
|
||||
HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(paramMap, new HttpHeaders());
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
@ -200,7 +210,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
LogUtil.error("login fail,inconsistent users");
|
||||
MSException.throwException("zentao login fail");
|
||||
}
|
||||
return session;
|
||||
return session;
|
||||
}
|
||||
|
||||
private String getSession() {
|
||||
|
@ -216,6 +226,53 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
|
||||
@Override
|
||||
public List<PlatformUser> getPlatformUser() {
|
||||
return null;
|
||||
|
||||
String session = login();
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(httpHeaders);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url + "api-getModel-user-getList?zentaosid=" + session,
|
||||
HttpMethod.GET, requestEntity, String.class);
|
||||
String body = responseEntity.getBody();
|
||||
JSONObject obj = JSONObject.parseObject(body);
|
||||
JSONArray data = obj.getJSONArray("data");
|
||||
|
||||
List<PlatformUser> users = new ArrayList<>();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject o = data.getJSONObject(i);
|
||||
PlatformUser platformUser = new PlatformUser();
|
||||
String account = o.getString("account");
|
||||
String username = o.getString("realname");
|
||||
platformUser.setName(username);
|
||||
platformUser.setUser(account);
|
||||
users.add(platformUser);
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
public List<ZentaoBuild> getBuilds() {
|
||||
String session = login();
|
||||
String projectId = getProjectId();
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(httpHeaders);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url + "api-getModel-build-getProductBuildPairs-productID={projectId}?zentaosid=" + session,
|
||||
HttpMethod.GET, requestEntity, String.class, projectId);
|
||||
String body = responseEntity.getBody();
|
||||
JSONObject obj = JSONObject.parseObject(body);
|
||||
JSONObject data = obj.getJSONObject("data");
|
||||
Map<String,Object> maps = data.getInnerMap();
|
||||
|
||||
List<ZentaoBuild> list = new ArrayList<>();
|
||||
for (Map.Entry map : maps.entrySet()) {
|
||||
ZentaoBuild build = new ZentaoBuild();
|
||||
String id = (String) map.getKey();
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
build.setId((String) map.getKey());
|
||||
build.setName((String) map.getValue());
|
||||
list.add(build);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,12 @@ public class IssuesRequest {
|
|||
private String projectId;
|
||||
private String testCaseId;
|
||||
private List<String> tapdUsers;
|
||||
/**
|
||||
* zentao bug 处理人
|
||||
*/
|
||||
private String zentaoUser;
|
||||
/**
|
||||
* zentao bug 影响版本
|
||||
*/
|
||||
private List<String> zentaoBuilds;
|
||||
}
|
||||
|
|
|
@ -19,9 +19,7 @@ import io.metersphere.notice.service.NoticeService;
|
|||
import io.metersphere.notice.service.WxChatTaskService;
|
||||
import io.metersphere.service.IntegrationService;
|
||||
import io.metersphere.service.ProjectService;
|
||||
import io.metersphere.track.issue.AbstractIssuePlatform;
|
||||
import io.metersphere.track.issue.IssueFactory;
|
||||
import io.metersphere.track.issue.PlatformUser;
|
||||
import io.metersphere.track.issue.*;
|
||||
import io.metersphere.track.request.testcase.IssuesRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -211,6 +209,13 @@ public class IssuesService {
|
|||
return platform.getPlatformUser();
|
||||
}
|
||||
|
||||
public List<PlatformUser> getZentaoUsers(String caseId) {
|
||||
IssuesRequest issueRequest = new IssuesRequest();
|
||||
issueRequest.setTestCaseId(caseId);
|
||||
AbstractIssuePlatform platform = IssueFactory.createPlatform(IssuesManagePlatform.Zentao.name(), issueRequest);
|
||||
return platform.getPlatformUser();
|
||||
}
|
||||
|
||||
public void deleteIssue(String id) {
|
||||
issuesMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
@ -222,4 +227,11 @@ public class IssuesService {
|
|||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
public List<ZentaoBuild> getZentaoBuilds(String caseId) {
|
||||
IssuesRequest issueRequest = new IssuesRequest();
|
||||
issueRequest.setTestCaseId(caseId);
|
||||
ZentaoPlatform platform = (ZentaoPlatform) IssueFactory.createPlatform(IssuesManagePlatform.Zentao.name(), issueRequest);
|
||||
return platform.getBuilds();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@
|
|||
<ckeditor :editor="editor" :disabled="isReadOnly" :config="editorConfig"
|
||||
v-model="testCase.issues.content"/>
|
||||
<el-row v-if="hasTapdId">
|
||||
{{ $t('test_track.issue.please_choose_current_owner') }}
|
||||
Tapd bug 处理人
|
||||
<el-select v-model="testCase.tapdUsers"
|
||||
multiple
|
||||
filterable
|
||||
|
@ -231,6 +231,27 @@
|
|||
:value="userInfo.user"/>
|
||||
</el-select>
|
||||
</el-row>
|
||||
<el-row v-if="hasZentaoId">
|
||||
禅道 bug 影响版本
|
||||
<el-select v-model="testCase.zentaoBuilds"
|
||||
multiple
|
||||
filterable
|
||||
style="width: 20%"
|
||||
placeholder="bug影响版本"
|
||||
collapse-tags size="small">
|
||||
<el-option v-for="(build, index) in Builds" :key="index" :label="build.name"
|
||||
:value="build.id"/>
|
||||
</el-select>
|
||||
禅道 bug 处理人
|
||||
<el-select v-model="testCase.zentaoAssigned"
|
||||
filterable
|
||||
style="width: 20%"
|
||||
:placeholder="$t('test_track.issue.please_choose_current_owner')"
|
||||
collapse-tags size="small">
|
||||
<el-option v-for="(userInfo, index) in zentaoUsers" :key="index" :label="userInfo.name"
|
||||
:value="userInfo.user"/>
|
||||
</el-select>
|
||||
</el-row>
|
||||
<el-button type="primary" size="small" @click="saveIssues">{{ $t('commons.save') }}</el-button>
|
||||
<el-button size="small" @click="issuesSwitch=false">{{ $t('commons.cancel') }}</el-button>
|
||||
</el-col>
|
||||
|
@ -360,7 +381,12 @@ export default {
|
|||
activeTab: 'detail',
|
||||
isFailure: true,
|
||||
users: [],
|
||||
Builds: [],
|
||||
zentaoBuilds: [],
|
||||
zentaoUsers: [],
|
||||
zentaoAssigned: "",
|
||||
hasTapdId: false,
|
||||
hasZentaoId: false,
|
||||
tableData: [],
|
||||
};
|
||||
},
|
||||
|
@ -558,6 +584,15 @@ export default {
|
|||
this.users = response.data;
|
||||
})
|
||||
}
|
||||
if (project.zentaoId) {
|
||||
this.hasZentaoId = true;
|
||||
this.result = this.$get("/issues/zentao/builds/" + this.testCase.caseId, response => {
|
||||
this.Builds = response.data;
|
||||
})
|
||||
this.result = this.$get("/issues/zentao/user/" + this.testCase.caseId, response => {
|
||||
this.zentaoUsers = response.data;
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -587,6 +622,8 @@ export default {
|
|||
param.content = this.testCase.issues.content;
|
||||
param.testCaseId = this.testCase.caseId;
|
||||
param.tapdUsers = this.testCase.tapdUsers;
|
||||
param.zentaoBuilds = this.testCase.zentaoBuilds;
|
||||
param.zentaoUser = this.testCase.zentaoAssigned;
|
||||
|
||||
this.result = this.$post("/issues/add", param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
|
@ -597,6 +634,8 @@ export default {
|
|||
this.testCase.issues.title = "";
|
||||
this.testCase.issues.content = "";
|
||||
this.testCase.tapdUsers = [];
|
||||
this.testCase.zentaoBuilds = [];
|
||||
this.testCase.zentaoAssigned = "";
|
||||
},
|
||||
getIssues(caseId) {
|
||||
this.result = this.$get("/issues/get/" + caseId, response => {
|
||||
|
|
Loading…
Reference in New Issue