fix(测试跟踪): 用例关联Zentao需求
This commit is contained in:
parent
41f81dff5e
commit
94b7cd3e4c
|
@ -8,4 +8,5 @@ import lombok.Setter;
|
|||
public class DemandDTO {
|
||||
private String id;
|
||||
private String name;
|
||||
private String platform;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
|||
*
|
||||
* @return 其他平台和本地项目绑定的属性值
|
||||
*/
|
||||
abstract String getProjectId();
|
||||
abstract String getProjectId(String projectId);
|
||||
|
||||
protected boolean isIntegratedPlatform(String orgId, String platform) {
|
||||
IntegrationRequest request = new IntegrationRequest();
|
||||
|
|
|
@ -103,7 +103,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
String auth = EncryptUtils.base64Encoding(account + ":" + password);
|
||||
|
||||
String testCaseId = issuesRequest.getTestCaseId();
|
||||
String jiraKey = getProjectId();
|
||||
String jiraKey = getProjectId(null);
|
||||
|
||||
|
||||
if (StringUtils.isBlank(jiraKey)) {
|
||||
|
@ -200,7 +200,10 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
@Override
|
||||
String getProjectId() {
|
||||
String getProjectId(String projectId) {
|
||||
if (StringUtils.isNotBlank(projectId)) {
|
||||
return projectService.getProjectById(projectId).getJiraKey();
|
||||
}
|
||||
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
|
||||
Project project = projectService.getProjectById(testCase.getProjectId());
|
||||
return project.getJiraKey();
|
||||
|
|
|
@ -66,7 +66,7 @@ public class LocalPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
@Override
|
||||
String getProjectId() {
|
||||
String getProjectId(String projectId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
@Override
|
||||
public List<Issues> getIssue() {
|
||||
List<Issues> list = new ArrayList<>();
|
||||
String tapdId = getProjectId();
|
||||
String tapdId = getProjectId("");
|
||||
|
||||
TestCaseIssuesExample example = new TestCaseIssuesExample();
|
||||
example.createCriteria().andTestCaseIdEqualTo(testCaseId);
|
||||
|
@ -67,18 +67,22 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
|
||||
@Override
|
||||
public List<DemandDTO> getDemandList(String projectId) {
|
||||
System.out.println(projectId);
|
||||
List<DemandDTO> demandList = new ArrayList<>();
|
||||
String url = "https://api.tapd.cn/stories?workspace_id=" + projectId;
|
||||
try {
|
||||
String url = "https://api.tapd.cn/stories?workspace_id=" + getProjectId(projectId);
|
||||
ResultHolder call = call(url);
|
||||
String listJson = JSON.toJSONString(call.getData());
|
||||
JSONArray jsonArray = JSON.parseArray(listJson);
|
||||
System.out.println(jsonArray);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject o = jsonArray.getJSONObject(i);
|
||||
DemandDTO demand = o.getObject("Story", DemandDTO.class);
|
||||
demand.setPlatform(IssuesManagePlatform.Tapd.name());
|
||||
demandList.add(demand);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage());
|
||||
}
|
||||
|
||||
return demandList;
|
||||
}
|
||||
|
||||
|
@ -111,7 +115,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
public void addIssue(IssuesRequest issuesRequest) {
|
||||
String url = "https://api.tapd.cn/bugs";
|
||||
String testCaseId = issuesRequest.getTestCaseId();
|
||||
String tapdId = getProjectId();
|
||||
String tapdId = getProjectId("");
|
||||
|
||||
if (StringUtils.isBlank(tapdId)) {
|
||||
MSException.throwException("未关联Tapd 项目ID");
|
||||
|
@ -172,7 +176,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
@Override
|
||||
public List<PlatformUser> getPlatformUser() {
|
||||
List<PlatformUser> users = new ArrayList<>();
|
||||
String projectId = getProjectId();
|
||||
String projectId = getProjectId("");
|
||||
String url = "https://api.tapd.cn/workspaces/users?workspace_id=" + projectId;
|
||||
ResultHolder call = call(url);
|
||||
String listJson = JSON.toJSONString(call.getData());
|
||||
|
@ -186,7 +190,10 @@ public class TapdPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
@Override
|
||||
String getProjectId() {
|
||||
String getProjectId(String projectId) {
|
||||
if (StringUtils.isNotBlank(projectId)) {
|
||||
return projectService.getProjectById(projectId).getTapdId();
|
||||
}
|
||||
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
|
||||
Project project = projectService.getProjectById(testCase.getProjectId());
|
||||
return project.getTapdId();
|
||||
|
|
|
@ -48,7 +48,10 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
@Override
|
||||
String getProjectId() {
|
||||
String getProjectId(String projectId) {
|
||||
if (StringUtils.isNotBlank(projectId)) {
|
||||
return projectService.getProjectById(projectId).getZentaoId();
|
||||
}
|
||||
TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId);
|
||||
Project project = projectService.getProjectById(testCase.getProjectId());
|
||||
return project.getZentaoId();
|
||||
|
@ -88,7 +91,39 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
|
||||
@Override
|
||||
public List<DemandDTO> getDemandList(String projectId) {
|
||||
return null;
|
||||
//getTestStories
|
||||
List<DemandDTO> list = new ArrayList<>();
|
||||
try {
|
||||
String session = login();
|
||||
String key = getProjectId(projectId);
|
||||
HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(new HttpHeaders());
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url + "api-getModel-story-getProductStories-productID={key}?zentaosid=" + session,
|
||||
HttpMethod.POST, requestEntity, String.class, key);
|
||||
String body = responseEntity.getBody();
|
||||
JSONObject obj = JSONObject.parseObject(body);
|
||||
|
||||
LogUtil.info("project story" + key + obj);
|
||||
|
||||
if (obj != null) {
|
||||
JSONObject data = obj.getJSONObject("data");
|
||||
String s = JSON.toJSONString(data);
|
||||
Map<String, Object> map = JSONArray.parseObject(s, Map.class);
|
||||
Collection<Object> values = map.values();
|
||||
values.forEach(v -> {
|
||||
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(v));
|
||||
DemandDTO demandDTO = new DemandDTO();
|
||||
demandDTO.setId(jsonObject.getString("id"));
|
||||
demandDTO.setName(jsonObject.getString("title"));
|
||||
demandDTO.setPlatform(IssuesManagePlatform.Zentao.name());
|
||||
list.add(demandDTO);
|
||||
});
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("get zentao bug fail " + e.getMessage());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Issues getZentaoIssues(String bugId) {
|
||||
|
@ -135,7 +170,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
public void addIssue(IssuesRequest issuesRequest) {
|
||||
|
||||
String session = login();
|
||||
String projectId = getProjectId();
|
||||
String projectId = getProjectId(null);
|
||||
|
||||
if (StringUtils.isBlank(projectId)) {
|
||||
MSException.throwException("add zentao bug fail, project zentao id is null");
|
||||
|
@ -279,7 +314,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
|||
|
||||
public List<ZentaoBuild> getBuilds() {
|
||||
String session = login();
|
||||
String projectId = getProjectId();
|
||||
String projectId = getProjectId(null);
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(httpHeaders);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
|
|
@ -32,9 +32,7 @@ public class DemandService {
|
|||
public List<DemandDTO> getDemandList(String projectId) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
/*
|
||||
String orgId = "88aceecf-5764-4094-96a9-f82bd52e77ad";
|
||||
*/
|
||||
|
||||
String orgId = user.getLastOrganizationId();
|
||||
boolean tapd = issuesService.isIntegratedPlatform(orgId, IssuesManagePlatform.Tapd.toString());
|
||||
boolean jira = issuesService.isIntegratedPlatform(orgId, IssuesManagePlatform.Jira.toString());
|
||||
|
@ -48,7 +46,6 @@ public class DemandService {
|
|||
if (StringUtils.isNotBlank(tapdId)) {
|
||||
platforms.add(IssuesManagePlatform.Tapd.name());
|
||||
}
|
||||
issueRequest.setProjectId(tapdId);
|
||||
}
|
||||
|
||||
if (jira) {
|
||||
|
@ -56,7 +53,6 @@ public class DemandService {
|
|||
if (StringUtils.isNotBlank(jiraKey)) {
|
||||
platforms.add(IssuesManagePlatform.Jira.name());
|
||||
}
|
||||
issueRequest.setProjectId(jiraKey);
|
||||
}
|
||||
|
||||
if (zentao) {
|
||||
|
@ -64,13 +60,14 @@ public class DemandService {
|
|||
if (StringUtils.isNotBlank(zentaoId)) {
|
||||
platforms.add(IssuesManagePlatform.Zentao.name());
|
||||
}
|
||||
issueRequest.setProjectId(zentaoId);
|
||||
}
|
||||
|
||||
List<AbstractIssuePlatform> platformList = IssueFactory.createPlatforms(platforms, issueRequest);
|
||||
platformList.forEach(platform -> {
|
||||
List<DemandDTO> demand = platform.getDemandList(issueRequest.getProjectId());
|
||||
List<DemandDTO> demand = platform.getDemandList(projectId);
|
||||
list.addAll(demand);
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,12 +136,12 @@
|
|||
<el-row>
|
||||
<el-col :span="10">
|
||||
<el-form-item label="关联需求" :label-width="formLabelWidth" prop="demandId">
|
||||
<el-select filterable :disabled="readOnly" v-model="form.demandId"
|
||||
<el-select filterable :disabled="readOnly" v-model="form.demandId" @visible-change="visibleChange"
|
||||
:placeholder="$t('test_track.case.input_type')" class="ms-case-input">
|
||||
<el-option
|
||||
v-for="item in demandOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:label="item.platform + ': '+item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
|
@ -761,18 +761,31 @@ export default {
|
|||
});
|
||||
}
|
||||
},
|
||||
visibleChange(flag) {
|
||||
if (flag) {
|
||||
this.getDemandOptions()
|
||||
}
|
||||
},
|
||||
getDemandOptions() {
|
||||
this.projectId = getCurrentProjectID()
|
||||
this.result = this.$get("demand/list/" + this.projectId, response => {
|
||||
this.demandOptions = response.data;
|
||||
this.demandOptions.unshift({id: 'other', name: this.$t('test_track.case.other')})
|
||||
});
|
||||
if (this.demandOptions.length === 0) {
|
||||
this.projectId = getCurrentProjectID();
|
||||
this.result = {loading : true};
|
||||
this.$get("demand/list/" + this.projectId).then(response => {
|
||||
this.demandOptions = response.data.data;
|
||||
this.demandOptions.unshift({id: 'other', name: this.$t('test_track.case.other'), platform: 'Other'})
|
||||
this.result = {loading : false};
|
||||
}).catch(() => {
|
||||
this.result = {loading : false};
|
||||
})
|
||||
}
|
||||
},
|
||||
getSelectOptions() {
|
||||
this.getModuleOptions();
|
||||
this.getMaintainerOptions();
|
||||
this.getTestOptions();
|
||||
// this.getDemandOptions()
|
||||
if (this.type === 'edit') {
|
||||
this.getDemandOptions();
|
||||
}
|
||||
},
|
||||
|
||||
resetForm() {
|
||||
|
|
Loading…
Reference in New Issue