Merge branch 'main' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
8b7fe7b807
|
@ -23,6 +23,7 @@ import io.metersphere.commons.utils.GenerateHashTreeUtil;
|
||||||
import io.metersphere.utils.LoggerUtil;
|
import io.metersphere.utils.LoggerUtil;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -204,12 +205,11 @@ public class ApiJMeterFileService {
|
||||||
new TreeSet<>(Comparator.comparing(Plugin::getPluginId))), ArrayList::new));
|
new TreeSet<>(Comparator.comparing(Plugin::getPluginId))), ArrayList::new));
|
||||||
plugins.forEach(item -> {
|
plugins.forEach(item -> {
|
||||||
File file = new File(item.getSourcePath());
|
File file = new File(item.getSourcePath());
|
||||||
if (file.isDirectory() && !item.getSourcePath().endsWith("/")) {
|
if (file.exists() && !file.isDirectory()) {
|
||||||
file = new File(item.getSourcePath() + "/");
|
byte[] fileByte = FileUtils.fileToByte(file);
|
||||||
}
|
if (ArrayUtils.isNotEmpty(fileByte)) {
|
||||||
byte[] fileByte = FileUtils.fileToByte(file);
|
jarFiles.put(file.getName(), fileByte);
|
||||||
if (fileByte != null) {
|
}
|
||||||
jarFiles.put(file.getName(), fileByte);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ public class PluginService {
|
||||||
List<PluginDTO> lists = new LinkedList<>();
|
List<PluginDTO> lists = new LinkedList<>();
|
||||||
try {
|
try {
|
||||||
PluginExample example = new PluginExample();
|
PluginExample example = new PluginExample();
|
||||||
|
example.createCriteria().andScenarioEqualTo(PluginScenario.api.name());
|
||||||
if (StringUtils.isNotBlank(name)) {
|
if (StringUtils.isNotBlank(name)) {
|
||||||
name = "%" + name + "%";
|
name = "%" + name + "%";
|
||||||
example.createCriteria().andNameLike(name);
|
example.createCriteria().andNameLike(name);
|
||||||
|
@ -158,6 +159,7 @@ public class PluginService {
|
||||||
|
|
||||||
public List<Plugin> list() {
|
public List<Plugin> list() {
|
||||||
PluginExample example = new PluginExample();
|
PluginExample example = new PluginExample();
|
||||||
|
example.createCriteria().andScenarioEqualTo(PluginScenario.api.name());
|
||||||
List<Plugin> plugins = pluginMapper.selectByExample(example);
|
List<Plugin> plugins = pluginMapper.selectByExample(example);
|
||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import io.metersphere.service.BaseProjectApplicationService;
|
||||||
import io.metersphere.service.MockConfigService;
|
import io.metersphere.service.MockConfigService;
|
||||||
import io.metersphere.service.ServiceUtils;
|
import io.metersphere.service.ServiceUtils;
|
||||||
import io.metersphere.service.ext.ExtApiScheduleService;
|
import io.metersphere.service.ext.ExtApiScheduleService;
|
||||||
import io.metersphere.xpack.api.service.ApiDefinitionSyncService;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -322,16 +321,11 @@ public class ApiDefinitionImportUtilService {
|
||||||
if (fullCoverage) {
|
if (fullCoverage) {
|
||||||
removeHttpChooseModuleRepeat(optionData, chooseModulePath);
|
removeHttpChooseModuleRepeat(optionData, chooseModulePath);
|
||||||
// optionData = singleOptionData;
|
// optionData = singleOptionData;
|
||||||
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(chooseModulePath), api -> api));
|
// optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(chooseModulePath), api -> api));
|
||||||
} else {
|
|
||||||
getChooseModuleUrlRepeatOptionMap(optionData, optionMap, chooseModulePath);
|
|
||||||
}
|
}
|
||||||
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().filter(t -> t.getModuleId().equals(chooseModule.getId())).collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath())));
|
|
||||||
} else {
|
|
||||||
//否则在整个系统中过滤
|
|
||||||
getUrlRepeatOptionMap(optionData, optionMap);
|
|
||||||
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath())));
|
|
||||||
}
|
}
|
||||||
|
getUrlRepeatOptionMap(optionData, optionMap);
|
||||||
|
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath())));
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
|
||||||
//重复接口的case
|
//重复接口的case
|
||||||
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ export const ROLE_ORG_ADMIN = 'org_admin';
|
||||||
export const ROLE_TEST_MANAGER = 'test_manager';
|
export const ROLE_TEST_MANAGER = 'test_manager';
|
||||||
export const ROLE_TEST_USER = 'test_user';
|
export const ROLE_TEST_USER = 'test_user';
|
||||||
export const ROLE_TEST_VIEWER = 'test_viewer';
|
export const ROLE_TEST_VIEWER = 'test_viewer';
|
||||||
|
export const SUPER_GROUP = 'super_group';
|
||||||
|
|
||||||
export const ORGANIZATION_ID = 'organization_id';
|
export const ORGANIZATION_ID = 'organization_id';
|
||||||
export const WORKSPACE_ID = 'workspace_id';
|
export const WORKSPACE_ID = 'workspace_id';
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
import {LicenseKey} from "./constants";
|
import {LicenseKey, SUPER_GROUP} from "./constants";
|
||||||
import {getCurrentProjectID, getCurrentUser, getCurrentWorkspaceId} from "./token";
|
import {getCurrentProjectID, getCurrentUser, getCurrentWorkspaceId} from "./token";
|
||||||
|
|
||||||
export function hasPermission(permission) {
|
export function hasPermission(permission) {
|
||||||
let user = getCurrentUser();
|
let user = getCurrentUser();
|
||||||
|
let index = user.groups.findIndex(g => g.id === SUPER_GROUP);
|
||||||
|
if (index !== -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
user.userGroups.forEach(ug => {
|
user.userGroups.forEach(ug => {
|
||||||
user.groupPermissions.forEach(gp => {
|
user.groupPermissions.forEach(gp => {
|
||||||
|
@ -13,20 +17,6 @@ export function hasPermission(permission) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let superGroupPermissions = user.userGroups.filter(ug => ug.group && ug.group.id === 'super_group')
|
|
||||||
.flatMap(ug => ug.userGroupPermissions)
|
|
||||||
.map(g => g.permissionId)
|
|
||||||
.reduce((total, current) => {
|
|
||||||
total.add(current);
|
|
||||||
return total;
|
|
||||||
}, new Set);
|
|
||||||
|
|
||||||
for (const p of superGroupPermissions) {
|
|
||||||
if (p === permission) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo 权限验证
|
// todo 权限验证
|
||||||
let currentProjectPermissions = user.userGroups.filter(ug => ug.group && ug.group.type === 'PROJECT')
|
let currentProjectPermissions = user.userGroups.filter(ug => ug.group && ug.group.type === 'PROJECT')
|
||||||
.filter(ug => ug.sourceId === getCurrentProjectID())
|
.filter(ug => ug.sourceId === getCurrentProjectID())
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.commons.utils;
|
||||||
|
|
||||||
import io.metersphere.base.domain.Group;
|
import io.metersphere.base.domain.Group;
|
||||||
import io.metersphere.base.domain.UserGroupPermission;
|
import io.metersphere.base.domain.UserGroupPermission;
|
||||||
|
import io.metersphere.commons.constants.UserGroupConstants;
|
||||||
import io.metersphere.commons.user.SessionUser;
|
import io.metersphere.commons.user.SessionUser;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -141,6 +142,15 @@ public class SessionUtils {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
long count = user.getGroups()
|
||||||
|
.stream()
|
||||||
|
.filter(g -> StringUtils.equals(g.getId(), UserGroupConstants.SUPER_GROUP))
|
||||||
|
.count();
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Set<String> currentProjectPermissions = getCurrentProjectPermissions(userGroupPermissions, projectId, group, user);
|
Set<String> currentProjectPermissions = getCurrentProjectPermissions(userGroupPermissions, projectId, group, user);
|
||||||
if (currentProjectPermissions.contains(permission)) {
|
if (currentProjectPermissions.contains(permission)) {
|
||||||
|
|
|
@ -70,8 +70,6 @@ public class GroupService {
|
||||||
@Resource
|
@Resource
|
||||||
private BaseUserService baseUserService;
|
private BaseUserService baseUserService;
|
||||||
private static final String GLOBAL = "global";
|
private static final String GLOBAL = "global";
|
||||||
private static final String SUPER_GROUP = "super_group";
|
|
||||||
|
|
||||||
|
|
||||||
// 服务权限拼装顺序
|
// 服务权限拼装顺序
|
||||||
private static final String[] servicePermissionLoadOrder = {MicroServiceName.PROJECT_MANAGEMENT,
|
private static final String[] servicePermissionLoadOrder = {MicroServiceName.PROJECT_MANAGEMENT,
|
||||||
|
@ -225,7 +223,7 @@ public class GroupService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editGroupPermission(EditGroupRequest request) {
|
public void editGroupPermission(EditGroupRequest request) {
|
||||||
if (StringUtils.equals(request.getUserGroupId(), SUPER_GROUP)) {
|
if (StringUtils.equals(request.getUserGroupId(), UserGroupConstants.SUPER_GROUP)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<GroupPermission> permissions = request.getPermissions();
|
List<GroupPermission> permissions = request.getPermissions();
|
||||||
|
|
|
@ -68,7 +68,6 @@ public class GroupService {
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|
||||||
private static final String GLOBAL = "global";
|
private static final String GLOBAL = "global";
|
||||||
private static final String SUPER_GROUP = "super_group";
|
|
||||||
private static final String PERSONAL_PREFIX = "PERSONAL";
|
private static final String PERSONAL_PREFIX = "PERSONAL";
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,7 +235,7 @@ public class GroupService {
|
||||||
|
|
||||||
public void editGroupPermission(EditGroupRequest request) {
|
public void editGroupPermission(EditGroupRequest request) {
|
||||||
// 超级用户组禁止修改权限
|
// 超级用户组禁止修改权限
|
||||||
if (StringUtils.equals(request.getUserGroupId(), SUPER_GROUP)) {
|
if (StringUtils.equals(request.getUserGroupId(), UserGroupConstants.SUPER_GROUP)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<GroupPermission> permissions = request.getPermissions();
|
List<GroupPermission> permissions = request.getPermissions();
|
||||||
|
@ -331,19 +330,21 @@ public class GroupService {
|
||||||
private List<GroupResourceDTO> getResourcePermission(List<GroupResource> resources, List<GroupPermission> permissions, Group group, List<String> permissionList) {
|
private List<GroupResourceDTO> getResourcePermission(List<GroupResource> resources, List<GroupPermission> permissions, Group group, List<String> permissionList) {
|
||||||
List<GroupResourceDTO> dto = new ArrayList<>();
|
List<GroupResourceDTO> dto = new ArrayList<>();
|
||||||
List<GroupResource> grs;
|
List<GroupResource> grs;
|
||||||
if (StringUtils.equals(group.getId(), SUPER_GROUP)) {
|
if (StringUtils.equals(group.getId(), UserGroupConstants.SUPER_GROUP)) {
|
||||||
grs = resources;
|
grs = resources;
|
||||||
|
permissions.forEach(p -> p.setChecked(true));
|
||||||
} else {
|
} else {
|
||||||
grs = resources
|
grs = resources
|
||||||
.stream()
|
.stream()
|
||||||
.filter(g -> g.getId().startsWith(group.getType()) || g.getId().startsWith(PERSONAL_PREFIX))
|
.filter(g -> g.getId().startsWith(group.getType()) || g.getId().startsWith(PERSONAL_PREFIX))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
permissions.forEach(p -> {
|
||||||
|
if (permissionList.contains(p.getId())) {
|
||||||
|
p.setChecked(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
permissions.forEach(p -> {
|
|
||||||
if (permissionList.contains(p.getId())) {
|
|
||||||
p.setChecked(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (GroupResource r : grs) {
|
for (GroupResource r : grs) {
|
||||||
GroupResourceDTO resourceDTO = new GroupResourceDTO();
|
GroupResourceDTO resourceDTO = new GroupResourceDTO();
|
||||||
resourceDTO.setResource(r);
|
resourceDTO.setResource(r);
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
import GroupPermission from "./GroupPermission";
|
import GroupPermission from "./GroupPermission";
|
||||||
import {PROJECT_GROUP_SCOPE, USER_GROUP_SCOPE} from "metersphere-frontend/src/utils/table-constants";
|
import {PROJECT_GROUP_SCOPE, USER_GROUP_SCOPE} from "metersphere-frontend/src/utils/table-constants";
|
||||||
import {hasLicense} from "metersphere-frontend/src/utils/permission";
|
import {hasLicense} from "metersphere-frontend/src/utils/permission";
|
||||||
import {GROUP_TYPE} from 'metersphere-frontend/src/utils/constants'
|
import {GROUP_TYPE, SUPER_GROUP} from 'metersphere-frontend/src/utils/constants'
|
||||||
import {getUserGroupPermission, modifyUserGroupPermission} from "../../../api/user-group";
|
import {getUserGroupPermission, modifyUserGroupPermission} from "../../../api/user-group";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -99,7 +99,7 @@ export default {
|
||||||
},
|
},
|
||||||
isReadOnly() {
|
isReadOnly() {
|
||||||
return function (data) {
|
return function (data) {
|
||||||
if (this.group.id === 'super_group') {
|
if (this.group.id === SUPER_GROUP) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const isDefaultSystemGroup = this.group.id === 'admin' && data.resource.id === 'SYSTEM_GROUP';
|
const isDefaultSystemGroup = this.group.id === 'admin' && data.resource.id === 'SYSTEM_GROUP';
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {SUPER_GROUP} from 'metersphere-frontend/src/utils/constants';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "GroupPermission",
|
name: "GroupPermission",
|
||||||
props: {
|
props: {
|
||||||
|
@ -45,7 +47,7 @@ export default {
|
||||||
isReadOnly() {
|
isReadOnly() {
|
||||||
return function (permission) {
|
return function (permission) {
|
||||||
// 禁止取消系统管理员用户组权限
|
// 禁止取消系统管理员用户组权限
|
||||||
if (this.group.id === 'super_group') {
|
if (this.group.id === SUPER_GROUP) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 禁止取消系统管理员用户组和超级管理员用户组的读取和设置权限
|
// 禁止取消系统管理员用户组和超级管理员用户组的读取和设置权限
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<el-table-column prop="description" :label="$t('group.description')" show-overflow-tooltip/>
|
<el-table-column prop="description" :label="$t('group.description')" show-overflow-tooltip/>
|
||||||
<el-table-column :label="$t('commons.operating')" min-width="120">
|
<el-table-column :label="$t('commons.operating')" min-width="120">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<div v-if="scope.row.id === 'super_group'">
|
<div v-if="scope.row.id === SUPER_GROUP">
|
||||||
<ms-table-operator
|
<ms-table-operator
|
||||||
:is-show="true"
|
:is-show="true"
|
||||||
@editClick="edit(scope.row)" @deleteClick="del(scope.row)">
|
@editClick="edit(scope.row)" @deleteClick="del(scope.row)">
|
||||||
|
@ -101,6 +101,8 @@ import {_sort} from "metersphere-frontend/src/utils/tableUtils";
|
||||||
import GroupMember from "./GroupMember";
|
import GroupMember from "./GroupMember";
|
||||||
import {hasPermission} from "metersphere-frontend/src/utils/permission";
|
import {hasPermission} from "metersphere-frontend/src/utils/permission";
|
||||||
import {delUserGroupById, getUserGroupListByPage} from "../../../api/user-group";
|
import {delUserGroupById, getUserGroupListByPage} from "../../../api/user-group";
|
||||||
|
import {SUPER_GROUP} from 'metersphere-frontend/src/utils/constants'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "UserGroup",
|
name: "UserGroup",
|
||||||
|
@ -123,6 +125,7 @@ export default {
|
||||||
total: 0,
|
total: 0,
|
||||||
screenHeight: 'calc(100vh - 160px)',
|
screenHeight: 'calc(100vh - 160px)',
|
||||||
groups: [],
|
groups: [],
|
||||||
|
SUPER_GROUP
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
|
|
|
@ -491,22 +491,21 @@ public class TestPlanReportService {
|
||||||
return testPlanReport;
|
return testPlanReport;
|
||||||
}
|
}
|
||||||
boolean isSendMessage = false;
|
boolean isSendMessage = false;
|
||||||
|
|
||||||
if (testPlanReport != null) {
|
if (testPlanReport != null) {
|
||||||
testPlanReport.setIsApiCaseExecuting(false);
|
testPlanReport.setIsApiCaseExecuting(false);
|
||||||
testPlanReport.setIsScenarioExecuting(false);
|
testPlanReport.setIsScenarioExecuting(false);
|
||||||
testPlanReport.setIsPerformanceExecuting(false);
|
testPlanReport.setIsPerformanceExecuting(false);
|
||||||
testPlanReport.setIsUiScenarioExecuting(false);
|
testPlanReport.setIsUiScenarioExecuting(false);
|
||||||
|
|
||||||
if (StringUtils.equalsIgnoreCase(testPlanReport.getStatus(), ExecuteResult.TEST_PLAN_RUNNING.toString())) {
|
if (StringUtils.equalsIgnoreCase(testPlanReport.getStatus(), ExecuteResult.TEST_PLAN_RUNNING.toString())) {
|
||||||
isSendMessage = true;
|
isSendMessage = true;
|
||||||
}
|
}
|
||||||
TestPlanReportContentWithBLOBs content = null;
|
TestPlanReportContentWithBLOBs content = null;
|
||||||
try {
|
try {
|
||||||
HttpHeaderUtils.runAsUser(testPlanReport.getCreator());
|
HttpHeaderUtils.runAsUser(testPlanReport.getCreator());
|
||||||
testPlanReport.setStatus(status);
|
boolean isRerunningTestPlan = BooleanUtils.isTrue(StringUtils.equalsIgnoreCase(testPlanReport.getStatus(), APITestStatus.Rerunning.name()));
|
||||||
content = this.initTestPlanContent(testPlanReport, status);
|
content = this.initTestPlanContent(testPlanReport, status, isRerunningTestPlan);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
testPlanReport.setStatus(status);
|
||||||
LogUtil.error("统计测试计划状态失败!", e);
|
LogUtil.error("统计测试计划状态失败!", e);
|
||||||
} finally {
|
} finally {
|
||||||
HttpHeaderUtils.clearUser();
|
HttpHeaderUtils.clearUser();
|
||||||
|
@ -518,24 +517,19 @@ public class TestPlanReportService {
|
||||||
return testPlanReport;
|
return testPlanReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestPlanReportContentWithBLOBs initTestPlanContent(TestPlanReport testPlanReport, String status) throws Exception {
|
private TestPlanReportContentWithBLOBs initTestPlanContent(TestPlanReport testPlanReport, String status, boolean isRerunningTestPlan) throws Exception {
|
||||||
|
testPlanReport.setStatus(status);
|
||||||
TestPlanReportContentWithBLOBs content = null;
|
TestPlanReportContentWithBLOBs content = null;
|
||||||
//初始化测试计划包含组件信息
|
//初始化测试计划包含组件信息
|
||||||
int[] componentIndexArr = new int[]{1, 3, 4};
|
int[] componentIndexArr = new int[]{1, 3, 4};
|
||||||
testPlanReport.setComponents(JSON.toJSONString(componentIndexArr));
|
testPlanReport.setComponents(JSON.toJSONString(componentIndexArr));
|
||||||
//如果测试案例没有未结束的功能用例,则更新最后结束日期。
|
|
||||||
TestPlanTestCaseMapper testPlanTestCaseMapper = CommonBeanFactory.getBean(TestPlanTestCaseMapper.class);
|
|
||||||
TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample();
|
|
||||||
testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(testPlanReport.getTestPlanId()).andStatusNotEqualTo("Prepare");
|
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
long testCaseCount = testPlanTestCaseMapper.countByExample(testPlanTestCaseExample);
|
//原逻辑中要判断包含测试计划功能用例时才会赋予结束时间。执行测试计划产生的测试报告,它的结束时间感觉没有这种判断必要。
|
||||||
boolean updateTestPlanTime = testCaseCount > 0;
|
testPlanReport.setEndTime(endTime);
|
||||||
if (updateTestPlanTime && !StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), APITestStatus.Rerunning.name())) {
|
testPlanReport.setUpdateTime(endTime);
|
||||||
testPlanReport.setEndTime(endTime);
|
|
||||||
testPlanReport.setUpdateTime(endTime);
|
|
||||||
}
|
|
||||||
TestPlanReportContentExample contentExample = new TestPlanReportContentExample();
|
TestPlanReportContentExample contentExample = new TestPlanReportContentExample();
|
||||||
contentExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReport.getTestPlanId());
|
contentExample.createCriteria().andTestPlanReportIdEqualTo(testPlanReport.getId());
|
||||||
List<TestPlanReportContentWithBLOBs> contents = testPlanReportContentMapper.selectByExampleWithBLOBs(contentExample);
|
List<TestPlanReportContentWithBLOBs> contents = testPlanReportContentMapper.selectByExampleWithBLOBs(contentExample);
|
||||||
if (CollectionUtils.isNotEmpty(contents)) {
|
if (CollectionUtils.isNotEmpty(contents)) {
|
||||||
content = contents.get(0);
|
content = contents.get(0);
|
||||||
|
@ -550,8 +544,8 @@ public class TestPlanReportService {
|
||||||
testPlanService.checkStatus(testPlanReport.getTestPlanId());
|
testPlanService.checkStatus(testPlanReport.getTestPlanId());
|
||||||
}
|
}
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
//更新content表对结束日期
|
//更新content表对结束日期 重跑的测试计划报告不用更新
|
||||||
if (!StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), APITestStatus.Rerunning.name())) {
|
if (!isRerunningTestPlan) {
|
||||||
content.setStartTime(testPlanReport.getStartTime());
|
content.setStartTime(testPlanReport.getStartTime());
|
||||||
content.setEndTime(endTime);
|
content.setEndTime(endTime);
|
||||||
}
|
}
|
||||||
|
@ -603,8 +597,13 @@ public class TestPlanReportService {
|
||||||
|
|
||||||
private void initTestPlanReportBaseCount(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs reportContent) {
|
private void initTestPlanReportBaseCount(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs reportContent) {
|
||||||
if (testPlanReport != null && reportContent != null) {
|
if (testPlanReport != null && reportContent != null) {
|
||||||
TestPlanReportBuildResultDTO reportBuildResultDTO = testPlanService.buildPlanReport(testPlanReport, reportContent);
|
try {
|
||||||
reportContent.setApiBaseCount(JSON.toJSONString(reportBuildResultDTO.getTestPlanSimpleReportDTO()));
|
TestPlanReportBuildResultDTO reportBuildResultDTO = testPlanService.buildPlanReport(testPlanReport, reportContent);
|
||||||
|
reportContent.setApiBaseCount(JSON.toJSONString(reportBuildResultDTO.getTestPlanSimpleReportDTO()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error("计算测试计划报告信息出错!", e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue