diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index d76439cb5f..d6b73cc520 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -54,6 +54,7 @@ public class MsScenario extends MsTestElement { private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestPlan.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestPlan.java index b45f3c2bd0..c9fb3fae2b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestPlan.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestPlan.java @@ -18,6 +18,7 @@ import java.util.List; public class MsTestPlan extends MsTestElement { private String type = "TestPlan"; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { final HashTree testPlanTree = tree.add(getPlan()); if (CollectionUtils.isNotEmpty(hashTree)) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java index 1687c52f0b..980202c675 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java @@ -20,6 +20,7 @@ public class MsThreadGroup extends MsTestElement { private String type = "ThreadGroup"; private boolean enableCookieShare; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { final HashTree groupTree = tree.add(getThreadGroup()); if ((config != null && config.isEnableCookieShare()) || enableCookieShare) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java index 21fcf65837..842e0acab8 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java @@ -24,6 +24,7 @@ public class MsAssertions extends MsTestElement { private MsAssertionDuration duration; private String type = "Assertions"; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (this.isEnable()) { addAssertions(tree); @@ -79,6 +80,8 @@ public class MsAssertions extends MsTestElement { case "Response Data": assertion.setTestFieldResponseData(); break; + default: + break; } return assertion; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java index 1fa4106320..18beab89f0 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java @@ -51,6 +51,7 @@ public class MsAuthManager extends MsTestElement { @JSONField(ordinal = 28) private String environment; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java index d8158136db..6f44d3fb23 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java @@ -25,6 +25,7 @@ public class MsHeaderManager extends MsTestElement { @JSONField(ordinal = 20) private List headers; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index dd01f99994..3f351f1c25 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -24,6 +24,7 @@ public class MsIfController extends MsTestElement { private String operator; private String value; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; @@ -39,7 +40,7 @@ public class MsIfController extends MsTestElement { private IfController ifController() { IfController ifController = new IfController(); ifController.setEnabled(true); - ifController.setName(this.getLabel()); + ifController.setName(this.getLabelName()); ifController.setCondition(this.getCondition()); ifController.setProperty(TestElement.TEST_CLASS, IfController.class.getName()); ifController.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("IfControllerPanel")); @@ -55,7 +56,7 @@ public class MsIfController extends MsTestElement { return StringUtils.isNotBlank(variable) && StringUtils.isNotBlank(operator) && StringUtils.isNotBlank(value); } - public String getLabel() { + public String getLabelName() { if (isValid()) { String label = variable + " " + operator; if (StringUtils.isNotBlank(value)) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java index 7f5390287a..0f4bce52d2 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java @@ -38,14 +38,15 @@ public class MsLoopController extends MsTestElement { @JSONField(ordinal = 23) private MsWhileController whileController; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; } GenericController controller = controller(); - if (controller == null) + if (controller == null) { return; - + } final HashTree groupTree = tree.add(controller); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java index 38dea36a09..871b834286 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java @@ -24,6 +24,7 @@ import java.util.List; @JSONType(typeName = "DNSCacheManager") public class MsDNSCacheManager extends MsTestElement { + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java index 17b81206dd..9d7a0dc552 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java @@ -27,6 +27,7 @@ public class MsExtract extends MsTestElement { private List xpath; private String type = "Extract"; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java index 880b20fb13..f9cb893ac6 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java @@ -27,6 +27,7 @@ public class MsJSR223Processor extends MsTestElement { @JSONField(ordinal = 21) private String scriptLanguage; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java index 4a922577da..a473882557 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java @@ -27,7 +27,7 @@ public class MsJSR223PostProcessor extends MsTestElement { @JSONField(ordinal = 21) private String scriptLanguage; - + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java index acea42c0e1..9f76eab72b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java @@ -27,6 +27,7 @@ public class MsJSR223PreProcessor extends MsTestElement { @JSONField(ordinal = 21) private String scriptLanguage; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java index 5ed1ae4cdd..d59d5fff20 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java @@ -54,14 +54,15 @@ public class MsDubboSampler extends MsTestElement { @JSONField(ordinal = 60) private Object requestResult; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; } - if (this.getReferenced() != null && this.getReferenced().equals("Deleted")) { + if (this.getReferenced() != null && "Deleted".equals(this.getReferenced())) { return; } - if (this.getReferenced() != null && this.getReferenced().equals("REF")) { + if (this.getReferenced() != null && "REF".equals(this.getReferenced())) { this.getRefElement(this); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 0ae7c5a4b6..65d1031b47 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -31,7 +31,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; - @Data @EqualsAndHashCode(callSuper = true) @JSONType(typeName = "HTTPSamplerProxy") @@ -86,11 +85,12 @@ public class MsHTTPSamplerProxy extends MsTestElement { @JSONField(ordinal = 35) private Object requestResult; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; } - if (this.getReferenced() != null && this.getReferenced().equals("REF")) { + if (this.getReferenced() != null && "REF".equals(this.getReferenced())) { this.getRefElement(this); } HTTPSamplerProxy sampler = new HTTPSamplerProxy(); @@ -109,9 +109,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { sampler.setFollowRedirects(this.isFollowRedirects()); sampler.setUseKeepAlive(true); sampler.setDoMultipart(this.isDoMultipartPost()); - if(config != null && config.getConfig() != null){ + if (config != null && config.getConfig() != null) { config.setConfig(config.getConfig()); - }else{ + } else { config.setConfig(getEnvironmentConfig(useEnvironment)); } @@ -183,7 +183,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { if (!StringUtils.equals(this.getMethod(), "GET")) { if (this.body != null) { List bodyParams = this.body.getBodyParams(sampler, this.getId()); - if (StringUtils.isNotEmpty(this.body.getType()) && this.body.getType().equals("Form Data")) { + if (StringUtils.isNotEmpty(this.body.getType()) && "Form Data".equals(this.body.getType())) { sampler.setDoMultipart(true); } if (CollectionUtils.isNotEmpty(bodyParams)) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java index f4a97f1405..bb253cad2d 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java @@ -51,11 +51,12 @@ public class MsJDBCSampler extends MsTestElement { @JSONField(ordinal = 28) private String dataSourceId; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; } - if (this.getReferenced() != null && this.getReferenced().equals("REF")) { + if (this.getReferenced() != null && "REF".equals(this.getReferenced())) { this.getRefElement(this); } if (StringUtils.isNotEmpty(dataSourceId)) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index b545bc405e..e2209f1842 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -59,6 +59,7 @@ public class MsTCPSampler extends MsTestElement { @JSONField(ordinal = 36) private String useEnvironment; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java index 490bd87588..137dc0b3dc 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java @@ -24,6 +24,7 @@ public class MsConstantTimer extends MsTestElement { @JSONField(ordinal = 21) private String delay; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java index 4a71274612..de555a7c9f 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java @@ -40,13 +40,17 @@ public class Body { if (StringUtils.equals(type, FORM_DATA) || StringUtils.equals(type, WWW_FROM) || StringUtils.equals(type, BINARY)) { return true; - } else return false; + } else { + return false; + } } public boolean isOldKV() { if (StringUtils.equals(type, KV)) { return true; - } else return false; + } else { + return false; + } } public List getBodyParams(HTTPSamplerProxy sampler, String requestId) { @@ -63,7 +67,7 @@ public class Body { if (!this.isJson()) { sampler.setPostBodyRaw(true); } else { - if (StringUtils.isNotEmpty(this.format) && this.format.equals("JSON-SCHEMA") && this.getJsonSchema() != null) { + if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) { this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema())); } } diff --git a/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java b/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java index 925ff066c2..c8914871e7 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java @@ -40,16 +40,16 @@ public class TestResult { this.passAssertions += count; } - private static final String separator = "<->"; + private static final String SEPARATOR = "<->"; public void addScenario(ScenarioResult result) { Map> requestResultMap = new LinkedHashMap<>(); if (result != null && CollectionUtils.isNotEmpty(result.getRequestResults())) { result.getRequestResults().forEach(item -> { - if (StringUtils.isNotEmpty(item.getName()) && item.getName().indexOf(separator) != -1) { - String array[] = item.getName().split(separator); + if (StringUtils.isNotEmpty(item.getName()) && item.getName().indexOf(SEPARATOR) != -1) { + String array[] = item.getName().split(SEPARATOR); String scenarioName = array[array.length - 1]; - item.setName(item.getName().replace(separator + scenarioName, "")); + item.setName(item.getName().replace(SEPARATOR + scenarioName, "")); if (requestResultMap.containsKey(scenarioName)) { requestResultMap.get(scenarioName).add(item); } else { diff --git a/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java b/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java index 4acf7f5690..ab0fcc08fa 100644 --- a/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java @@ -157,7 +157,7 @@ public class JmeterDocumentParser { u += k + "=" + ScriptEngineUtils.calculate(v); return u; }); - ele.setTextContent(url + ((params != null && !params.equals("?")) ? params : "")); + ele.setTextContent(url + ((params != null && !"?".equals(params)) ? params : "")); break; case "Argument.value": String textContent = ele.getTextContent(); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index 89cbbeee16..d79014a1ea 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -295,7 +295,7 @@ public class ApiModuleService extends NodeTreeService { if (level > 8) { MSException.throwException(Translator.get("node_deep_limit")); } - if (rootNode.getId().equals("root")) { + if ("root".equals(rootNode.getId())) { rootPath = ""; } ApiModule apiDefinitionNode = new ApiModule(); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java index 0876613978..94a62fb6e7 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java @@ -253,7 +253,7 @@ public class ApiScenarioModuleService extends NodeTreeService 8) { MSException.throwException(Translator.get("node_deep_limit")); } - if (rootNode.getId().equals("root")) { + if ("root".equals(rootNode.getId())) { rootPath = ""; } ApiScenarioModule apiScenarioModule = new ApiScenarioModule();