refactor: " " -> StringUtils.SPACE

This commit is contained in:
liqiang-fit2cloud 2022-10-17 14:52:55 +08:00
parent ef9f70a4a8
commit 8a58e449b3
29 changed files with 60 additions and 52 deletions

View File

@ -176,7 +176,7 @@ public class Document {
assertion.setExpectNull(false);
assertion.setInvert(false);
assertion.setName((StringUtils.isNotEmpty(assertionName) ? assertionName : "DocumentAssertion") + (delimiter + item.getJsonPath() + " " + getConditionStr(item, elementCondition)));
assertion.setName((StringUtils.isNotEmpty(assertionName) ? assertionName : "DocumentAssertion") + (delimiter + item.getJsonPath() + StringUtils.SPACE + getConditionStr(item, elementCondition)));
assertion.setProperty(TestElement.TEST_CLASS, JSONPathAssertion.class.getName());
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPathAssertionGui"));
assertion.setJsonPath(item.getJsonPath());
@ -195,7 +195,7 @@ public class Document {
private XMLAssertion newXMLAssertion(DocumentElement item, ElementCondition elementCondition) {
XMLAssertion assertion = new XMLAssertion();
assertion.setEnabled(true);
assertion.setName((StringUtils.isNotEmpty(assertionName) ? assertionName : "XMLAssertion") + delimiter + (item.getJsonPath() + " " + getConditionStr(item, elementCondition)));
assertion.setName((StringUtils.isNotEmpty(assertionName) ? assertionName : "XMLAssertion") + delimiter + (item.getJsonPath() + StringUtils.SPACE + getConditionStr(item, elementCondition)));
assertion.setProperty(TestElement.TEST_CLASS, XMLAssertion.class.getName());
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XMLAssertionGui"));
assertion.setProperty(PropertyConstant.XML_PATH, item.getJsonPath());

View File

@ -70,9 +70,9 @@ public class MsIfController extends MsTestElement {
public String getLabelName() {
if (isValid()) {
String label = "条件控制器:" + variable + " " + operator;
String label = "条件控制器:" + variable + StringUtils.SPACE + operator;
if (StringUtils.isNotBlank(value)) {
label += " " + this.value;
label += StringUtils.SPACE + this.value;
}
return label;
}

View File

@ -66,7 +66,7 @@ public class MsTransactionController extends MsTestElement {
public String getLabelName() {
if (isValid()) {
return NAME_CN + " " + this.name;
return NAME_CN + StringUtils.SPACE + this.name;
}
return NAME_CN;
}

View File

@ -225,8 +225,8 @@ public class MsTCPSampler extends MsTestElement {
if (!isCustomizeReq() && config != null && config.getTcpConfig() != null) {
if (!isCustomizeReq() && config != null) {
this.server = config.getTcpConfig().getServer();
this.port = config.getTcpConfig().getPort() + "";
if (StringUtils.equals(this.eolByte, " ")) {
this.port = config.getTcpConfig().getPort() + StringUtils.EMPTY;
if (StringUtils.equals(this.eolByte, StringUtils.SPACE)) {
this.eolByte = "";
} else {
if (StringUtils.isEmpty(this.eolByte)) {

View File

@ -12,6 +12,7 @@ import io.metersphere.xpack.resourcepool.engine.provider.ClientCredential;
import io.metersphere.xpack.resourcepool.engine.provider.KubernetesProvider;
import org.apache.commons.beanutils.ConstructorUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.reflections.Reflections;
import java.util.Set;
@ -55,12 +56,12 @@ public class KubernetesTestEngine extends AbstractEngine {
.append(JSON.toJSONString(pod.getMetadata())).append("");
LoggerUtil.info(logMsg);
// 拼接CURL执行命令
StringBuffer command = new StringBuffer("curl -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d").append(" ");
StringBuffer command = new StringBuffer("curl -H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST -d").append(StringUtils.SPACE);
command.append("'").append(JSON.toJSONString(runRequest)).append("'"); // 请求参数
command.append(" ").append("--connect-timeout 30"); // 设置连接超时时间为30S
command.append(" ").append("--max-time 120"); // 设置请求超时时间为120S
command.append(" ").append("--retry 3"); // 设置重试次数3次
command.append(" ").append("http://127.0.0.1:8082/jmeter/api/start");
command.append(StringUtils.SPACE).append("--connect-timeout 30"); // 设置连接超时时间为30S
command.append(StringUtils.SPACE).append("--max-time 120"); // 设置请求超时时间为120S
command.append(StringUtils.SPACE).append("--retry 3"); // 设置重试次数3次
command.append(StringUtils.SPACE).append("http://127.0.0.1:8082/jmeter/api/start");
KubernetesApiExec.newExecWatch(client, clientCredential.getNamespace(), pod.getMetadata().getName(), command.toString());
} catch (Exception e) {
LoggerUtil.error("当前报告:【" + runRequest.getReportId() + "】资源:【" + runRequest.getTestId() + "】CURL失败", e);

View File

@ -6,6 +6,7 @@ import ch.qos.logback.core.UnsynchronizedAppenderBase;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.FixedCapacityUtil;
import org.apache.commons.lang3.StringUtils;
public class JMeterLoggerAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
@Override
@ -13,9 +14,9 @@ public class JMeterLoggerAppender extends UnsynchronizedAppenderBase<ILoggingEve
try {
if (!event.getLevel().levelStr.equals(LogUtil.DEBUG)) {
StringBuffer message = new StringBuffer();
message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(" ")
.append(event.getLevel()).append(" ")
.append(event.getThreadName()).append(" ")
message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(StringUtils.SPACE)
.append(event.getLevel()).append(StringUtils.SPACE)
.append(event.getThreadName()).append(StringUtils.SPACE)
.append(event.getFormattedMessage()).append("\n");
if (event.getThrowableProxy() != null) {

View File

@ -50,8 +50,8 @@ public class Swagger2Parser extends SwaggerAbstractParser {
} else {
sourceStr = getApiTestStr(source); // 导入的二进制文件转换为 String
JSONObject jsonObject = JSONUtil.parseObject(sourceStr);
if (jsonObject.opt("swagger") == null || jsonObject.opt("swagger") == "null" || jsonObject.opt("swagger") == " ") {
if (jsonObject.opt("openapi") == null || jsonObject.opt("openapi") == "null" || jsonObject.opt("openapi") == " ") {
if (jsonObject.opt("swagger") == null || jsonObject.opt("swagger") == "null" || jsonObject.opt("swagger") == StringUtils.SPACE) {
if (jsonObject.opt("openapi") == null || jsonObject.opt("openapi") == "null" || jsonObject.opt("openapi") == StringUtils.SPACE) {
MSException.throwException("wrong format");
}
}

View File

@ -21,6 +21,8 @@
package io.metersphere.api.parse.api.har.model;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
public class HarRequest {
@ -47,7 +49,7 @@ public class HarRequest {
@Override
public String toString() {
return this.method + " " + this.url + " " + this.httpVersion;
return this.method + StringUtils.SPACE + this.url + StringUtils.SPACE + this.httpVersion;
}
}

View File

@ -104,7 +104,7 @@ public class XMLUtil {
pattern = Pattern.compile(rgex);
m = pattern.matcher(xml);
xml = m.replaceAll(" </");
return Arrays.asList(xml.split(" "));
return Arrays.asList(xml.split(StringUtils.SPACE));
}
// 传入预处理的列表返回转换成功的 json 对象

View File

@ -1008,7 +1008,7 @@ public class ApiTestCaseService {
if (nameListStr.length() > 1) {
nameListStr = nameListStr.substring(0, nameListStr.length() - 1) + "]";
}
String msg = deleteCaseName + " " + Translator.get("delete_check_reference_by") + ": " + nameListStr + " ";
String msg = deleteCaseName + StringUtils.SPACE + Translator.get("delete_check_reference_by") + ": " + nameListStr + StringUtils.SPACE;
checkMsgList.add(msg);
}
}

View File

@ -568,7 +568,7 @@ public class ApiScenarioService {
}
List<ApiScenarioWithBLOBs> apiScenarioWithBLOBs = extApiScenarioMapper.listWithRefIds(ids);
List<String> scenarioIds = apiScenarioWithBLOBs.stream().map(ApiScenarioWithBLOBs::getId).collect(Collectors.toList());
Map<String, String> scenarioIdDefinitionMap = apiScenarioWithBLOBs.stream().collect(Collectors.toMap(ApiScenarioWithBLOBs::getId, scenario -> scenario.getScenarioDefinition() == null ? " " : scenario.getScenarioDefinition()));
Map<String, String> scenarioIdDefinitionMap = apiScenarioWithBLOBs.stream().collect(Collectors.toMap(ApiScenarioWithBLOBs::getId, scenario -> scenario.getScenarioDefinition() == null ? StringUtils.SPACE : scenario.getScenarioDefinition()));
preDelAndResource(scenarioIdDefinitionMap);
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
@ -1941,14 +1941,14 @@ public class ApiScenarioService {
List<String> scenarioNames = extApiScenarioMapper.selectNameByIdIn(scenarioIdList);
if (StringUtils.isNotEmpty(deleteScenarioName) && CollectionUtils.isNotEmpty(scenarioNames)) {
String nameListStr = " ";
String nameListStr = StringUtils.SPACE;
for (String name : scenarioNames) {
nameListStr += name + ",";
}
if (nameListStr.length() > 1) {
nameListStr = nameListStr.substring(0, nameListStr.length() - 1) + " ";
nameListStr = nameListStr.substring(0, nameListStr.length() - 1) + StringUtils.SPACE;
}
String msg = deleteScenarioName + " " + Translator.get("delete_check_reference_by") + ": " + nameListStr + " ";
String msg = deleteScenarioName + StringUtils.SPACE + Translator.get("delete_check_reference_by") + ": " + nameListStr + StringUtils.SPACE;
checkMsgList.add(msg);
}
}

View File

@ -269,12 +269,12 @@ public class LdapService {
String mapAttr = (String) jsonObject.get(attr);
if (StringUtils.isBlank(mapAttr)) {
MSException.throwException(Translator.get("check_ldap_mapping") + " " + attr);
MSException.throwException(Translator.get("check_ldap_mapping") + StringUtils.SPACE + attr);
}
String result = dirContext.getStringAttribute(mapAttr);
if (StringUtils.isBlank(result)) {
MSException.throwException(Translator.get("ldap_mapping_value_null") + " " + mapAttr);
MSException.throwException(Translator.get("ldap_mapping_value_null") + StringUtils.SPACE + mapAttr);
}
return result;

View File

@ -4,6 +4,7 @@ package io.metersphere.controller.handler;
import io.metersphere.commons.utils.LogUtil;
import lombok.Builder;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
@ -49,13 +50,13 @@ public class WebLogAspect {
StringBuilder sb = new StringBuilder()
.append(h.getMethod()).append(": ")
.append(h.getUrl()).append(" ")
.append(h.getUrl()).append(StringUtils.SPACE)
.append("TIME: ")
.append((System.currentTimeMillis() - h.getStartTime())).append("ms ");
if (LogUtil.getLogger().isDebugEnabled()) {
sb.append("ARGS: ")
.append(Arrays.toString(h.getArgs())).append(" ")
.append(Arrays.toString(h.getArgs())).append(StringUtils.SPACE)
.append("RETURN: ")
.append(ret);
LogUtil.debug(sb.toString());

View File

@ -398,7 +398,7 @@ public class BaseEnvironmentService extends NodeTreeService<ApiModuleDTO> {
criteria.andIdNotEqualTo(request.getId());
}
if (apiTestEnvironmentMapper.selectByExample(example).size() > 0) {
existNames.append(" ").append(request.getName());
existNames.append(StringUtils.SPACE).append(request.getName());
continue;
}
}

View File

@ -142,7 +142,7 @@ public class CommandService {
arguments.add("-destkeypass");
arguments.add("ms123...");
LoggerUtil.info("证书合并命令:", String.join(" ", arguments));
LoggerUtil.info("证书合并命令:", String.join(StringUtils.SPACE, arguments));
SystemCommand nativeCommand = new SystemCommand(destFile.getParentFile(), (Map) null);
int exitVal = nativeCommand.run(arguments);
if (exitVal > 0) {

View File

@ -109,7 +109,7 @@ public class XMLUtils {
pattern = Pattern.compile(rgex);
m = pattern.matcher(xml);
xml = m.replaceAll(" </");
return Arrays.asList(xml.split(" "));
return Arrays.asList(xml.split(StringUtils.SPACE));
}
// 传入预处理的列表返回转换成功的 json 对象

View File

@ -50,7 +50,7 @@ public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> {
if (!StringUtils.isEmpty(errMsg)) {
ExcelErrData excelErrData = new ExcelErrData(t, rowIndex,
Translator.get("number") + " " + rowIndex + " " + Translator.get("row") + Translator.get("error")
Translator.get("number") + org.apache.commons.lang3.StringUtils.SPACE + rowIndex + org.apache.commons.lang3.StringUtils.SPACE + Translator.get("row") + Translator.get("error")
+ "" + errMsg);
errList.add(excelErrData);
} else {

View File

@ -217,12 +217,12 @@ public class LdapService {
String mapAttr = (String) jsonObject.get(attr);
if (StringUtils.isBlank(mapAttr)) {
MSException.throwException(Translator.get("check_ldap_mapping") + " " + attr);
MSException.throwException(Translator.get("check_ldap_mapping") + StringUtils.SPACE + attr);
}
String result = dirContext.getStringAttribute(mapAttr);
if (StringUtils.isBlank(result)) {
MSException.throwException(Translator.get("ldap_mapping_value_null") + " " + mapAttr);
MSException.throwException(Translator.get("ldap_mapping_value_null") + StringUtils.SPACE + mapAttr);
}
return result;

View File

@ -212,11 +212,11 @@ public class ReflexObjectUtil {
} else {
String newValue = Objects.toString(column.getNewValue().toString(), "");
if (StringUtils.isNotEmpty(newValue)) {
column.setNewValue(newValue.replaceAll("\\n", " "));
column.setNewValue(newValue.replaceAll("\\n", StringUtils.SPACE));
}
String oldValue = Objects.toString(column.getOriginalValue(), "");
String oldValue = Objects.toString(column.getOriginalValue(), StringUtils.EMPTY);
if (StringUtils.isNotEmpty(oldValue)) {
column.setOriginalValue(oldValue.replaceAll("\\n", " "));
column.setOriginalValue(oldValue.replaceAll("\\n", StringUtils.SPACE));
}
}
comparedColumns.add(column);

View File

@ -30,6 +30,8 @@ package io.metersphere.log.utils.diff.json;
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import org.apache.commons.lang3.StringUtils;
/**
* Represents a difference, as used in <code>Diff</code>. A difference consists of two pairs of starting and ending
* points, each pair representing either the "from" or the "to" collection passed to <code>Diff</code>. If an ending
@ -148,7 +150,7 @@ public class IncavaEntry {
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("del: [" + delStart + ", " + delEnd + "]");
buf.append(" ");
buf.append(StringUtils.SPACE);
buf.append("add: [" + addStart + ", " + addEnd + "]");
return buf.toString();
}

View File

@ -28,7 +28,7 @@ public class LarkNoticeSender extends AbstractNoticeSender {
.collect(Collectors.toList());
LogUtil.info("飞书收件人: {}", userIds);
context += StringUtils.join(collect, " ");
context += StringUtils.join(collect, StringUtils.SPACE);
LarkClient.send(messageDetail.getWebhook(), "消息通知: \n" + context);
}

View File

@ -221,7 +221,7 @@ public class EngineFactory {
if (!(Boolean) prop.get("enable")) {
continue;
}
dns.append(prop.get("ip")).append(" ").append(prop.get("domain")).append("\n");
dns.append(prop.get("ip")).append(StringUtils.SPACE).append(prop.get("domain")).append("\n");
}
}
}

View File

@ -6,6 +6,7 @@ import ch.qos.logback.core.UnsynchronizedAppenderBase;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.code.snippet.util.FixedCapacityUtils;
import org.apache.commons.lang3.StringUtils;
public class JMeterLoggerAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
@ -14,9 +15,9 @@ public class JMeterLoggerAppender extends UnsynchronizedAppenderBase<ILoggingEve
try {
if (!event.getLevel().levelStr.equals(LogUtil.DEBUG)) {
StringBuffer message = new StringBuffer();
message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(" ")
.append(event.getLevel()).append(" ")
.append(event.getThreadName()).append(" ")
message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(StringUtils.SPACE)
.append(event.getLevel()).append(StringUtils.SPACE)
.append(event.getThreadName()).append(StringUtils.SPACE)
.append(event.getFormattedMessage()).append("\n");
if (event.getThrowableProxy() != null) {

View File

@ -364,7 +364,7 @@ public class EnterpriseTestReportService {
previweContent = StringUtils.replace(previweContent, "class=\"hljs-right\"", "style=\"text-align: right\"");
previweContent = StringUtils.replace(previweContent, "class=\"hljs-left\"", "style=\"text-align: left\"");
if (StringUtils.contains(previweContent, "<img src=\"/resource/md/get") && StringUtils.contains(previweContent, "\" alt=\"")) {
String[] previewContentArr = StringUtils.splitByWholeSeparator(" " + previweContent, "<img src=\"/resource/md/get");
String[] previewContentArr = StringUtils.splitByWholeSeparator(StringUtils.SPACE + previweContent, "<img src=\"/resource/md/get");
if (previewContentArr.length > 1) {
for (int i = 1; i < previewContentArr.length; i++) {
String itemStr = previewContentArr[i];

View File

@ -50,7 +50,7 @@ public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> {
if (!StringUtils.isEmpty(errMsg)) {
ExcelErrData excelErrData = new ExcelErrData(t, rowIndex,
Translator.get("number") + " " + rowIndex + " " + Translator.get("row") + Translator.get("error")
Translator.get("number") + org.apache.commons.lang3.StringUtils.SPACE + rowIndex + org.apache.commons.lang3.StringUtils.SPACE + Translator.get("row") + Translator.get("error")
+ "" + errMsg);
errList.add(excelErrData);
} else {

View File

@ -202,8 +202,8 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
}
ExcelErrData excelErrData = new ExcelErrData(testCaseExcelData, rowIndex,
Translator.get("number")
.concat(" ")
.concat(String.valueOf(errorRowIndex + 1)).concat(" ")
.concat(StringUtils.SPACE)
.concat(String.valueOf(errorRowIndex + 1)).concat(StringUtils.SPACE)
.concat(Translator.get("row"))
.concat(Translator.get("error"))
.concat("")

View File

@ -2057,7 +2057,7 @@ public class TestCaseService {
caseName = caseName.append(testCase.getName()).append(",");
}
String str = caseName.substring(0, caseName.length() - 1);
MSException.throwException(Translator.get("related_case_del_fail_prefix") + " " + str + " " + Translator.get("related_case_del_fail_suffix"));
MSException.throwException(Translator.get("related_case_del_fail_prefix") + StringUtils.SPACE + str + StringUtils.SPACE + Translator.get("related_case_del_fail_suffix"));
}
}

View File

@ -119,11 +119,11 @@ public abstract class ZentaoClient extends BaseClient {
if(StringUtils.equalsIgnoreCase(getIssueResponse.getStatus(),"fail")){
GetIssueResponse.Issue issue = new GetIssueResponse.Issue();
issue.setId(id);
issue.setSteps(" ");
issue.setTitle(" ");
issue.setSteps(StringUtils.SPACE);
issue.setTitle(StringUtils.SPACE);
issue.setStatus("closed");
issue.setDeleted("1");
issue.setOpenedBy(" ");
issue.setOpenedBy(StringUtils.SPACE);
getIssueResponse.setData(JSON.toJSONString(issue).toString());
}
return JSON.parseMap(getIssueResponse.getData());

View File

@ -56,7 +56,7 @@ public abstract class AbstractCustomFieldValidator {
.replace("]", "\"]")
.replace(",", "\",\"")
.replace("", "\"\"")
.replace(" ", StringUtils.EMPTY);
.replace(StringUtils.SPACE, StringUtils.EMPTY);
}
return JSON.parseArray(value, String.class);
} catch (Exception e) {