Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v1.7' into v1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Somebody-JIAN committed Feb 19, 2021
2 parents 217800b + ff478c3 commit 2b9713b
Show file tree
Hide file tree
Showing 29 changed files with 660 additions and 558 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.http.control.Header;
import org.apache.jmeter.protocol.http.control.HeaderManager;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jorphan.collections.HashTree;
Expand Down Expand Up @@ -100,6 +102,9 @@ public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterCon
el.toHashTree(tree, el.getHashTree(), config);
}
}
if (CollectionUtils.isNotEmpty(this.headers)) {
setHeader(tree, this.headers);
}
}

public void setOldVariables(List<KeyValue> oldVariables) {
Expand All @@ -109,6 +114,20 @@ public void setOldVariables(List<KeyValue> oldVariables) {
}
}

public void setHeader(HashTree tree, List<KeyValue> headers) {
if (CollectionUtils.isNotEmpty(headers)) {
HeaderManager headerManager = new HeaderManager();
headerManager.setEnabled(true);
headerManager.setName(this.getName() + "场景Headers");
headerManager.setProperty(TestElement.TEST_CLASS, HeaderManager.class.getName());
headerManager.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HeaderPanel"));
headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
headerManager.add(new Header(keyValue.getName(), keyValue.getValue()))
);
tree.add(headerManager);
}
}

private Arguments arguments(ParameterConfig config) {
Arguments arguments = new Arguments();
arguments.setEnabled(true);
Expand All @@ -134,11 +153,6 @@ private Arguments arguments(ParameterConfig config) {
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
);
}
if (CollectionUtils.isNotEmpty(this.headers)) {
this.headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
);
}

return arguments;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private CounterConfig addCounterConfig() {
return counterConfig;
}

