refactor: "" -> StringUtils.EMPTY

This commit is contained in:
liqiang-fit2cloud 2022-10-17 17:29:36 +08:00
parent abbae8bd05
commit 671f609866
22 changed files with 65 additions and 61 deletions

View File

@ -25,7 +25,7 @@ public class ErrorReportLibraryParseDTO {
String errorCodeStr = StringUtils.join(this.errorCodeList,";"); String errorCodeStr = StringUtils.join(this.errorCodeList,";");
return errorCodeStr; return errorCodeStr;
}else { }else {
return ""; return StringUtils.EMPTY;
} }
} }

View File

@ -26,13 +26,13 @@ public class JmxInfoDTO {
private List<FileMetadata> fileMetadataList; private List<FileMetadata> fileMetadataList;
public JmxInfoDTO(String name, String xml, Map<String, String> attachFiles) { public JmxInfoDTO(String name, String xml, Map<String, String> attachFiles) {
this.name = StringUtils.replace(name, "/", ""); this.name = StringUtils.replace(name, "/", StringUtils.EMPTY);
this.xml = xml; this.xml = xml;
this.attachFiles = attachFiles; this.attachFiles = attachFiles;
} }
public void setName(String name) { public void setName(String name) {
this.name = StringUtils.replace(name, "/", ""); this.name = StringUtils.replace(name, "/", StringUtils.EMPTY);
} }
public void addFileMetadataLists(List<FileMetadata> list) { public void addFileMetadataLists(List<FileMetadata> list) {

View File

@ -131,7 +131,7 @@ public class TestResult {
result.setRequestResults(formatedResult); result.setRequestResults(formatedResult);
result.getRequestResults().forEach(item -> { result.getRequestResults().forEach(item -> {
String itemAndScenarioName = ""; String itemAndScenarioName = StringUtils.EMPTY;
if (StringUtils.isNotEmpty(item.getScenario())) { if (StringUtils.isNotEmpty(item.getScenario())) {
//第1个当前场景 第all_id_names个最后一层场景 //第1个当前场景 第all_id_names个最后一层场景
List<String> all_id_names = JSON.parseObject(item.getScenario(), List.class); List<String> all_id_names = JSON.parseObject(item.getScenario(), List.class);

View File

@ -57,7 +57,7 @@ public abstract class ApiImportAbstractParser<T> implements ApiImportParser<T> {
} }
protected String getBodyType(String contentType) { protected String getBodyType(String contentType) {
String bodyType = ""; String bodyType = StringUtils.EMPTY;
if (StringUtils.isBlank(contentType)) { if (StringUtils.isBlank(contentType)) {
return bodyType; return bodyType;
} }
@ -85,7 +85,7 @@ public abstract class ApiImportAbstractParser<T> implements ApiImportParser<T> {
} }
protected void addBodyHeader(MsHTTPSamplerProxy request) { protected void addBodyHeader(MsHTTPSamplerProxy request) {
String contentType = ""; String contentType = StringUtils.EMPTY;
if (request.getBody() != null && StringUtils.isNotBlank(request.getBody().getType())) { if (request.getBody() != null && StringUtils.isNotBlank(request.getBody().getType())) {
switch (request.getBody().getType()) { switch (request.getBody().getType()) {
case Body.WWW_FROM: case Body.WWW_FROM:
@ -176,7 +176,7 @@ public abstract class ApiImportAbstractParser<T> implements ApiImportParser<T> {
} }
protected void addCookie(List<KeyValue> headers, String key, String value) { protected void addCookie(List<KeyValue> headers, String key, String value) {
addCookie(headers, key, value, "", true); addCookie(headers, key, value, StringUtils.EMPTY, true);
} }
protected void addCookie(List<KeyValue> headers, String key, String value, String description, boolean required) { protected void addCookie(List<KeyValue> headers, String key, String value, String description, boolean required) {
@ -184,17 +184,17 @@ public abstract class ApiImportAbstractParser<T> implements ApiImportParser<T> {
for (KeyValue header : headers) { for (KeyValue header : headers) {
if (StringUtils.equalsIgnoreCase("Cookie", header.getName())) { if (StringUtils.equalsIgnoreCase("Cookie", header.getName())) {
hasCookie = true; hasCookie = true;
String cookies = Optional.ofNullable(header.getValue()).orElse(""); String cookies = Optional.ofNullable(header.getValue()).orElse(StringUtils.EMPTY);
header.setValue(cookies + key + "=" + value + ";"); header.setValue(cookies + key + "=" + value + ";");
} }
} }
if (!hasCookie) { if (!hasCookie) {
addHeader(headers, "Cookie", key + "=" + value + ";", description, "", required); addHeader(headers, "Cookie", key + "=" + value + ";", description, StringUtils.EMPTY, required);
} }
} }
protected void addHeader(List<KeyValue> headers, String key, String value) { protected void addHeader(List<KeyValue> headers, String key, String value) {
addHeader(headers, key, value, "", "", true); addHeader(headers, key, value, "", StringUtils.EMPTY, true);
} }
protected void addHeader(List<KeyValue> headers, String key, String value, String description, String contentType, boolean required) { protected void addHeader(List<KeyValue> headers, String key, String value, String description, String contentType, boolean required) {

View File

@ -147,7 +147,7 @@ public abstract class HarScenarioAbstractParser<T> extends ApiImportAbstractPars
} }
private void parseHeaderParameters(HarHeader harHeader, List<KeyValue> headers) { private void parseHeaderParameters(HarHeader harHeader, List<KeyValue> headers) {
addHeader(headers, harHeader.name, harHeader.value, harHeader.comment, "", false); addHeader(headers, harHeader.name, harHeader.value, harHeader.comment, StringUtils.EMPTY, false);
} }
private void addPreScript(MsHTTPSamplerProxy request, List<PostmanEvent> event) { private void addPreScript(MsHTTPSamplerProxy request, List<PostmanEvent> event) {
@ -227,7 +227,7 @@ public abstract class HarScenarioAbstractParser<T> extends ApiImportAbstractPars
if (options != null) { if (options != null) {
JsonNode raw = options.get(PostmanRequestBodyMode.RAW.value()); JsonNode raw = options.get(PostmanRequestBodyMode.RAW.value());
if (raw != null) { if (raw != null) {
String bodyType = ""; String bodyType = StringUtils.EMPTY;
switch (raw.get("language").textValue()) { switch (raw.get("language").textValue()) {
case "json": case "json":
bodyType = Body.JSON_STR; bodyType = Body.JSON_STR;
@ -244,7 +244,7 @@ public abstract class HarScenarioAbstractParser<T> extends ApiImportAbstractPars
} }
private String getDefaultStringValue(String val) { private String getDefaultStringValue(String val) {
return StringUtils.isBlank(val) ? "" : val; return StringUtils.isBlank(val) ? StringUtils.EMPTY : val;
} }
private String getBoundaryFromContentType(String contentType) { private String getBoundaryFromContentType(String contentType) {

View File

@ -159,7 +159,7 @@ public class JmeterDocumentParser {
u += k + "=" + ScriptEngineUtils.buildFunctionCallString(v); u += k + "=" + ScriptEngineUtils.buildFunctionCallString(v);
return u; return u;
}); });
ele.setTextContent(url + ((params != null && !"?".equals(params)) ? params : "")); ele.setTextContent(url + ((params != null && !"?".equals(params)) ? params : StringUtils.EMPTY));
break; break;
case "Argument.value": case "Argument.value":
String textContent = ele.getTextContent(); String textContent = ele.getTextContent();
@ -214,7 +214,7 @@ public class JmeterDocumentParser {
if (p.contains("=")) { if (p.contains("=")) {
String[] param = p.split("="); String[] param = p.split("=");
if (param.length == 1) { if (param.length == 1) {
strUrlParas.put(param[0], ""); strUrlParas.put(param[0], StringUtils.EMPTY);
} else { } else {
String key = param[0]; String key = param[0];

View File

@ -32,8 +32,8 @@ public abstract class PostmanAbstractParserParser<T> extends ApiImportAbstractPa
} }
requestDesc.getAuth(); // todo 认证方式等待优化 requestDesc.getAuth(); // todo 认证方式等待优化
PostmanUrl url = requestDesc.getUrl(); PostmanUrl url = requestDesc.getUrl();
MsHTTPSamplerProxy request = buildRequest(requestItem.getName(), url == null ? "" : url.getRaw(), requestDesc.getMethod(), MsHTTPSamplerProxy request = buildRequest(requestItem.getName(), url == null ? StringUtils.EMPTY : url.getRaw(), requestDesc.getMethod(),
requestDesc.getBody().get("jsonSchema") == null ? "" : requestDesc.getBody().get("jsonSchema").textValue()); requestDesc.getBody().get("jsonSchema") == null ? StringUtils.EMPTY : requestDesc.getBody().get("jsonSchema").textValue());
request.setRest(parseKeyValue(requestDesc.getUrl().getVariable())); request.setRest(parseKeyValue(requestDesc.getUrl().getVariable()));
if (StringUtils.isNotBlank(request.getPath())) { if (StringUtils.isNotBlank(request.getPath())) {
String path = request.getPath().split("\\?")[0]; String path = request.getPath().split("\\?")[0];
@ -168,7 +168,7 @@ public abstract class PostmanAbstractParserParser<T> extends ApiImportAbstractPa
if (options != null) { if (options != null) {
JsonNode raw = options.get(PostmanRequestBodyMode.RAW.value()); JsonNode raw = options.get(PostmanRequestBodyMode.RAW.value());
if (raw != null) { if (raw != null) {
String bodyType = ""; String bodyType = StringUtils.EMPTY;
switch (raw.get("language").textValue()) { switch (raw.get("language").textValue()) {
case "json": case "json":
bodyType = Body.JSON_STR; bodyType = Body.JSON_STR;

View File

@ -3,6 +3,7 @@ package io.metersphere.api.tcp;
import io.metersphere.api.tcp.server.TCPServer; import io.metersphere.api.tcp.server.TCPServer;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -18,7 +19,7 @@ public class TCPPool {
private TCPPool(){} private TCPPool(){}
public static String createTcp(int port){ public static String createTcp(int port){
String returnString = ""; String returnString = StringUtils.EMPTY;
if(port > 0){ if(port > 0){
TCPServer tcpServer = null; TCPServer tcpServer = null;
if(serverSockedMap.containsKey(port)){ if(serverSockedMap.containsKey(port)){

View File

@ -207,7 +207,7 @@ public class ApiTestDefinitionDiffUtilImpl implements ApiDefinitionDiffUtil {
authColumns.forEach(item -> { authColumns.forEach(item -> {
Object value = item.getOriginalValue(); Object value = item.getOriginalValue();
item.setNewValue(value); item.setNewValue(value);
item.setOriginalValue(""); item.setOriginalValue(StringUtils.EMPTY);
}); });
diffMap.put("body_auth", JSON.toJSONString(authColumns)); diffMap.put("body_auth", JSON.toJSONString(authColumns));
} }

View File

@ -1,5 +1,7 @@
package io.metersphere.commons.utils; package io.metersphere.commons.utils;
import org.apache.commons.lang3.StringUtils;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -50,7 +52,7 @@ public class FixedCapacityUtil {
return logMessage; return logMessage;
} catch (Exception e) { } catch (Exception e) {
return ""; return StringUtils.EMPTY;
} finally { } finally {
if (isClear && FixedCapacityUtil.jmeterLogTask.containsKey(reportId)) { if (isClear && FixedCapacityUtil.jmeterLogTask.containsKey(reportId)) {
FixedCapacityUtil.jmeterLogTask.remove(reportId); FixedCapacityUtil.jmeterLogTask.remove(reportId);

View File

@ -69,7 +69,7 @@ public class HashTreeUtil {
for (String param : params) { for (String param : params) {
String value = envHeadMap.get(param); String value = envHeadMap.get(param);
if (value == null) { if (value == null) {
value = ""; value = StringUtils.EMPTY;
} }
if (returnMap.containsKey(envId)) { if (returnMap.containsKey(envId)) {
returnMap.get(envId).put(param, value); returnMap.get(envId).put(param, value);
@ -94,7 +94,7 @@ public class HashTreeUtil {
for (Object hashTreeKey : hashTree.keySet()) { for (Object hashTreeKey : hashTree.keySet()) {
HashTree itemTree = hashTree.get(hashTreeKey); HashTree itemTree = hashTree.get(hashTreeKey);
String scriptValue = ""; String scriptValue = StringUtils.EMPTY;
try { try {
if (hashTreeKey instanceof JSR223PostProcessor) { if (hashTreeKey instanceof JSR223PostProcessor) {
JSR223PostProcessor postProcessor = (JSR223PostProcessor) hashTreeKey; JSR223PostProcessor postProcessor = (JSR223PostProcessor) hashTreeKey;

View File

@ -78,7 +78,7 @@ public class JSONSchemaToDocumentUtil {
Object value = null; Object value = null;
boolean required = requiredList.contains(propertyName); boolean required = requiredList.contains(propertyName);
if (object.has(PropertyConstant.DEFAULT)) { if (object.has(PropertyConstant.DEFAULT)) {
value = object.get(PropertyConstant.DEFAULT) != null ? object.get(PropertyConstant.DEFAULT).getAsString() : ""; value = object.get(PropertyConstant.DEFAULT) != null ? object.get(PropertyConstant.DEFAULT).getAsString() : StringUtils.EMPTY;
concept.add(new DocumentElement(propertyName, propertyObjType, value, required, null)); concept.add(new DocumentElement(propertyName, propertyObjType, value, required, null));
} else if (object.has(PropertyConstant.ENUM)) { } else if (object.has(PropertyConstant.ENUM)) {
try { try {
@ -102,7 +102,7 @@ public class JSONSchemaToDocumentUtil {
} else if (propertyObjType.equals(PropertyConstant.STRING)) { } else if (propertyObjType.equals(PropertyConstant.STRING)) {
// 先设置空值 // 先设置空值
if (object.has(PropertyConstant.DEFAULT)) { if (object.has(PropertyConstant.DEFAULT)) {
value = object.get(PropertyConstant.DEFAULT) != null ? object.get(PropertyConstant.DEFAULT).getAsString() : ""; value = object.get(PropertyConstant.DEFAULT) != null ? object.get(PropertyConstant.DEFAULT).getAsString() : StringUtils.EMPTY;
} }
if (object.has(PropertyConstant.MOCK) && object.get(PropertyConstant.MOCK).getAsJsonObject() != null if (object.has(PropertyConstant.MOCK) && object.get(PropertyConstant.MOCK).getAsJsonObject() != null
&& StringUtils.isNotEmpty(object.get(PropertyConstant.MOCK).getAsJsonObject().get(PropertyConstant.MOCK).getAsString())) { && StringUtils.isNotEmpty(object.get(PropertyConstant.MOCK).getAsJsonObject().get(PropertyConstant.MOCK).getAsString())) {
@ -149,12 +149,12 @@ public class JSONSchemaToDocumentUtil {
concept.add(new DocumentElement(propertyName, propertyObjType, value, required, null)); concept.add(new DocumentElement(propertyName, propertyObjType, value, required, null));
} else if (propertyObjType.equals(PropertyConstant.ARRAY)) { } else if (propertyObjType.equals(PropertyConstant.ARRAY)) {
List<DocumentElement> elements = new LinkedList<>(); List<DocumentElement> elements = new LinkedList<>();
concept.add(new DocumentElement(propertyName, propertyObjType, "", requiredList.contains(propertyName), true, elements)); concept.add(new DocumentElement(propertyName, propertyObjType, StringUtils.EMPTY, requiredList.contains(propertyName), true, elements));
JsonArray jsonArray = object.get(PropertyConstant.ITEMS).getAsJsonArray(); JsonArray jsonArray = object.get(PropertyConstant.ITEMS).getAsJsonArray();
analyzeArray(propertyName, jsonArray, elements, requiredList); analyzeArray(propertyName, jsonArray, elements, requiredList);
} else if (propertyObjType.equals(PropertyConstant.OBJECT)) { } else if (propertyObjType.equals(PropertyConstant.OBJECT)) {
List<DocumentElement> list = new LinkedList<>(); List<DocumentElement> list = new LinkedList<>();
concept.add(new DocumentElement(propertyName, propertyObjType, "", list)); concept.add(new DocumentElement(propertyName, propertyObjType, StringUtils.EMPTY, list));
analyzeObject(object, list); analyzeObject(object, list);
} }
} }
@ -166,7 +166,7 @@ public class JSONSchemaToDocumentUtil {
if (obj.isJsonArray()) { if (obj.isJsonArray()) {
JsonArray itemsObject = obj.getAsJsonArray(); JsonArray itemsObject = obj.getAsJsonArray();
List<DocumentElement> elements = new LinkedList<>(); List<DocumentElement> elements = new LinkedList<>();
array.add(new DocumentElement(propertyName, "", "", requiredList.contains("" + i + ""), elements)); array.add(new DocumentElement(propertyName, StringUtils.EMPTY, StringUtils.EMPTY, requiredList.contains("" + i + ""), elements));
analyzeArray("", itemsObject, elements, requiredList); analyzeArray("", itemsObject, elements, requiredList);
} else if (obj.isJsonObject()) { } else if (obj.isJsonObject()) {
List<String> requiredItems = new ArrayList<>(); List<String> requiredItems = new ArrayList<>();

View File

@ -20,11 +20,11 @@ public class JSONToDocumentUtil {
Object value = array.get(i); Object value = array.get(i);
if (value instanceof JSONObject) { if (value instanceof JSONObject) {
List<DocumentElement> childrenElements = new LinkedList<>(); List<DocumentElement> childrenElements = new LinkedList<>();
children.add(new DocumentElement("", PropertyConstant.OBJECT, "", childrenElements)); children.add(new DocumentElement(StringUtils.EMPTY, PropertyConstant.OBJECT, StringUtils.EMPTY, childrenElements));
jsonDataFormatting((JSONObject) value, childrenElements); jsonDataFormatting((JSONObject) value, childrenElements);
} else if (value instanceof JSONArray) { } else if (value instanceof JSONArray) {
List<DocumentElement> childrenElements = new LinkedList<>(); List<DocumentElement> childrenElements = new LinkedList<>();
DocumentElement documentElement = new DocumentElement("", PropertyConstant.ARRAY, "", childrenElements); DocumentElement documentElement = new DocumentElement(StringUtils.EMPTY, PropertyConstant.ARRAY, StringUtils.EMPTY, childrenElements);
documentElement.setArrayVerification(true); documentElement.setArrayVerification(true);
children.add(documentElement); children.add(documentElement);
jsonDataFormatting((JSONArray) value, childrenElements); jsonDataFormatting((JSONArray) value, childrenElements);
@ -33,7 +33,7 @@ public class JSONToDocumentUtil {
if (value != null) { if (value != null) {
type = DocumentUtils.getType(value); type = DocumentUtils.getType(value);
} }
children.add(new DocumentElement("", type, value, null)); children.add(new DocumentElement(StringUtils.EMPTY, type, value, null));
} }
} }
} }
@ -43,11 +43,11 @@ public class JSONToDocumentUtil {
Object value = object.get(key); Object value = object.get(key);
if (value instanceof JSONObject) { if (value instanceof JSONObject) {
List<DocumentElement> childrenElements = new LinkedList<>(); List<DocumentElement> childrenElements = new LinkedList<>();
children.add(new DocumentElement(key, PropertyConstant.OBJECT, "", childrenElements)); children.add(new DocumentElement(key, PropertyConstant.OBJECT, StringUtils.EMPTY, childrenElements));
jsonDataFormatting((JSONObject) value, childrenElements); jsonDataFormatting((JSONObject) value, childrenElements);
} else if (value instanceof JSONArray) { } else if (value instanceof JSONArray) {
List<DocumentElement> childrenElements = new LinkedList<>(); List<DocumentElement> childrenElements = new LinkedList<>();
DocumentElement documentElement = new DocumentElement(key, PropertyConstant.ARRAY, "", childrenElements); DocumentElement documentElement = new DocumentElement(key, PropertyConstant.ARRAY, StringUtils.EMPTY, childrenElements);
documentElement.setArrayVerification(true); documentElement.setArrayVerification(true);
children.add(documentElement); children.add(documentElement);
jsonDataFormatting((JSONArray) value, childrenElements); jsonDataFormatting((JSONArray) value, childrenElements);

View File

@ -339,7 +339,7 @@ public class JmeterDocumentParser implements EngineSourceParser {
collectionProp.addAttribute("name", "Asserion.test_strings"); collectionProp.addAttribute("name", "Asserion.test_strings");
// //
appendStringProp(item, "Assertion.custom_message", ""); appendStringProp(item, "Assertion.custom_message", StringUtils.EMPTY);
appendStringProp(item, "Assertion.test_field", "Assertion.response_code"); appendStringProp(item, "Assertion.test_field", "Assertion.response_code");
appendBoolProp(item, "Assertion.assume_success", true); appendBoolProp(item, "Assertion.assume_success", true);
appendIntProp(item, "Assertion.test_type", 40); appendIntProp(item, "Assertion.test_type", 40);
@ -368,7 +368,7 @@ public class JmeterDocumentParser implements EngineSourceParser {
Element collectionProp = responseAssertion.addElement(COLLECTION_PROP); Element collectionProp = responseAssertion.addElement(COLLECTION_PROP);
collectionProp.addAttribute("name", "Asserion.test_strings"); collectionProp.addAttribute("name", "Asserion.test_strings");
// //
appendStringProp(responseAssertion, "Assertion.custom_message", ""); appendStringProp(responseAssertion, "Assertion.custom_message", StringUtils.EMPTY);
appendStringProp(responseAssertion, "Assertion.test_field", "Assertion.response_code"); appendStringProp(responseAssertion, "Assertion.test_field", "Assertion.response_code");
appendBoolProp(responseAssertion, "Assertion.assume_success", true); appendBoolProp(responseAssertion, "Assertion.assume_success", true);
appendIntProp(responseAssertion, "Assertion.test_type", 40); appendIntProp(responseAssertion, "Assertion.test_type", 40);
@ -462,14 +462,14 @@ public class JmeterDocumentParser implements EngineSourceParser {
collectionProp.addAttribute("name", "Arguments.arguments"); collectionProp.addAttribute("name", "Arguments.arguments");
appendStringProp(element, "HTTPSampler.domain", ""); appendStringProp(element, "HTTPSampler.domain", StringUtils.EMPTY);
appendStringProp(element, "HTTPSampler.port", ""); appendStringProp(element, "HTTPSampler.port", StringUtils.EMPTY);
appendStringProp(element, "HTTPSampler.protocol", ""); appendStringProp(element, "HTTPSampler.protocol", StringUtils.EMPTY);
appendStringProp(element, "HTTPSampler.contentEncoding", ""); appendStringProp(element, "HTTPSampler.contentEncoding", StringUtils.EMPTY);
appendStringProp(element, "HTTPSampler.path", ""); appendStringProp(element, "HTTPSampler.path", StringUtils.EMPTY);
appendStringProp(element, "HTTPSampler.concurrentPool", "6"); appendStringProp(element, "HTTPSampler.concurrentPool", "6");
appendStringProp(element, "HTTPSampler.connect_timeout", "60000"); appendStringProp(element, "HTTPSampler.connect_timeout", "60000");
appendStringProp(element, "HTTPSampler.response_timeout", ""); appendStringProp(element, "HTTPSampler.response_timeout", StringUtils.EMPTY);
// 空的 hashTree // 空的 hashTree
hashTree.addElement(HASH_TREE_ELEMENT); hashTree.addElement(HASH_TREE_ELEMENT);
@ -878,7 +878,7 @@ public class JmeterDocumentParser implements EngineSourceParser {
appendStringProp(threadGroup, "RampUp", rampUp); appendStringProp(threadGroup, "RampUp", rampUp);
appendStringProp(threadGroup, "Steps", step); appendStringProp(threadGroup, "Steps", step);
appendStringProp(threadGroup, "Hold", hold); appendStringProp(threadGroup, "Hold", hold);
appendStringProp(threadGroup, "LogFilename", ""); appendStringProp(threadGroup, "LogFilename", StringUtils.EMPTY);
// bzm - Concurrency Thread Group "Thread Iterations Limit:" 设置为空 // bzm - Concurrency Thread Group "Thread Iterations Limit:" 设置为空
// threadGroup.appendChild(createStringProp(document, "Iterations", "1")); // threadGroup.appendChild(createStringProp(document, "Iterations", "1"));
appendStringProp(threadGroup, "Unit", "S"); appendStringProp(threadGroup, "Unit", "S");

View File

@ -37,8 +37,8 @@ public class ResultConversionUtil {
String resourceId = result.getResourceId(); String resourceId = result.getResourceId();
ApiScenarioReportResultWithBLOBs report = newScenarioReportResult(reportId, resourceId); ApiScenarioReportResultWithBLOBs report = newScenarioReportResult(reportId, resourceId);
report.setTotalAssertions(Long.parseLong(result.getTotalAssertions() + "")); report.setTotalAssertions(Long.parseLong(result.getTotalAssertions() + StringUtils.EMPTY));
report.setPassAssertions(Long.parseLong(result.getPassAssertions() + "")); report.setPassAssertions(Long.parseLong(result.getPassAssertions() + StringUtils.EMPTY));
String status = result.getError() == 0 ? ApiReportStatus.SUCCESS.name() : ApiReportStatus.ERROR.name(); String status = result.getError() == 0 ? ApiReportStatus.SUCCESS.name() : ApiReportStatus.ERROR.name();
if (CollectionUtils.isNotEmpty(errorCodeDTO.getErrorCodeList())) { if (CollectionUtils.isNotEmpty(errorCodeDTO.getErrorCodeList())) {
report.setErrorCode(errorCodeDTO.getErrorCodeStr()); report.setErrorCode(errorCodeDTO.getErrorCodeStr());

View File

@ -2,6 +2,7 @@ package io.metersphere.commons.utils;
import io.metersphere.api.dto.MsgDTO; import io.metersphere.api.dto.MsgDTO;
import io.metersphere.utils.LoggerUtil; import io.metersphere.utils.LoggerUtil;
import org.apache.commons.lang3.StringUtils;
import javax.websocket.RemoteEndpoint; import javax.websocket.RemoteEndpoint;
import javax.websocket.Session; import javax.websocket.Session;
@ -28,8 +29,8 @@ public class WebSocketUtil {
// 单用户推送 // 单用户推送
public static void sendMessageSingle(MsgDTO dto) { public static void sendMessageSingle(MsgDTO dto) {
sendMessage(ONLINE_USER_SESSIONS.get(Optional.ofNullable(dto.getReportId()).orElse("")), dto.getContent()); sendMessage(ONLINE_USER_SESSIONS.get(Optional.ofNullable(dto.getReportId()).orElse(StringUtils.EMPTY)), dto.getContent());
sendMessage(ONLINE_USER_SESSIONS.get(Optional.ofNullable(dto.getToReport()).orElse("")), dto.getContent()); sendMessage(ONLINE_USER_SESSIONS.get(Optional.ofNullable(dto.getToReport()).orElse(StringUtils.EMPTY)), dto.getContent());
} }
// 全用户推送 // 全用户推送

View File

@ -67,7 +67,7 @@ public class XMLUtil {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); buffer.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
try { try {
jsonToXmlStr(jObj, buffer, new StringBuffer("")); jsonToXmlStr(jObj, buffer, new StringBuffer(StringUtils.EMPTY));
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
} }

View File

@ -339,7 +339,7 @@ public class ExtApiScheduleService {
if (list.size() > 0) { if (list.size() > 0) {
return list.get(0).getKey(); return list.get(0).getKey();
} else { } else {
return ""; return StringUtils.EMPTY;
} }
} }

View File

@ -128,7 +128,7 @@ public class ExtProjectApplicationService {
public void checkProjectTcpPort(AddProjectRequest project) { public void checkProjectTcpPort(AddProjectRequest project) {
//判断端口是否重复 //判断端口是否重复
if (project.getMockTcpPort() != null && project.getMockTcpPort().intValue() != 0) { if (project.getMockTcpPort() != null && project.getMockTcpPort().intValue() != 0) {
String projectId = StringUtils.isEmpty(project.getId()) ? "" : project.getId(); String projectId = StringUtils.isEmpty(project.getId()) ? StringUtils.EMPTY : project.getId();
ProjectApplicationExample example = new ProjectApplicationExample(); ProjectApplicationExample example = new ProjectApplicationExample();
example.createCriteria().andTypeEqualTo(ProjectApplicationType.MOCK_TCP_PORT.name()).andTypeValueEqualTo(String.valueOf(project.getMockTcpPort())).andProjectIdNotEqualTo(projectId); example.createCriteria().andTypeEqualTo(ProjectApplicationType.MOCK_TCP_PORT.name()).andTypeValueEqualTo(String.valueOf(project.getMockTcpPort())).andProjectIdNotEqualTo(projectId);
if (projectApplicationMapper.countByExample(example) > 0) { if (projectApplicationMapper.countByExample(example) > 0) {

View File

@ -1001,7 +1001,7 @@ public class PerformanceTestService {
LoadTestFileExample example1 = new LoadTestFileExample(); LoadTestFileExample example1 = new LoadTestFileExample();
example1.createCriteria().andFileIdEqualTo(fileId); example1.createCriteria().andFileIdEqualTo(fileId);
List<LoadTestFile> loadTestFiles = loadTestFileMapper.selectByExample(example1); List<LoadTestFile> loadTestFiles = loadTestFileMapper.selectByExample(example1);
String errorMessage = ""; String errorMessage = StringUtils.EMPTY;
if (loadTestFiles.size() > 0) { if (loadTestFiles.size() > 0) {
List<String> testIds = loadTestFiles.stream().map(LoadTestFile::getTestId).distinct().collect(Collectors.toList()); List<String> testIds = loadTestFiles.stream().map(LoadTestFile::getTestId).distinct().collect(Collectors.toList());
LoadTestExample example = new LoadTestExample(); LoadTestExample example = new LoadTestExample();

View File

@ -2688,7 +2688,7 @@ public class TestCaseService {
fileContentExample.createCriteria().andFileIdIn(fileIds); fileContentExample.createCriteria().andFileIdIn(fileIds);
List<FileContent> allCaseFileContents = fileContentMapper.selectByExample(fileContentExample); List<FileContent> allCaseFileContents = fileContentMapper.selectByExample(fileContentExample);
entry.getValue().stream().forEach(relation -> { entry.getValue().stream().forEach(relation -> {
String filename = ""; String filename = StringUtils.EMPTY;
List<FileMetadata> fileMetadatas = allCaseFileMetadatas.stream().filter(fileMetadata -> fileMetadata.getId().equals(relation.getAttachmentId())) List<FileMetadata> fileMetadatas = allCaseFileMetadatas.stream().filter(fileMetadata -> fileMetadata.getId().equals(relation.getAttachmentId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<FileContent> fileContents = allCaseFileContents.stream().filter(fileContent -> fileContent.getFileId().equals(relation.getAttachmentId())) List<FileContent> fileContents = allCaseFileContents.stream().filter(fileContent -> fileContent.getFileId().equals(relation.getAttachmentId()))
@ -2699,7 +2699,7 @@ public class TestCaseService {
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata(); FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata); BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
fileAttachmentMetadata.setId(UUID.randomUUID().toString()); fileAttachmentMetadata.setId(UUID.randomUUID().toString());
fileAttachmentMetadata.setCreator(""); fileAttachmentMetadata.setCreator(StringUtils.EMPTY);
fileAttachmentMetadata.setFilePath(uploadPath); fileAttachmentMetadata.setFilePath(uploadPath);
fileAttachmentMetadataMapper.insert(fileAttachmentMetadata); fileAttachmentMetadataMapper.insert(fileAttachmentMetadata);
AttachmentModuleRelation record = new AttachmentModuleRelation(); AttachmentModuleRelation record = new AttachmentModuleRelation();
@ -3066,7 +3066,7 @@ public class TestCaseService {
return; return;
} }
if (!StringUtils.equals(demandId, "other")) { if (!StringUtils.equals(demandId, "other")) {
demandName = ""; demandName = StringUtils.EMPTY;
} }
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestCaseMapper mapper = sqlSession.getMapper(TestCaseMapper.class); TestCaseMapper mapper = sqlSession.getMapper(TestCaseMapper.class);

View File

@ -119,9 +119,9 @@ public class XmindCaseParser {
process.add(Translator.get("test_case_node_level_tip") + process.add(Translator.get("test_case_node_level_tip") +
TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level"), nodePath); TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level"), nodePath);
} }
String path = ""; String path = StringUtils.EMPTY;
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) { if (i != 0 && StringUtils.equals(nodes[i].trim(), StringUtils.EMPTY)) {
process.add(Translator.get("module_not_null"), path); process.add(Translator.get("module_not_null"), path);
} else if (nodes[i].trim().length() > 100) { } else if (nodes[i].trim().length() > 100) {
process.add(Translator.get("module") + Translator.get("test_track.length_less_than") + "100", path + nodes[i].trim()); process.add(Translator.get("module") + Translator.get("test_track.length_less_than") + "100", path + nodes[i].trim());
@ -150,7 +150,7 @@ public class XmindCaseParser {
//用例名称判断 //用例名称判断
if (StringUtils.isEmpty(data.getName())) { if (StringUtils.isEmpty(data.getName())) {
validatePass = false; validatePass = false;
process.add("name" + Translator.get("cannot_be_null"), nodePath + ""); process.add("name" + Translator.get("cannot_be_null"), nodePath + StringUtils.EMPTY);
} else { } else {
if (data.getName().length() > 200) { if (data.getName().length() > 200) {
validatePass = false; validatePass = false;
@ -170,7 +170,7 @@ public class XmindCaseParser {
} }
} }
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) { if (i != 0 && StringUtils.equals(nodes[i].trim(), StringUtils.EMPTY)) {
validatePass = false; validatePass = false;
process.add(Translator.get("test_case") + Translator.get("module_not_null"), nodePath + data.getName()); process.add(Translator.get("test_case") + Translator.get("module_not_null"), nodePath + data.getName());
if (!errorPath.contains(nodePath)) { if (!errorPath.contains(nodePath)) {
@ -315,7 +315,7 @@ public class XmindCaseParser {
} }
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
Matcher result = pattern.matcher(str); Matcher result = pattern.matcher(str);
str = result.replaceAll(""); str = result.replaceAll(StringUtils.EMPTY);
return str; return str;
} }
@ -339,8 +339,8 @@ public class XmindCaseParser {
// 保持插入顺序判断用例是否有相同的steps // 保持插入顺序判断用例是否有相同的steps
Map step = new LinkedHashMap(); Map step = new LinkedHashMap();
step.put("num", 1); step.put("num", 1);
step.put("desc", ""); step.put("desc", StringUtils.EMPTY);
step.put("result", ""); step.put("result", StringUtils.EMPTY);
jsonArray.add(step); jsonArray.add(step);
} }
return JSON.toJSONString(jsonArray); return JSON.toJSONString(jsonArray);
@ -364,7 +364,7 @@ public class XmindCaseParser {
return; return;
} }
// 用例名称 // 用例名称
String name = title.replace(tcArrs[0] + "", "").replace(tcArrs[0] + ":", ""); String name = title.replace(tcArrs[0] + "", StringUtils.EMPTY).replace(tcArrs[0] + ":", StringUtils.EMPTY);
testCase.setName(name); testCase.setName(name);
testCase.setNodePath(nodePath.trim()); testCase.setNodePath(nodePath.trim());