Merge branch 'master' into local-api-delimit

# Conflicts:
#	backend/src/main/java/io/metersphere/api/service/APITestService.java
#	backend/src/main/resources/i18n/messages_zh_TW.properties
#	frontend/src/business/components/api/report/components/ResponseText.vue
This commit is contained in:
fit2-zhao 2020-11-24 10:56:36 +08:00
commit 9408555bba
40 changed files with 400 additions and 180 deletions

View File

@ -8,20 +8,27 @@ import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter;
import io.metersphere.api.jmeter.JMeterService;
import io.metersphere.api.parse.ApiImportParser;
import io.metersphere.api.parse.ApiImportParserFactory;
import io.metersphere.api.parse.JmeterDocumentParser;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiTestFileMapper;
import io.metersphere.base.mapper.ApiTestMapper;
import io.metersphere.base.mapper.ext.ExtApiTestMapper;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.constants.FileType;
import io.metersphere.commons.constants.ScheduleGroup;
import io.metersphere.commons.constants.ScheduleType;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*;
import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.dto.ScheduleDao;
import io.metersphere.i18n.Translator;
import io.metersphere.job.sechedule.ApiTestJob;
import io.metersphere.notice.service.MailService;
import io.metersphere.notice.service.NoticeService;
import io.metersphere.service.FileService;
import io.metersphere.service.QuotaService;
import io.metersphere.service.ScheduleService;
import io.metersphere.service.UserService;
import io.metersphere.track.service.TestCaseService;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
@ -39,6 +46,8 @@ import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class APITestService {
@Resource
private UserService userService;
@Resource
private ApiTestMapper apiTestMapper;
@Resource
@ -55,6 +64,11 @@ public class APITestService {
private ScheduleService scheduleService;
@Resource
private TestCaseService testCaseService;
@Resource
private MailService mailService;
@Resource
private NoticeService noticeService;
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
@ -72,19 +86,33 @@ public class APITestService {
return extApiTestMapper.listByIds(request.getIds());
}
public void create(SaveAPITestRequest request, List<MultipartFile> bodyFiles) {
public void create(SaveAPITestRequest request, MultipartFile file, List<MultipartFile> bodyFiles) {
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
ApiTest test = createTest(request);
ApiTest test = createTest(request, file);
createBodyFiles(test, bodyUploadIds, bodyFiles);
}
private ApiTest createTest(SaveAPITestRequest request, MultipartFile file) {
if (file == null) {
throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
}
checkQuota();
request.setBodyUploadIds(null);
ApiTest test = createTest(request);
saveFile(test.getId(), file);
return test;
}
public void update(SaveAPITestRequest request, List<MultipartFile> bodyFiles) {
public void update(SaveAPITestRequest request, MultipartFile file, List<MultipartFile> bodyFiles) {
if (file == null) {
throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
}
deleteFileByTestId(request.getId());
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
request.setBodyUploadIds(null);
ApiTest test = updateTest(request);
createBodyFiles(test, bodyUploadIds, bodyFiles);
saveFile(test.getId(), file);
}
private void createBodyFiles(ApiTest test, List<String> bodyUploadIds, List<MultipartFile> bodyFiles) {
@ -127,6 +155,14 @@ public class APITestService {
copy.setStatus(APITestStatus.Saved.name());
copy.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
apiTestMapper.insert(copy);
// copy test file
ApiTestFile apiTestFile = getFileByTestId(request.getId());
if (apiTestFile != null) {
FileMetadata fileMetadata = fileService.copyFile(apiTestFile.getFileId());
apiTestFile.setTestId(copy.getId());
apiTestFile.setFileId(fileMetadata.getId());
apiTestFileMapper.insert(apiTestFile);
}
copyBodyFiles(copy.getId(), request.getId());
}

View File

@ -9,4 +9,5 @@ import java.util.List;
public interface ExtWorkspaceMapper {
List<WorkspaceDTO> getWorkspaceWithOrg(@Param("request") WorkspaceRequest request);
List<String> getWorkspaceIdsByOrgId(@Param("orgId") String orgId);
}

View File

@ -13,4 +13,9 @@
order by w.update_time desc
</select>
<select id="getWorkspaceIdsByOrgId" resultType="java.lang.String">
select id from workspace
where organization_id = #{orgId}
</select>
</mapper>

View File

@ -12,6 +12,7 @@ import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import org.apache.commons.lang3.StringUtils;
public class JsonPathUtils {
@ -68,9 +69,26 @@ public class JsonPathUtils {
.compareTo( (String)b.get("json_path") )
);
// 正则特殊字符转义
allJsons.forEach(item -> {
item.put("regular_expression", escapeExprSpecialWord((String) item.get("json_value")));
});
return allJsons;
}
public static String escapeExprSpecialWord(String keyword) {
if (StringUtils.isNotBlank(keyword)) {
String[] fbsArr = {"\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|"};
for (String key : fbsArr) {
if (keyword.contains(key)) {
keyword = keyword.replace(key, "\\" + key);
}
}
}
return keyword;
}
private static String formatJson(String json_path){
String ret="";
String reg = ".(\\d{1,3}).{0,1}";

View File

@ -3,6 +3,7 @@ package io.metersphere.controller;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.User;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.handler.annotation.NoResultHolder;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -34,6 +35,26 @@ public class TestController {
return jsonObject;
}
@NoResultHolder
@GetMapping(value = "/xml")
public String getXmlString() {
return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
"\n" +
"<bookstore>\n" +
"\n" +
"<book>\n" +
" <title lang=\"eng\">Harry Potter</title>\n" +
" <price>29.99</price>\n" +
"</book>\n" +
"\n" +
"<book>\n" +
" <title lang=\"eng\">Learning XML</title>\n" +
" <price>39.95</price>\n" +
"</book>\n" +
"\n" +
"</bookstore>";
}
@GetMapping(value = "/{str}")
public Object getString(@PathVariable String str) throws InterruptedException {
if (StringUtils.equals("error", str)) {

View File

@ -2,6 +2,7 @@ package io.metersphere.controller.handler;
import com.alibaba.fastjson.JSON;
import io.metersphere.controller.ResultHolder;
import io.metersphere.controller.handler.annotation.NoResultHolder;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
@ -30,6 +31,10 @@ public class ResultResponseBodyAdvice implements ResponseBodyAdvice<Object> {
return null;
}
if (methodParameter.hasMethodAnnotation(NoResultHolder.class)) {
return o;
}
if (!(o instanceof ResultHolder)) {
if (o instanceof String) {
return JSON.toJSONString(ResultHolder.success(o));

View File

@ -0,0 +1,15 @@
package io.metersphere.controller.handler.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Inherited
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface NoResultHolder {
}

View File

@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Transactional(propagation = Propagation.NOT_SUPPORTED)
@ -57,7 +58,9 @@ public class DingTaskService {
list.forEach(u -> {
phoneList.add(u.getPhone());
});
at.setAtMobiles(phoneList);
LogUtil.info("收件人地址" + phoneList);
List<String> phoneLists = phoneList.stream().distinct().collect(Collectors.toList());
at.setAtMobiles(phoneLists);
request.setAt(at);
OapiRobotSendResponse response = null;
try {

View File

@ -37,6 +37,7 @@ import javax.mail.internet.MimeMessage;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Transactional(propagation = Propagation.NOT_SUPPORTED)
@ -111,7 +112,9 @@ public class MailService {
list.forEach(u -> {
emails.add(u.getEmail());
});
users = emails.toArray(new String[0]);
List<String> email = emails.stream().distinct().collect(Collectors.toList());
users = email.toArray(new String[0]);
LogUtil.info("收件人地址" + users);
helper.setText(getContent(Template, context), true);
helper.setTo(users);
try {
@ -143,9 +146,10 @@ public class MailService {
}
public void sendCommentNotice(MessageDetail messageDetail, List<String> userIds, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs, String eventType) {
User user = userMapper.selectByPrimaryKey(testCaseWithBLOBs.getMaintainer());
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
Map<String, String> context = new HashMap<>();
context.put("maintainer", testCaseWithBLOBs.getMaintainer());
context.put("maintainer", user.getName());
context.put("testCaseName", testCaseWithBLOBs.getName());
context.put("description", request.getDescription());
context.put("url", baseSystemConfigDTO.getUrl());
@ -183,7 +187,9 @@ public class MailService {
list.forEach(u -> {
emails.add(u.getEmail());
});
users = emails.toArray(new String[0]);
List<String> email = emails.stream().distinct().collect(Collectors.toList());
users = email.toArray(new String[0]);
LogUtil.info("收件人地址" + users);
helper.setText(getContent(Template, context), true);
helper.setTo(users);
if (users.length > 0) {
@ -195,7 +201,8 @@ public class MailService {
public void sendTestPlanStartNotice(MessageDetail messageDetail, List<String> userIds, AddTestPlanRequest testPlan, String eventType) {
Map<String, String> context = getTestPlanContext(testPlan);
context.put("creator", testPlan.getCreator());
User user = userMapper.selectByPrimaryKey(testPlan.getCreator());
context.put("creator", user.getName());
try {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanStart.html"), StandardCharsets.UTF_8);
sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
@ -205,8 +212,9 @@ public class MailService {
}
public void sendTestPlanEndNotice(MessageDetail messageDetail, List<String> userIds, AddTestPlanRequest testPlan, String eventType) {
User user = userMapper.selectByPrimaryKey(testPlan.getCreator());
Map<String, String> context = getTestPlanContext(testPlan);
context.put("creator", userIds.toString());
context.put("creator", user.getName());
try {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanEnd.html"), StandardCharsets.UTF_8);
sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
@ -216,8 +224,9 @@ public class MailService {
}
public void sendTestPlanDeleteNotice(MessageDetail messageDetail, List<String> userIds, AddTestPlanRequest testPlan, String eventType) {
User user = userMapper.selectByPrimaryKey(testPlan.getCreator());
Map<String, String> context = getTestPlanContext(testPlan);
context.put("creator", userIds.toString());
context.put("creator", user.getName());
try {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanDelete.html"), StandardCharsets.UTF_8);
sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate);
@ -241,7 +250,9 @@ public class MailService {
list.forEach(u -> {
emails.add(u.getEmail());
});
users = emails.toArray(new String[0]);
List<String> email = emails.stream().distinct().collect(Collectors.toList());
users = email.toArray(new String[0]);
LogUtil.info("收件人地址" + users);
helper.setText(getContent(Template, context), true);
helper.setTo(users);
javaMailSender.send(mimeMessage);
@ -276,7 +287,9 @@ public class MailService {
list.forEach(u -> {
emails.add(u.getEmail());
});
users = emails.toArray(new String[0]);
List<String> email = emails.stream().distinct().collect(Collectors.toList());
users = email.toArray(new String[0]);
LogUtil.info("收件人地址" + users);
helper.setText(getContent(Template, context), true);
helper.setTo(users);
javaMailSender.send(mimeMessage);
@ -381,7 +394,7 @@ public class MailService {
if (StringUtils.isNotBlank(context.get(k))) {
template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", context.get(k));
} else {
template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", "");
template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", "未设置");
}
}
}

View File

@ -5,8 +5,10 @@ import io.metersphere.base.domain.MessageTaskExample;
import io.metersphere.base.mapper.MessageTaskMapper;
import io.metersphere.base.mapper.ext.ExtMessageMapper;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.i18n.Translator;
import io.metersphere.notice.controller.request.MessageRequest;
import io.metersphere.notice.domain.MessageDetail;
import io.metersphere.notice.domain.MessageSettingDetail;
@ -49,6 +51,7 @@ public class NoticeService {
long time = System.currentTimeMillis();
String identification = UUID.randomUUID().toString();
list.getUserIds().forEach(m -> {
checkUserIdExist(m, list);
MessageTask message = new MessageTask();
message.setId(UUID.randomUUID().toString());
message.setEvent(list.getEvent());
@ -57,7 +60,7 @@ public class NoticeService {
message.setType(list.getType());
message.setWebhook(list.getWebhook());
message.setIdentification(identification);
message.setIsSet(list.getIsSet());
message.setIsSet(false);
message.setOrganizationId(orgId);
message.setTestId(list.getTestId());
message.setCreateTime(time);
@ -65,6 +68,14 @@ public class NoticeService {
});
}
private void checkUserIdExist(String userId, MessageDetail list) {
MessageTaskExample example = new MessageTaskExample();
example.createCriteria().andUserIdEqualTo(userId).andEventEqualTo(list.getEvent()).andTypeEqualTo(list.getType()).andTaskTypeEqualTo(list.getTaskType()).andWebhookEqualTo(list.getWebhook());
if (messageTaskMapper.countByExample(example) > 0) {
MSException.throwException(Translator.get("message_task_already_exists"));
}
}
public List<MessageDetail> searchMessageSchedule(String testId) {
List<MessageTask> messageTaskLists = extMessageMapper.searchMessageByTestId(testId);
List<MessageDetail> scheduleMessageTask = new ArrayList<>();
@ -116,10 +127,14 @@ public class NoticeService {
messageDetail.setUserIds(new ArrayList<String>(userIds));
MessageDetailList.add(messageDetail);
});
List<MessageDetail> jenkinsTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.JENKINS_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList());
List<MessageDetail> testCasePlanTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.TEST_PLAN_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList());
List<MessageDetail> reviewTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.REVIEW_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList());
List<MessageDetail> defectTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.DEFECT_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList());
List<MessageDetail> jenkinsTask = (MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.JENKINS_TASK)).sorted(Comparator.comparing(
MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList())).stream().distinct().collect(Collectors.toList());
List<MessageDetail> testCasePlanTask = (MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.TEST_PLAN_TASK)).sorted(Comparator.comparing(
MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList())).stream().distinct().collect(Collectors.toList());
List<MessageDetail> reviewTask = (MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.REVIEW_TASK)).sorted(Comparator.comparing(
MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList())).stream().distinct().collect(Collectors.toList());
List<MessageDetail> defectTask = (MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.DEFECT_TASK)).sorted(Comparator.comparing(
MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList())).stream().distinct().collect(Collectors.toList());
messageSettingDetail.setJenkinsTask(jenkinsTask);
messageSettingDetail.setTestCasePlanTask(testCasePlanTask);
messageSettingDetail.setReviewTask(reviewTask);

View File

@ -18,6 +18,7 @@ import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Transactional(propagation = Propagation.NOT_SUPPORTED)
@ -50,7 +51,9 @@ public class WxChatTaskService {
list.forEach(u -> {
phoneList.add(u.getPhone());
});
mentionedMobileList.addAll(phoneList);
LogUtil.info("收件人地址" + phoneList);
List<String> phoneLists = phoneList.stream().distinct().collect(Collectors.toList());
mentionedMobileList.addAll(phoneLists);
message.setMentionedMobileList(mentionedMobileList);
try {
SendResult result = WxChatbotClient.send(Webhook, message);

View File

@ -7,6 +7,7 @@ import io.metersphere.base.mapper.ext.ExtSystemParameterMapper;
import io.metersphere.commons.constants.ParamConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.EncryptUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.ldap.domain.LdapInfo;
@ -99,6 +100,7 @@ public class SystemParameterService {
try {
javaMailSender.testConnection();
} catch (MessagingException e) {
LogUtil.error(e);
MSException.throwException(Translator.get("connection_failed"));
}
}

View File

@ -318,6 +318,17 @@ public class UserService {
}
public void updateUser(User user) {
// todo 提取重复代码
if (StringUtils.isNotBlank(user.getEmail())) {
UserExample example = new UserExample();
UserExample.Criteria criteria = example.createCriteria();
criteria.andEmailEqualTo(user.getEmail());
criteria.andIdNotEqualTo(user.getId());
if (userMapper.countByExample(example) > 0) {
MSException.throwException(Translator.get("user_email_already_exists"));
}
}
user.setUpdateTime(System.currentTimeMillis());
userMapper.updateByPrimaryKeySelective(user);
// 禁用用户之后剔除在线用户
@ -424,8 +435,12 @@ public class UserService {
}
public void delOrganizationMember(String organizationId, String userId) {
List<String> resourceIds = workspaceService.getWorkspaceIdsOrgId(organizationId);
resourceIds.add(organizationId);
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andRoleIdLike("%org%").andUserIdEqualTo(userId).andSourceIdEqualTo(organizationId);
userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdIn(resourceIds);
User user = userMapper.selectByPrimaryKey(userId);
if (StringUtils.equals(organizationId, user.getLastOrganizationId())) {

View File

@ -202,6 +202,10 @@ public class WorkspaceService {
return resultWorkspaceList;
}
public List<String> getWorkspaceIdsOrgId(String orgId) {
return extWorkspaceMapper.getWorkspaceIdsByOrgId(orgId);
}
public void updateWorkspaceMember(WorkspaceMemberDTO memberDTO) {
String workspaceId = memberDTO.getWorkspaceId();
String userId = memberDTO.getId();

View File

@ -3,8 +3,10 @@ package io.metersphere.track.service;
import io.metersphere.base.domain.TestCaseComment;
import io.metersphere.base.domain.TestCaseCommentExample;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.base.domain.User;
import io.metersphere.base.mapper.TestCaseCommentMapper;
import io.metersphere.base.mapper.TestCaseMapper;
import io.metersphere.base.mapper.UserMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseCommentMapper;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.exception.MSException;
@ -48,7 +50,8 @@ public class TestCaseCommentService {
private NoticeService noticeService;
@Resource
private ExtTestCaseCommentMapper extTestCaseCommentMapper;
@Resource
private UserMapper userMapper;
public void saveComment(SaveCommentRequest request) {
TestCaseComment testCaseComment = new TestCaseComment();
@ -97,6 +100,7 @@ public class TestCaseCommentService {
}
private String getReviewContext(TestCaseComment testCaseComment, TestCaseWithBLOBs testCaseWithBLOBs) {
User user = userMapper.selectByPrimaryKey(testCaseComment.getAuthor());
Long startTime = testCaseComment.getCreateTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String start = null;
@ -105,7 +109,7 @@ public class TestCaseCommentService {
start = sdf.format(new Date(Long.parseLong(sTime)));
}
String context = "";
context = "测试评审任务通知:" + testCaseComment.getAuthor() + "" + start + "" + "'" + testCaseWithBLOBs.getName() + "'" + "添加评论:" + testCaseComment.getDescription();
context = "测试评审任务通知:" + user.getName() + "" + start + "" + "'" + testCaseWithBLOBs.getName() + "'" + "添加评论:" + testCaseComment.getDescription();
return context;
}

View File

@ -572,10 +572,14 @@ public class TestCaseReviewService {
String eTime = String.valueOf(endTime);
if (!sTime.equals("null")) {
start = sdf.format(new Date(Long.parseLong(sTime)));
} else {
start = "未设置";
}
String end = null;
if (!eTime.equals("null")) {
end = sdf.format(new Date(Long.parseLong(eTime)));
} else {
start = "未设置";
}
String context = "";
if (StringUtils.equals(NoticeConstants.CREATE, type)) {

View File

@ -141,7 +141,7 @@ public class TestPlanService {
}
}
public List<TestPlan> getTestPlanByName(String name) {
public synchronized List<TestPlan> getTestPlanByName(String name) {
TestPlanExample example = new TestPlanExample();
example.createCriteria().andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId())
.andNameEqualTo(name);
@ -547,13 +547,13 @@ public class TestPlanService {
if (!sTime.equals("null")) {
start = sdf.format(new Date(Long.parseLong(sTime)));
} else {
start = "";
start = "未设置";
}
String end = null;
if (!eTime.equals("null")) {
end = sdf.format(new Date(Long.parseLong(eTime)));
} else {
end = "";
end = "未设置";
}
String context = "";
if (StringUtils.equals(NoticeConstants.CREATE, type)) {

View File

@ -171,6 +171,7 @@ task_notification_=Timing task result notification
api_definition_url_not_repeating=The interface request address already exists
task_notification_jenkins=Jenkins Task notification
task_notification=Result notification
message_task_already_exists=Task recipient already exists

View File

@ -172,3 +172,4 @@ task_notification_=定时任务结果通知
api_definition_url_not_repeating=接口请求地址已经存在
task_notification_jenkins=jenkins任务通知
task_notification=任务通知
message_task_already_exists=任务接收人已经存在

View File

@ -173,3 +173,5 @@ task_notification_jenkins=jenkins任務通知
task_notification=任務通知
task_notification_=定時任務通知
api_definition_url_not_repeating=接口請求地址已經存在
message_task_already_exists=任務接收人已經存在

View File

@ -21,9 +21,10 @@
<pre>{{response.vars}}</pre>
</el-tab-pane>
<el-tab-pane v-if="activeName == 'body' && !isSqlType" :disabled="true" name="mode" class="pane assertions">
<el-tab-pane v-if="activeName == 'body'" :disabled="true" name="mode" class="pane assertions">
<template v-slot:label>
<ms-dropdown :commands="modes" :default-command="mode" @command="modeChange"/>
<ms-dropdown v-if="!isSqlType" :commands="modes" :default-command="mode" @command="modeChange"/>
<ms-dropdown v-if="isSqlType" :commands="sqlModes" :default-command="mode" @command="sqlModeChange"/>
</template>
</el-tab-pane>
@ -33,13 +34,13 @@
</template>
<script>
import MsAssertionResults from "./AssertionResults";
import MsCodeEdit from "../../../common/components/MsCodeEdit";
import MsDropdown from "../../../common/components/MsDropdown";
import {BODY_FORMAT, RequestFactory, Request, SqlRequest} from "../../test/model/ScenarioModel";
import MsSqlResultTable from "./SqlResultTable";
import MsAssertionResults from "./AssertionResults";
import MsCodeEdit from "../../../common/components/MsCodeEdit";
import MsDropdown from "../../../common/components/MsDropdown";
import {BODY_FORMAT, RequestFactory, Request, SqlRequest} from "../../test/model/ScenarioModel";
import MsSqlResultTable from "./SqlResultTable";
export default {
export default {
name: "MsResponseText",
components: {
@ -59,6 +60,7 @@
isActive: true,
activeName: "body",
modes: ['text', 'json', 'xml', 'html'],
sqlModes: ['text', 'table'],
mode: BODY_FORMAT.TEXT
}
},
@ -69,6 +71,9 @@
},
modeChange(mode) {
this.mode = mode;
},
sqlModeChange(mode) {
this.mode = mode;
}
},
@ -86,7 +91,7 @@
return (this.requestType === RequestFactory.TYPES.SQL && this.response.responseCode === '200');
}
}
}
}
</script>
<style scoped>

View File

@ -1,10 +1,13 @@
<template>
<div>
<el-table
:data="tableData"
v-for="(table, index) in tables"
:key="index"
:data="table.tableData"
border
size="mini"
highlight-current-row>
<el-table-column v-for="(title, index) in titles" :key="index" :label="title" min-width="15%">
<el-table-column v-for="(title, index) in table.titles" :key="index" :label="title" min-width="150px">
<template v-slot:default="scope">
<el-popover
placement="top"
@ -17,6 +20,7 @@
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
@ -24,7 +28,7 @@
name: "MsSqlResultTable",
data() {
return {
tableData: [],
tables: [],
titles: []
}
},
@ -36,29 +40,71 @@
return;
}
let rowArry = this.body.split("\n");
let title;
this.getTableData(rowArry);
if (this.tables.length > 1) {
for (let i = 0; i < this.tables.length; i++) {
if (this.tables[i].titles.length === 1 && i < this.tables.length - 1) {
this.tables[i].tableData.splice(this.tables[i].tableData.length - 1, 1);
}
}
let lastTable = this.tables[this.tables.length - 1];
if (lastTable.titles.length === 1) {
if (lastTable.tableData.length > 4) {
lastTable.tableData.splice(lastTable.tableData.length - 4, 4);
} else {
this.tables.splice(this.tables.length - 1, 1);
}
} else {
this.tables.splice(this.tables.length - 1, 1);
}
} else {
let table = this.tables[0];
table.tableData.splice(table.tableData.length - 4, 4);
}
},
methods: {
getTableData(rowArry) {
let titles;
let result = [];
for (let i = 0; i < rowArry.length; i++) {
let colArray = rowArry[i].split("\t");
if (i === 0) {
title = colArray;
titles = colArray;
} else {
if (colArray.length != titles.length) {
//
if (colArray.length === 1 && colArray[0] === '') {
this.getTableData(rowArry.slice(i + 1));
} else {
this.getTableData(rowArry.slice(i));
}
break;
} else {
let item = {};
for (let j = 0; j < colArray.length; j++) {
item[title[j]] = (colArray[j] ? colArray[j] : "");
item[titles[j]] = (colArray[j] ? colArray[j] : "");
}
result.push(item);
}
}
this.titles = title;
this.tableData = result;
this.tableData.splice(this.tableData.length - 3, 3);
}
this.tables.splice(0, 0, {
titles: titles,
tableData: result
});
}
}
}
</script>
<style scoped>
.el-table {
margin-bottom: 20px;
}
.el-table >>> .cell {
white-space: nowrap;
}

View File

@ -107,7 +107,7 @@ export default {
jsonPathList.forEach(jsonPath => {
let jsonItem = new JSONPath();
jsonItem.expression = jsonPath.json_path;
jsonItem.expect = jsonPath.json_value;
jsonItem.expect = jsonPath.regular_expression;
jsonItem.setJSONPathDescription();
this.assertions.jsonPath.push(jsonItem);
});

View File

@ -217,7 +217,7 @@
})
},
del(row) {
this.$confirm(this.$t('member.remove_member'), '', {
this.$confirm(this.$t('member.org_remove_member'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'

View File

@ -145,26 +145,26 @@ export default {
data.isReadOnly = true;
if (data.type === 'EMAIL') {
data.isReadOnly = !data.isReadOnly
data.webhook = ""
data.webhook = '';
}
},
handleEditTask(index,data) {
data.isSet = true
if (data.type === 'EMAIL') {
data.isReadOnly = false
data.webhook = ""
data.isReadOnly = false;
data.webhook = '';
} else {
data.isReadOnly = true
data.isReadOnly = true;
}
},
handleAddTaskModel(type) {
let Task = {};
Task.event = [];
Task.userIds = [];
Task.type = "";
Task.webhook = "";
Task.type = '';
Task.webhook = '';
Task.isSet = true;
Task.identification = "";
Task.identification = '';
if (type === 'jenkinsTask') {
Task.taskType = 'JENKINS_TASK'
this.form.jenkinsTask.push(Task)

View File

@ -146,18 +146,18 @@ export default {
handleEdit(index, data) {
data.isReadOnly = true;
if (data.type === 'EMAIL') {
data.isReadOnly = !data.isReadOnly
data.webhook = ""
data.isReadOnly = !data.isReadOnly;
data.webhook = '';
}
},
handleAddTaskModel(type) {
let Task = {};
Task.event = [];
Task.userIds = [];
Task.type = "";
Task.webhook = "";
Task.type = '';
Task.webhook = '';
Task.isSet = true;
Task.identification = "";
Task.identification = '';
if (type === 'jenkinsTask') {
Task.taskType = 'JENKINS_TASK'
this.form.jenkinsTask.push(Task)
@ -194,21 +194,20 @@ export default {
handleEditTask(index,data) {
data.isSet = true
if (data.type === 'EMAIL') {
data.isReadOnly = false
data.webhook = ""
data.isReadOnly = false;
data.webhook = '';
} else {
data.isReadOnly = true
data.isReadOnly = true;
}
},
addTask(data) {
let list = []
data.isSet = false
list.push(data)
let list = [];
list.push(data);
let param = {};
param.messageDetail = list
param.messageDetail = list;
this.result = this.$post("/notice/save/message/task", param, () => {
this.initForm()
this.initForm();
this.$success(this.$t('commons.save_success'));
})
},
@ -216,7 +215,7 @@ export default {
if (!data[index].identification) {
data.splice(index, 1)
} else {
data[index].isSet = false
data[parseInt(index)].isSet = false;
}
},

View File

@ -147,32 +147,32 @@ export default {
handleEdit(index, data) {
data.isReadOnly = true;
if (data.type === 'EMAIL') {
data.isReadOnly = !data.isReadOnly
data.webhook = ""
data.isReadOnly = !data.isReadOnly;
data.webhook = '';
}
},
handleAddTaskModel(type) {
let Task = {};
Task.event = [];
Task.userIds = [];
Task.type = "";
Task.webhook = "";
Task.type = '';
Task.webhook = '';
Task.isSet = true;
Task.identification = "";
Task.identification = '';
if (type === 'scheduleTask') {
Task.taskType = 'SCHEDULE_TASK'
Task.testId=this.testId
this.form.scheduleTask.push(Task)
Task.taskType = 'SCHEDULE_TASK';
Task.testId=this.testId;
this.form.scheduleTask.push(Task);
}
},
handleEditTask(index,data) {
data.isSet = true
data.testId = this.testId
data.isSet = true;
data.testId = this.testId;
if (data.type === 'EMAIL') {
data.isReadOnly = false
data.webhook = ""
data.isReadOnly = false;
data.webhook = '';
} else {
data.isReadOnly = true
data.isReadOnly = true;
}
},
handleAddTask(index, data) {
@ -192,11 +192,11 @@ export default {
}
},
addTask(data) {
let list = []
data.isSet = false
list.push(data)
let list = [];
data.isSet = false;
list.push(data);
let param = {};
param.messageDetail = list
param.messageDetail = list;
this.result = this.$post("/notice/save/message/task", param, () => {
this.initForm()
this.$success(this.$t('commons.save_success'));
@ -206,7 +206,7 @@ export default {
if (!data[index].identification) {
data.splice(index, 1)
} else {
data[index].isSet = false
data[index].isSet = false;
}
},
deleteRowTask(index, data) { //

View File

@ -151,26 +151,26 @@ export default {
data.isReadOnly = true;
if (data.type === 'EMAIL') {
data.isReadOnly = !data.isReadOnly
data.webhook = ""
data.webhook = '';
}
},
handleEditTask(index,data) {
data.isSet = true
if (data.type === 'EMAIL') {
data.isReadOnly = false
data.webhook = ""
data.isReadOnly = false;
data.webhook = '';
} else {
data.isReadOnly = true
data.isReadOnly = true;
}
},
handleAddTaskModel(type) {
let Task = {};
Task.event = [];
Task.userIds = [];
Task.type = "";
Task.webhook = "";
Task.type = '';
Task.webhook = '';
Task.isSet = true;
Task.identification = "";
Task.identification = '';
if (type === 'jenkinsTask') {
Task.taskType = 'JENKINS_TASK'
this.form.jenkinsTask.push(Task)

View File

@ -151,27 +151,27 @@ export default {
handleEdit(index, data) {
data.isReadOnly = true;
if (data.type === 'EMAIL') {
data.isReadOnly = !data.isReadOnly
data.webhook = ""
data.isReadOnly = !data.isReadOnly;
data.webhook = '';
}
},
handleEditTask(index,data) {
data.isSet = true
data.isSet = true;
if (data.type === 'EMAIL') {
data.isReadOnly = false
data.webhook = ""
data.isReadOnly = false;
data.webhook = '';
} else {
data.isReadOnly = true
data.isReadOnly = true;
}
},
handleAddTaskModel(type) {
let Task = {};
Task.event = [];
Task.userIds = [];
Task.type = "";
Task.webhook = "";
Task.type = '';
Task.webhook = '';
Task.isSet = true;
Task.identification = "";
Task.identification = '';
if (type === 'jenkinsTask') {
Task.taskType = 'JENKINS_TASK'
this.form.jenkinsTask.push(Task)
@ -207,13 +207,13 @@ export default {
}
},
addTask(data) {
let list = []
data.isSet = false
list.push(data)
let list = [];
data.isSet = false;
list.push(data);
let param = {};
param.messageDetail = list
param.messageDetail = list;
this.result = this.$post("/notice/save/message/task", param, () => {
this.initForm()
this.initForm();
this.$success(this.$t('commons.save_success'));
})
},
@ -221,7 +221,7 @@ export default {
if (!data[index].identification) {
data.splice(index, 1)
} else {
data[index].isSet = false
data[index].isSet = false;
}
},
deleteRowTask(index, data) { //

View File

@ -58,11 +58,8 @@
<el-form-item :label="$t('test_track.plan.plan_stage')" :label-width="formLabelWidth" prop="stage">
<el-select v-model="form.stage" clearable :placeholder="$t('test_track.plan.input_plan_stage')">
<el-option :label="$t('test_track.plan.smoke_test')" value="smoke"></el-option>
<!--<el-option :label="$t('test_track.plan.functional_test')" value="functional"></el-option>-->
<!--<el-option :label="$t('test_track.plan.integration_testing')" value="integration"></el-option>-->
<el-option :label="$t('test_track.plan.system_test')" value="system"></el-option>
<el-option :label="$t('test_track.plan.regression_test')" value="regression"></el-option>
<!--<el-option :label="$t('test_track.plan.version_validation')" value="version"></el-option>-->
</el-select>
</el-form-item>
</el-col>

View File

@ -208,11 +208,9 @@ export default {
methods: {
initTableData() {
if (this.planId) {
// param.planId = this.planId;
this.condition.planId = this.planId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// param.nodeIds = this.selectNodeIds;
this.condition.nodeIds = this.selectNodeIds;
}
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {

View File

@ -293,6 +293,8 @@
this.projectId = data[0].id;
this.projectName = data[0].name;
this.search();
//
this.getProjectNode(this.projectId)
}
})
}

View File

@ -129,6 +129,10 @@ export default {
pre {
margin: 0 0;
white-space: pre-wrap;
word-wrap: break-word;
width: 100%;
line-height: 20px;
}
.comment-delete {

View File

@ -231,7 +231,6 @@
this.selectIds.add(item.id);
});
} else {
// this.selectIds.clear();
this.testReviews.forEach(item => {
if (this.selectIds.has(item.id)) {
this.selectIds.delete(item.id);

View File

@ -389,7 +389,7 @@ export default {
this.saveReport(reportId);
},
saveReport(reportId) {
// this.$post('/test/plan/case/edit', {id: this.testCase.id, reportId: reportId});
},
getComments(testCase) {
let id = '';

View File

@ -301,7 +301,6 @@ export default {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
handleEdit(testCase, index) {
// console.log(testCase)
this.isReadOnly = false;
if (!checkoutTestManagerOrTestUser()) {
this.isReadOnly = true;

View File

@ -314,6 +314,7 @@ export default {
repeat_password: 'Repeat',
inconsistent_passwords: 'The two passwords entered are inconsistent',
remove_member: 'Are you sure you want to remove this member',
org_remove_member: 'Removing the user from the organization will also remove permissions from all workspaces under the organization. Are you sure you want to remove the member ?',
input_id_or_email: 'Please enter user ID, or user Email',
no_such_user: 'Without this user information, please enter the correct user ID or user Email!',
},

View File

@ -313,6 +313,7 @@ export default {
repeat_password: '确认密码',
inconsistent_passwords: '两次输入的密码不一致',
remove_member: '确定要移除该成员吗',
org_remove_member: '将该用户从组织中移除,将同时移除该组织下所有工作空间的权限,确定要移除该成员吗?',
input_id_or_email: '请输入用户 ID, 或者 用户邮箱',
no_such_user: '无此用户信息, 请输入正确的用户 ID 或者 用户邮箱!',
},

View File

@ -313,6 +313,7 @@ export default {
repeat_password: '確認密碼',
inconsistent_passwords: '兩次輸入的密碼不壹致',
remove_member: '確定要移除該成員嗎',
org_remove_member: '將該用戶從組織中移除,將同時移除該組織下所有工作空間的權限,確定要移除該成員嗎?',
input_id_or_email: '請輸入用戶 ID, 或者 用戶郵箱',
no_such_user: '無此用戶信息, 請輸入正確的用戶 ID 或者 用戶郵箱!',
},