private LoopController loopController() {
private LoopController initLoopController() {
LoopController loopController = new LoopController();
loopController.setEnabled(true);
loopController.setName("LoopController");
Expand All @@ -113,7 +113,7 @@ private LoopController loopController() {
return loopController;
}

public String getCondition() {
private String getCondition() {
String variable = "\"" + this.whileController.getVariable() + "\"";
String operator = this.whileController.getOperator();
String value = "\"" + this.whileController.getValue() + "\"";
Expand All @@ -136,7 +136,7 @@ public String getCondition() {
return "${__jexl3(" + variable + operator + value + ")}";
}

private WhileController whileController() {
private WhileController initWhileController() {
String condition = getCondition();
if (StringUtils.isEmpty(condition)) {
return null;
Expand All @@ -150,7 +150,7 @@ private WhileController whileController() {
return controller;
}

private ForeachController foreachController() {
private ForeachController initForeachController() {
ForeachController controller = new ForeachController();
controller.setEnabled(true);
controller.setName("ForeachController");
Expand All @@ -175,13 +175,13 @@ private HashTree controller(HashTree tree) {
runTime.setRuntime(timeout);
// 添加超时处理,防止死循环
HashTree hashTree = tree.add(runTime);
return hashTree.add(whileController());
return hashTree.add(initWhileController());
}
if (StringUtils.equals(this.loopType, LoopConstants.FOREACH.name()) && this.forEachController != null) {
return tree.add(foreachController());
return tree.add(initForeachController());
}
if (StringUtils.equals(this.loopType, LoopConstants.LOOP_COUNT.name()) && this.countController != null) {
return tree.add(loopController());
return tree.add(initLoopController());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import sun.security.util.Cache;

import javax.annotation.Resource;
import java.io.*;
import java.io.File;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.metersphere.service.QuotaService;
import io.metersphere.service.UserService;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
Expand All @@ -38,11 +39,10 @@
import org.aspectj.util.FileUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.*;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ public void dragNode(DragNodeRequest request) {

TestCaseNodeDTO nodeTree = request.getNodeTree();

if (nodeTree == null) {
return;
}

List<TestCaseNode> updateNodes = new ArrayList<>();

buildUpdateTestCase(nodeTree, testCases, updateNodes, "/", "0", 1);
Expand Down
15 changes: 6 additions & 9 deletions backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,22 +276,19 @@ private void formatTestCase(String title, String nodePath, List<Attached> attach
testCase.setType("functional");

String tc = title.replace(":", ":");
String[] tcArr = tc.split(":");
if (tcArr.length < 1) {
String[] tcArrs = tc.split(":");
if (tcArrs.length < 1) {
process.add(Translator.get("test_case_name") + Translator.get("incorrect_format"), title);
return;
}
// 用例名称
StringBuffer name = new StringBuffer();
for (int i = 1; i < tcArr.length; i++) {
name.append(tcArr[i]);
}
testCase.setName(name.toString());
String name = title.replace(tcArrs[0] + ":", "").replace(tcArrs[0] + ":", "");
testCase.setName(name);
testCase.setNodePath(nodePath);

// 用例等级和用例性质处理
if (tcArr[0].indexOf("-") != -1) {
for (String item : tcArr[0].split("-")) {
if (tcArrs[0].indexOf("-") != -1) {
for (String item : tcArrs[0].split("-")) {
if (isAvailable(item, TC_REGEX)) {
continue;
} else if (item.toUpperCase().startsWith("P")) {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/java/io/metersphere/xpack
Submodule xpack updated from b35af5 to 5e0b36
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ALTER TABLE schedule
MODIFY COLUMN id VARCHAR(255);
MODIFY COLUMN id VARCHAR (255);
ALTER TABLE message_task
MODIFY COLUMN id VARCHAR(255);
MODIFY COLUMN id VARCHAR (255);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ALTER TABLE schedule
MODIFY COLUMN resource_id VARCHAR(255);
MODIFY COLUMN resource_id VARCHAR (255);
ALTER TABLE message_task
MODIFY COLUMN test_id VARCHAR(255);
MODIFY COLUMN test_id VARCHAR (255);
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
</el-col>
<el-col :span="3" class="ms-col-one ms-font">
<el-link class="head" @click="showScenarioParameters">{{$t('api_test.automation.scenario_total')}}</el-link>
:{{getVariableSize()}}
:{{ getVariableSize() }}
</el-col>
<el-col :span="3" class="ms-col-one ms-font">
<el-checkbox v-model="enableCookieShare">共享cookie</el-checkbox>
Expand Down Expand Up @@ -204,37 +204,44 @@
</template>

<script>
import {API_STATUS, PRIORITY} from "../../definition/model/JsonData";
import {WORKSPACE_ID} from '@/common/js/constants';
import {Assertions, Extract, IfController, JSR223Processor, ConstantTimer, LoopController} from "../../definition/model/ApiTestModel";
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
import {ELEMENTS, ELEMENT_TYPE} from "./Setting";
import MsApiCustomize from "./ApiCustomize";
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
import MsInputTag from "./MsInputTag";
import MsRun from "./DebugRun";
import MsApiReportDetail from "../report/ApiReportDetail";
import MsVariableList from "./variable/VariableList";
import ApiImport from "../../definition/components/import/ApiImport";
import "@/common/css/material-icons.css"
import OutsideClick from "@/common/js/outside-click";
import ScenarioApiRelevance from "./api/ApiRelevance";
import ScenarioRelevance from "./api/ScenarioRelevance";
import MsComponentConfig from "./component/ComponentConfig";
import {handleCtrlSEvent} from "../../../../../common/js/utils";
import {API_STATUS, PRIORITY} from "../../definition/model/JsonData";
import {WORKSPACE_ID} from '@/common/js/constants';
import {
Assertions,
ConstantTimer,
Extract,
IfController,
JSR223Processor,
LoopController
} from "../../definition/model/ApiTestModel";
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
import {ELEMENT_TYPE, ELEMENTS} from "./Setting";
import MsApiCustomize from "./ApiCustomize";
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
import MsInputTag from "./MsInputTag";
import MsRun from "./DebugRun";
import MsApiReportDetail from "../report/ApiReportDetail";
import MsVariableList from "./variable/VariableList";
import ApiImport from "../../definition/components/import/ApiImport";
import "@/common/css/material-icons.css"
import OutsideClick from "@/common/js/outside-click";
import ScenarioApiRelevance from "./api/ApiRelevance";
import ScenarioRelevance from "./api/ScenarioRelevance";
import MsComponentConfig from "./component/ComponentConfig";
import {handleCtrlSEvent} from "../../../../../common/js/utils";
export default {
name: "EditApiScenario",
props: {
moduleOptions: Array,
currentScenario: {},
},
components: {
MsVariableList,
ScenarioRelevance,
ScenarioApiRelevance,
ApiEnvironmentConfig,
export default {
name: "EditApiScenario",
props: {
moduleOptions: Array,
currentScenario: {},
},
components: {
MsVariableList,
ScenarioRelevance,
ScenarioApiRelevance,
ApiEnvironmentConfig,
MsApiReportDetail,
MsInputTag, MsRun,
MsApiCustomize,
Expand Down Expand Up @@ -679,9 +686,15 @@
if (valid) {
this.editScenario();
this.debugData = {
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare, headers: this.currentScenario.headers,
environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition
id: this.currentScenario.id,
name: this.currentScenario.name,
type: "scenario",
variables: this.currentScenario.variables,
referenced: 'Created',
enableCookieShare: this.enableCookieShare,
headers: this.currentScenario.headers,
environmentId: this.currentEnvironmentId,
hashTree: this.scenarioDefinition
};
this.reportId = getUUID().substring(0, 8);
}
Expand Down Expand Up @@ -912,9 +925,15 @@
this.currentScenario.modulePath = this.getPath(this.currentScenario.apiScenarioModuleId);
// 构建一个场景对象 方便引用处理
let scenario = {
id: this.currentScenario.id, enableCookieShare: this.enableCookieShare, name: this.currentScenario.name, type: "scenario",
variables: this.currentScenario.variables, headers: this.currentScenario.headers,
referenced: 'Created', environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition
id: this.currentScenario.id,
enableCookieShare: this.enableCookieShare,
name: this.currentScenario.name,
type: "scenario",
variables: this.currentScenario.variables,
headers: this.currentScenario.headers,
referenced: 'Created',
environmentId: this.currentEnvironmentId,
hashTree: this.scenarioDefinition
};
this.currentScenario.scenarioDefinition = scenario;
if (this.currentScenario.tags instanceof Array) {
Expand Down Expand Up @@ -1084,6 +1103,7 @@
content: "\e722";
font-size: 20px;
}
.ms-sc-variable-header >>> .el-dialog__body {
padding: 0px 20px;
}
Expand Down
Loading

0 comments on commit 2b9713b

Please sign in to comment.