From 0070123bef277134e37a5468e335a91b7c6de14e Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 20 Jan 2021 13:12:09 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E7=94=A8=E4=BE=8B=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiTestCaseService.java | 9 +-- .../components/case/ApiCaseHeader.vue | 6 +- .../components/case/ApiCaseList.vue | 57 ++++++++++++++++++- 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 1d179da506..29b18207bc 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -83,7 +83,7 @@ public class ApiTestCaseService { } public List listSimple(ApiTestCaseRequest request) { - request = this.initRequest(request,true,true); + request = this.initRequest(request, true, true); List apiTestCases = extApiTestCaseMapper.listSimple(request); if (CollectionUtils.isEmpty(apiTestCases)) { @@ -95,16 +95,17 @@ public class ApiTestCaseService { /** * 初始化部分参数 + * * @param request * @param setDefultOrders * @param checkThisWeekData * @return */ private ApiTestCaseRequest initRequest(ApiTestCaseRequest request, boolean setDefultOrders, boolean checkThisWeekData) { - if(setDefultOrders){ + if (setDefultOrders) { request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); } - if(checkThisWeekData){ + if (checkThisWeekData) { if (request.isSelectThisWeedData()) { Map weekFirstTimeAndLastTime = DateUtils.getWeedFirstTimeAndLastTime(new Date()); Date weekFirstTime = weekFirstTimeAndLastTime.get("firstTime"); @@ -412,7 +413,7 @@ public class ApiTestCaseService { apiDefinitionWithBLOBs.setUpdateTime(System.currentTimeMillis()); apiTestCaseMapper.updateByExampleSelective(apiDefinitionWithBLOBs, apiDefinitionExample); } - if ((StringUtils.isNotEmpty(request.getMethod()) || StringUtils.isNotEmpty(request.getPath())) && request.getProtocol().equals(RequestType.HTTP)) { + if ((StringUtils.isNotEmpty(request.getMethod()) || StringUtils.isNotEmpty(request.getPath())) && RequestType.HTTP.equals(request.getProtocol())) { List bloBs = apiTestCaseMapper.selectByExampleWithBLOBs(apiDefinitionExample); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class); diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue index 04e0e0d32e..3e031e4357 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue @@ -56,7 +56,8 @@ @command="handleCommand" v-tester> +{{$t('api_test.definition.request.case')}} - {{$t('commons.test')}} + {{$t('api_test.automation.batch_execute')}} + {{$t('test_track.case.batch_edit_case')}} @@ -169,6 +170,9 @@ if (e === "run") { this.$emit('batchRun'); } + if (e === 'batch_edit_case') { + this.$emit('batchEditCase'); + } }, getColor(enable, method) { if (enable) { diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue index 9ae9451279..e72997102d 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue @@ -9,6 +9,7 @@ @addCase="addCase" @batchRun="batchRun" @selectAll="selectAll" + @batchEditCase="batchEditCase" :condition="condition" :priorities="priorities" :apiCaseList="apiCaseList" @@ -39,9 +40,9 @@ - + + - From 91ded7f5ba90f1a8728f5debd86b76c2cecac94d Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 20 Jan 2021 14:53:34 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):?= =?UTF-8?q?=20=E5=8F=A6=E5=AD=98=E6=96=B0=E7=94=A8=E4=BE=8B=20TAG=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/extract/MsExtractCommon.java | 2 +- .../api/service/ApiTestCaseService.java | 25 ++++++++-- .../components/case/ApiCaseList.vue | 47 ++++++++++--------- .../components/list/ApiCaseSimpleList.vue | 13 ----- 4 files changed, 47 insertions(+), 40 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractCommon.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractCommon.java index 3ac9f8a662..767a295102 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractCommon.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractCommon.java @@ -8,7 +8,7 @@ import org.apache.commons.lang3.StringUtils; @Data public class MsExtractCommon extends MsExtractType{ private String variable; - private String value; // value: ${variable} + private String value; private String expression; private String description; private boolean multipleMatching; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 29b18207bc..88fa857651 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -417,19 +417,34 @@ public class ApiTestCaseService { List bloBs = apiTestCaseMapper.selectByExampleWithBLOBs(apiDefinitionExample); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); bloBs.forEach(apiTestCase -> { MsHTTPSamplerProxy req = JSON.parseObject(apiTestCase.getRequest(), MsHTTPSamplerProxy.class); - if (StringUtils.isNotEmpty(request.getMethod())) { - req.setMethod(request.getMethod()); - } - if (StringUtils.isNotEmpty(request.getPath())) { - req.setPath(request.getPath()); + try { + JSONObject element = JSON.parseObject(apiTestCase.getRequest()); + if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) { + LinkedList elements = mapper.readValue(element.getString("hashTree"), new TypeReference>() { + }); + req.setHashTree(elements); + } + if (StringUtils.isNotEmpty(request.getMethod())) { + req.setMethod(request.getMethod()); + } + if (StringUtils.isNotEmpty(request.getPath())) { + req.setPath(request.getPath()); + } + } catch (Exception e) { + e.printStackTrace(); + LogUtil.error(e.getMessage()); } String requestStr = JSON.toJSONString(req); apiTestCase.setRequest(requestStr); batchMapper.updateByPrimaryKeySelective(apiTestCase); }); sqlSession.flushStatements(); + } } diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue index e72997102d..55cfccbcfe 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue @@ -86,7 +86,7 @@ singleLoading: false, singleRunId: "", runData: [], - batchData: [], + selectdCases: [], reportId: "", projectId: "", testCaseId: "", @@ -128,8 +128,6 @@ this.projectId = getCurrentProjectID(); if (this.createCase) { this.sysAddition(); - } else { - this.getApiTest(); } }, computed: { @@ -153,11 +151,19 @@ this.condition.projectId = this.projectId; this.condition.apiDefinitionId = this.api.id; this.$post("/api/testcase/list", this.condition, response => { - for (let index in response.data) { - let test = response.data[index]; - test.request = JSON.parse(test.request); - } this.apiCaseList = response.data; + this.apiCaseList.forEach(apiCase => { + if (apiCase.tags && apiCase.tags.length > 0) { + apiCase.tags = JSON.parse(apiCase.tags); + this.$set(apiCase, 'selected', false); + } + if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() != 'object') { + apiCase.request = JSON.parse(apiCase.request); + } + if (!apiCase.request.hashTree) { + apiCase.request.hashTree = []; + } + }) this.addCase(); }); }, @@ -200,24 +206,22 @@ this.condition.apiDefinitionId = this.api.id; } this.result = this.$post("/api/testcase/list", this.condition, response => { - for (let index in response.data) { - let test = response.data[index]; - test.request = JSON.parse(test.request); - if (!test.request.hashTree) { - test.request.hashTree = []; - } - } this.apiCaseList = response.data; - if (addCase && this.apiCaseList.length == 0 && !this.loaded) { - this.addCase(); - } this.apiCaseList.forEach(apiCase => { if (apiCase.tags && apiCase.tags.length > 0) { apiCase.tags = JSON.parse(apiCase.tags); this.$set(apiCase, 'selected', false); } + if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() != 'object') { + apiCase.request = JSON.parse(apiCase.request); + } + if (!apiCase.request.hashTree) { + apiCase.request.hashTree = []; + } }) - + if (addCase && this.apiCaseList.length == 0 && !this.loaded) { + this.addCase(); + } }); } }, @@ -293,11 +297,11 @@ if (this.apiCaseList.length > 0) { this.apiCaseList.forEach(item => { if (item.selected && item.id) { - this.batchData.push(item.id); + this.selectdCases.push(item.id); } }) } - if (this.batchData.length == 0) { + if (this.selectdCases.length == 0) { this.$warning("请选择用例!"); return; } @@ -306,7 +310,7 @@ batchEdit(form) { let param = {}; param[form.type] = form.value; - param.ids = this.batchData; + param.ids = this.selectdCases; param.projectId = getCurrentProjectID(); if (this.api) { param.protocol = this.api.protocol; @@ -316,6 +320,7 @@ param = Object.assign(param, this.condition); this.$post('/api/testcase/batch/editByParam', param, () => { this.$success(this.$t('commons.save_success')); + this.selectdCases = []; this.getApiTest(); }); }, diff --git a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue index 951cb2fad4..5b72cf06d5 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue @@ -413,19 +413,6 @@ this.initTable(); }); return; - // } - // this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + apiCase.name + " ?", '', { - // confirmButtonText: this.$t('commons.confirm'), - // callback: (action) => { - // if (action === 'confirm') { - // let ids = [apiCase.id]; - // this.$post('/api/testcase/removeToGc/', ids, () => { - // this.$success(this.$t('commons.delete_success')); - // this.initTable(); - // }); - // } - // } - // }); }, setEnvironment(data) { this.environmentId = data.id; From b1fb972f990a753dc5207940b08b7944a2b1dc81 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 20 Jan 2021 15:02:15 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81groovy=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/scenario/component/Jsr233Processor.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue b/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue index f6d83926d9..2a74cf5132 100644 --- a/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue +++ b/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue @@ -18,9 +18,9 @@ - @@ -81,11 +81,12 @@ ], isCodeEditAlive: true, languages: [ - 'beanshell', "python" + 'beanshell', "python", "groovy" ], codeEditModeMap: { - beanshell: 'beanshell', - python: 'python' + beanshell: 'java', + python: 'python', + groovy: 'java' } } }, From e2eed011f756eff3726fa4bb4c67685d74d07226 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 20 Jan 2021 15:11:41 +0800 Subject: [PATCH 4/5] =?UTF-8?q?style(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E6=8E=A5=E5=8F=A3=E6=AD=A5=E9=AA=A4=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scenario/component/ComponentConfig.vue | 16 ++++++++++++---- .../scenario/component/Jsr233Processor.vue | 7 ++++--- .../api/definition/components/step/JmxStep.vue | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue index 4eee593ba1..970fbb023a 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue @@ -1,7 +1,7 @@ @@ -32,6 +32,8 @@ data() { return { title: this.$t('api_test.automation.customize_script'), + titleColor: "", + backgroundColor: "", } }, computed: { @@ -79,25 +81,31 @@ getComponent(type) { if (type === ELEMENT_TYPE.JSR223PreProcessor) { this.title = this.$t('api_test.definition.request.pre_script'); + this.titleColor = "#B8741A"; + this.backgroundColor = "#F9F1EA"; return "MsJsr233Processor"; } else if (type === ELEMENT_TYPE.JSR223PostProcessor) { this.title = this.$t('api_test.definition.request.post_script'); + this.titleColor = "#783887"; + this.backgroundColor = "#F2ECF3"; return "MsJsr233Processor"; } else { this.title = this.$t('api_test.automation.customize_script'); + this.titleColor = "#7B4D12"; + this.backgroundColor = "#F1EEE9"; return "MsJsr233Processor"; } }, remove(row, node) { - this.$emit('remove',row,node); + this.$emit('remove', row, node); }, copyRow(row, node) { - this.$emit('copyRow',row,node); + this.$emit('copyRow', row, node); }, suggestClick(node) { - this.$emit('suggestClick',node); + this.$emit('suggestClick', node); }, } } diff --git a/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue b/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue index f6d83926d9..30c27f856a 100644 --- a/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue +++ b/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue @@ -4,8 +4,8 @@ @remove="remove" :data="jsr223ProcessorData" :draggable="draggable" - color="#B8741A" - background-color="#F9F1EA" + :color="color" + :background-color="backgroundColor" :title="title"> @@ -111,7 +111,8 @@ false }, title: String, - styleType: String, + color: String, + backgroundColor: String, node: {}, }, watch: { diff --git a/frontend/src/business/components/api/definition/components/step/JmxStep.vue b/frontend/src/business/components/api/definition/components/step/JmxStep.vue index 45dca71282..dfad0f4643 100644 --- a/frontend/src/business/components/api/definition/components/step/JmxStep.vue +++ b/frontend/src/business/components/api/definition/components/step/JmxStep.vue @@ -9,10 +9,10 @@
+ :jsr223-processor="row" color="#B8741A" background-color="#F9F1EA"/> + :jsr223-processor="row" color="#783887" background-color="#F2ECF3"/>
From 758a7a5356ced1d08dca548e43c97c66cc553377 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 20 Jan 2021 15:21:54 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3=E7=94=A8=E4=BE=8B=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/ApiResponseComponent.vue | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue index ee14c107d7..8b74501e7c 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiResponseComponent.vue @@ -16,43 +16,43 @@