This commit is contained in:
chenjianxing 2020-08-18 18:43:28 +08:00
commit 65a033ce3a
21 changed files with 206 additions and 43 deletions

3
backend/.gitignore vendored
View File

@ -31,4 +31,5 @@ target
.settings
.project
.classpath
.factorypath
.factorypath
*.jar

View File

@ -369,6 +369,16 @@
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/jmeter/lib/**/*.jar</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@ -396,6 +406,35 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_functions</artifactId>
<version>${jmeter.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>src/main/resources/jmeter/lib/ext</outputDirectory>
<destFileName>ApacheJMeter_functions.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/wars</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>

View File

@ -11,4 +11,6 @@ public interface ExtProjectMapper {
List<ProjectDTO> getProjectWithWorkspace(@Param("proRequest") ProjectRequest request);
List<String> getProjectIdByWorkspaceId(String workspaceId);
int removeIssuePlatform(@Param("platform") String platform, @Param("orgId") String orgId);
}

View File

@ -4,9 +4,9 @@
<select id="getProjectWithWorkspace" resultType="io.metersphere.dto.ProjectDTO">
select p.id, p.workspace_id, p.name, p.description, p.update_time,
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key
from project p
join workspace w on p.workspace_id = w.id
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key
from project p
join workspace w on p.workspace_id = w.id
<where>
<if test="proRequest.name != null and proRequest.name != ''">
and p.name like #{proRequest.name, jdbcType=VARCHAR}
@ -28,4 +28,22 @@
where workspace_id = #{workspaceId}
</select>
<update id="removeIssuePlatform">
update project
<set>
<if test="platform == 'Jira'">
jira_key = null
</if>
<if test="platform == 'Tapd'">
tapd_id = null
</if>
</set>
where project.id in (select id from (select id
from project
where workspace_id in
(select workspace.id
from workspace
where organization_id = #{orgId})) as a)
</update>
</mapper>

View File

@ -23,7 +23,8 @@ public class RestTemplateUtils {
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
return responseEntity.getBody();
} catch (Exception e) {
MSException.throwException("接口调用失败:" + e.getMessage());
LogUtil.error(e.getMessage(), e);
MSException.throwException("Tapd接口调用失败" + e.getMessage());
return null;
}
}
@ -36,7 +37,8 @@ public class RestTemplateUtils {
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
return responseEntity.getBody();
} catch (Exception e) {
MSException.throwException("接口调用失败:" + e.getMessage());
LogUtil.error(e.getMessage(), e);
MSException.throwException("Tapd接口调用失败" + e.getMessage());
return null;
}

View File

@ -3,6 +3,7 @@ package io.metersphere.service;
import io.metersphere.base.domain.ServiceIntegration;
import io.metersphere.base.domain.ServiceIntegrationExample;
import io.metersphere.base.mapper.ServiceIntegrationMapper;
import io.metersphere.base.mapper.ext.ExtProjectMapper;
import io.metersphere.controller.request.IntegrationRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -20,6 +21,8 @@ public class IntegrationService {
@Resource
private ServiceIntegrationMapper serviceIntegrationMapper;
@Resource
private ExtProjectMapper extProjectMapper;
public ServiceIntegration save(ServiceIntegration service) {
ServiceIntegrationExample example = new ServiceIntegrationExample();
@ -63,6 +66,8 @@ public class IntegrationService {
.andOrganizationIdEqualTo(orgId)
.andPlatformEqualTo(platform);
serviceIntegrationMapper.deleteByExample(example);
// 删除项目关联的id/key
extProjectMapper.removeIssuePlatform(platform, orgId);
}
public List<ServiceIntegration> getAll(String orgId) {

View File

@ -1,7 +1,7 @@
package io.metersphere.track.controller;
import io.metersphere.base.domain.Issues;
import io.metersphere.service.IssuesService;
import io.metersphere.track.service.IssuesService;
import io.metersphere.track.request.testcase.IssuesRequest;
import org.springframework.web.bind.annotation.*;
@ -30,4 +30,9 @@ public class TestCaseIssuesController {
issuesService.testAuth(platform);
}
@GetMapping("/close/{id}")
public void closeLocalIssue(@PathVariable String id) {
issuesService.closeLocalIssue(id);
}
}

View File

@ -1,4 +1,4 @@
package io.metersphere.service;
package io.metersphere.track.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -15,8 +15,9 @@ import io.metersphere.commons.utils.RestTemplateUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.ResultHolder;
import io.metersphere.controller.request.IntegrationRequest;
import io.metersphere.service.IntegrationService;
import io.metersphere.service.ProjectService;
import io.metersphere.track.request.testcase.IssuesRequest;
import io.metersphere.track.service.TestCaseService;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
@ -63,7 +65,6 @@ public class IssuesService {
RestTemplate restTemplate = new RestTemplate();
restTemplate.exchange("https://api.tapd.cn/quickstart/testauth", HttpMethod.GET, requestEntity, String.class);
} catch (Exception e) {
System.out.println(e);
LogUtil.error(e.getMessage(), e);
MSException.throwException("验证失败!");
}
@ -154,12 +155,6 @@ public class IssuesService {
String tapdId = getTapdProjectId(issuesRequest.getTestCaseId());
String jiraKey = getJiraProjectKey(issuesRequest.getTestCaseId());
if (tapd || jira) {
if (StringUtils.isBlank(tapdId) && StringUtils.isBlank(jiraKey)) {
MSException.throwException("集成了缺陷管理平台,但未进行项目关联!");
}
}
if (tapd) {
// 是否关联了项目
if (StringUtils.isNotBlank(tapdId)) {
@ -173,7 +168,7 @@ public class IssuesService {
}
}
if (!tapd && !jira) {
if (StringUtils.isBlank(tapdId) && StringUtils.isBlank(jiraKey)) {
addLocalIssues(issuesRequest);
}
@ -275,7 +270,14 @@ public class IssuesService {
HttpEntity<String> requestEntity = new HttpEntity<>(json, requestHeaders);
RestTemplate restTemplate = new RestTemplate();
//post
ResponseEntity<String> responseEntity = restTemplate.exchange(url + "/rest/api/2/issue", HttpMethod.POST, requestEntity, String.class);
ResponseEntity<String> responseEntity = null;
try {
responseEntity = restTemplate.exchange(url + "/rest/api/2/issue", HttpMethod.POST, requestEntity, String.class);
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
MSException.throwException("调用Jira接口创建缺陷失败");
}
return responseEntity.getBody();
}
@ -315,7 +317,7 @@ public class IssuesService {
HttpEntity<MultiValueMap> requestEntity = new HttpEntity<>(headers);
RestTemplate restTemplate = new RestTemplate();
//post
ResponseEntity<String> responseEntity = null;
ResponseEntity<String> responseEntity;
Issues issues = new Issues();
try {
responseEntity = restTemplate.exchange(url + "/rest/api/2/issue/" + issuesId, HttpMethod.GET, requestEntity, String.class);
@ -336,8 +338,15 @@ public class IssuesService {
issues.setDescription(description);
issues.setStatus(status);
issues.setPlatform(IssuesManagePlatform.Jira.toString());
} catch (Exception e) {
} catch (HttpClientErrorException.NotFound e) {
LogUtil.error(e.getStackTrace(), e);
return new Issues();
} catch (HttpClientErrorException.Unauthorized e) {
LogUtil.error(e.getStackTrace(), e);
MSException.throwException("获取Jira缺陷失败检查Jira配置信息");
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
MSException.throwException("调用Jira接口获取缺陷失败");
}
return issues;
@ -381,7 +390,7 @@ public class IssuesService {
List<Issues> issues = extIssuesMapper.getIssues(caseId, IssuesManagePlatform.Tapd.toString());
List<String> issuesIds = issues.stream().map(issue -> issue.getId()).collect(Collectors.toList());
List<String> issuesIds = issues.stream().map(Issues::getId).collect(Collectors.toList());
issuesIds.forEach(issuesId -> {
Issues dto = getTapdIssues(tapdId, issuesId);
if (StringUtils.isBlank(dto.getId())) {
@ -423,7 +432,7 @@ public class IssuesService {
List<Issues> issues = extIssuesMapper.getIssues(caseId, IssuesManagePlatform.Jira.toString());
List<String> issuesIds = issues.stream().map(issue -> issue.getId()).collect(Collectors.toList());
List<String> issuesIds = issues.stream().map(Issues::getId).collect(Collectors.toList());
issuesIds.forEach(issuesId -> {
Issues dto = getJiraIssues(headers, url, issuesId);
if (StringUtils.isBlank(dto.getId())) {
@ -445,7 +454,11 @@ public class IssuesService {
}
public List<Issues> getLocalIssues(String caseId) {
return extIssuesMapper.getIssues(caseId, IssuesManagePlatform.Local.toString());
List<Issues> list = extIssuesMapper.getIssues(caseId, IssuesManagePlatform.Local.toString());
List<Issues> issues = list.stream()
.filter(l -> !StringUtils.equals(l.getStatus(), "closed"))
.collect(Collectors.toList());
return issues;
}
public String getTapdProjectId(String testCaseId) {
@ -471,4 +484,11 @@ public class IssuesService {
return StringUtils.isNotBlank(integration.getId());
}
public void closeLocalIssue(String issueId) {
Issues issues = new Issues();
issues.setId(issueId);
issues.setStatus("closed");
issuesMapper.updateByPrimaryKeySelective(issues);
}
}

@ -1 +1 @@
Subproject commit b86032cbbda9a9e6028308aa95a887cff2192f1c
Subproject commit 8eff343619df1572e1cded52f173257ef4b518a1

View File

@ -118,7 +118,6 @@ test_case_already_exists_excel=There are duplicate test cases in the import file
test_case_module_already_exists=The module name already exists at the same level
api_test_name_already_exists=Test name already exists
functional_method_tip=Functional test not support auto method
#ldap
ldap_url_is_null=LDAP address is empty
ldap_dn_is_null=LDAP binding DN is empty
@ -136,4 +135,10 @@ login_fail_email_null=Login failed, user mailbox is empty
login_fail_ou_error=Login failed, please check the user OU
login_fail_filter_error=Login failed, please check the user filter
check_ldap_mapping=Check LDAP attribute mapping
ldap_mapping_value_null=LDAP user attribute mapping field is empty
ldap_mapping_value_null=LDAP user attribute mapping field is empty
#quota
quota_workspace_excess_org_api=The total number of interface tests in the workspace cannot exceed the organization's quota
quota_workspace_excess_org_performance=The total number of performance tests for the workspace cannot exceed the organization's quota
quota_workspace_excess_org_max_threads=The maximum concurrent number of workspaces cannot exceed the quota of the organization
quota_workspace_excess_org_max_duration=The stress test duration of the workspace cannot exceed the organization's quota
quota_workspace_excess_org_resource_pool=The resource pool of the workspace cannot exceed the resource pool of the organization

View File

@ -118,7 +118,6 @@ test_case_already_exists_excel=导入文件中存在重复用例
test_case_module_already_exists=同层级下已存在该模块名称
api_test_name_already_exists=测试名称已经存在
functional_method_tip=功能测试不支持自动方式
#ldap
ldap_url_is_null=LDAP地址为空
ldap_dn_is_null=LDAP绑定DN为空
@ -137,5 +136,12 @@ login_fail_ou_error=登录失败请检查用户OU
login_fail_filter_error=登录失败,请检查用户过滤器
check_ldap_mapping=检查LDAP属性映射
ldap_mapping_value_null=LDAP用户属性映射字段为空值
#quota
quota_workspace_excess_org_api=工作空间的接口测试数量总和不能超过组织的配额
quota_workspace_excess_org_performance=工作空间的性能测试数量总和不能超过组织的配额
quota_workspace_excess_org_max_threads=工作空间的最大并发数不能超过组织的配额
quota_workspace_excess_org_max_duration=工作空间的压测时长不能超过组织的配额
quota_workspace_excess_org_resource_pool=工作空间的资源池不能超过组织的资源池范围

View File

@ -118,7 +118,6 @@ test_case_already_exists_excel=導入文件中存在重復用例
test_case_module_already_exists=同層級下已存在該模塊名稱
api_test_name_already_exists=測試名稱已經存在
functional_method_tip=功能測試不支持自動方式
#ldap
ldap_url_is_null=LDAP地址為空
ldap_dn_is_null=LDAP綁定DN為空
@ -137,3 +136,9 @@ login_fail_ou_error=登錄失敗請檢查用戶OU
login_fail_filter_error=登錄失敗,請檢查用戶過濾器
check_ldap_mapping=檢查LDAP屬性映射
ldap_mapping_value_null=LDAP用戶屬性映射預設為空值
#quota
quota_workspace_excess_org_api=工作空間的接口測試數量總和不能超過組織的配額
quota_workspace_excess_org_performance=工作空間的性能測試數量總和不能超過組織的配額
quota_workspace_excess_org_max_threads=工作空間的最大並發數不能超過組織的配額
quota_workspace_excess_org_max_duration=工作空間的壓測時長不能超過組織的配額
quota_workspace_excess_org_resource_pool=工作空間的資源池不能超過組織的資源池範圍

View File

@ -1,6 +1,6 @@
<template>
<el-card class="header-title">
<div v-loading="result.loading">
<el-card class="header-title" v-loading="result.loading">
<div>
<div>{{$t('organization.select_defect_platform')}}</div>
<el-radio-group v-model="platform" style="margin-top: 10px" @change="change">
<el-radio v-for="(item, index) in platforms" :key="index" :label="item.value" size="small">
@ -26,12 +26,12 @@
</div>
<div style="margin-left: 100px">
<el-button type="primary" size="small" :disabled="!show" @click="testConnection">{{$t('ldap.test_connect')}}
<el-button type="primary" size="mini" :disabled="!show" @click="testConnection">{{$t('ldap.test_connect')}}
</el-button>
<el-button v-if="showEdit" size="small" @click="edit">{{$t('commons.edit')}}</el-button>
<el-button type="primary" v-if="showSave" size="small" @click="save('form')">{{$t('commons.save')}}</el-button>
<el-button v-if="showCancel" size="small" @click="cancelEdit">取消编辑</el-button>
<el-button type="info" size="small" @click="cancelIntegration('form')" :disabled="!show">
<el-button v-if="showEdit" size="mini" @click="edit">{{$t('commons.edit')}}</el-button>
<el-button type="primary" v-if="showSave" size="mini" @click="save('form')">{{$t('commons.save')}}</el-button>
<el-button v-if="showCancel" size="mini" @click="cancelEdit">取消编辑</el-button>
<el-button type="info" size="mini" @click="cancelIntegration('form')" :disabled="!show">
取消集成
</el-button>
</div>
@ -54,7 +54,7 @@
import {getCurrentUser} from "../../../../common/js/utils";
export default {
name: "DefectManagement",
name: "IssuesManagement",
data() {
return {
form: {},
@ -195,7 +195,7 @@
});
},
testConnection() {
this.$get("issues/auth/" + this.platform, () => {
this.result = this.$get("issues/auth/" + this.platform, () => {
this.$success("验证通过!");
});
}

View File

@ -10,7 +10,7 @@
<script>
import DefectManagement from "./DefectManagement";
import DefectManagement from "./IssuesManagement";
export default {
name: "ServiceIntegration",

View File

@ -61,6 +61,7 @@
</template>
</el-table-column>
</el-table>
<div style="text-align: center"> {{testCases.length}} </div>
</el-main>
</el-container>
</el-container>
@ -161,6 +162,8 @@
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// param.nodeIds = this.selectNodeIds;
this.condition.nodeIds = this.selectNodeIds;
} else {
this.condition.nodeIds = [];
}
this.result = this.$post('/test/case/name', this.condition, response => {
this.testCases = response.data;

View File

@ -207,11 +207,22 @@
<el-row>
<el-col :span="20" :offset="1" class="issues-edit">
<el-table border class="adjust-table" :data="issues" style="width: 100%">
<el-table-column prop="id" label="缺陷ID"/>
<el-table-column prop="id" label="缺陷ID" show-overflow-tooltip/>
<el-table-column prop="title" label="缺陷标题"/>
<el-table-column prop="status" label="缺陷状态"/>
<el-table-column prop="description" label="缺陷描述" show-overflow-tooltip/>
<el-table-column prop="status" label="缺陷状态"/>
<el-table-column prop="platform" label="平台"/>
<el-table-column label="操作">
<template v-slot:default="scope">
<el-tooltip content="关闭缺陷"
placement="right">
<el-button type="danger" icon="el-icon-circle-close" size="mini"
circle v-if="scope.row.platform === 'Local'"
@click="closeIssue(scope.row)"
/>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
@ -475,11 +486,16 @@
})
},
getIssues(caseId) {
this.result = this.$get("/issues/get/"+caseId,response => {
this.result = this.$get("/issues/get/" + caseId, response => {
let data = response.data;
this.issues = data;
console.log(data);
})
},
closeIssue(row) {
this.result = this.$get("/issues/close/" + row.id, () => {
this.getIssues(this.testCase.caseId);
this.$success("关闭成功");
});
}
}
}

View File

@ -102,6 +102,28 @@
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="nodePath"
label="缺陷"
show-overflow-tooltip>
<template v-slot:default="scope">
<el-popover
placement="right"
width="400"
trigger="hover">
<el-table border class="adjust-table" :data="scope.row.issuesContent" style="width: 100%">
<!-- <el-table-column prop="id" label="缺陷ID" show-overflow-tooltip/>-->
<el-table-column prop="title" label="缺陷标题"/>
<el-table-column prop="description" label="缺陷描述" show-overflow-tooltip/>
<!-- <el-table-column prop="status" label="缺陷状态"/>-->
<el-table-column prop="platform" label="平台"/>
</el-table>
<el-button slot="reference" type="text">{{scope.row.issuesSize}}</el-button>
</el-popover>
</template>
</el-table-column>
<el-table-column
prop="executorName"
:label="$t('test_track.plan_view.executor')">
@ -317,6 +339,14 @@
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
for (let i = 0; i < this.tableData.length; i++) {
this.$set(this.tableData[i], "issuesSize", 0);
this.$get("/issues/get/" + this.tableData[i].caseId, response => {
let issues = response.data;
this.$set(this.tableData[i], "issuesSize", issues.length);
this.$set(this.tableData[i], "issuesContent", issues);
})
}
// this.selectIds.clear();
this.selectRows.clear();
});

@ -1 +1 @@
Subproject commit 7e4d80cc2b870a8cac6dbb9fe6711ab6041faf6d
Subproject commit 06fc0a321a9886419be5c607ddaa6b40efb5179b

View File

@ -815,5 +815,7 @@ export default {
modify: "Modify Quota",
edit_quota_title: "{0} quota",
workspace_quota_list: "Workspace quota list of {0}",
unlimited: "Unlimited",
clean: "Clean"
}
};

View File

@ -817,5 +817,7 @@ export default {
modify: "修改配额",
edit_quota_title: "{0}的配额",
workspace_quota_list: "{0}的工作空间配额列表",
unlimited: "无限制",
clean: "清空"
}
};

View File

@ -814,5 +814,7 @@ export default {
modify: "修改配額",
edit_quota_title: "{0}的配額",
workspace_quota_list: "{0}的工作空間配額列表",
unlimited: "無限制",
clean: "清空"
}
};