From 75e70435d7ea76295f9f066ddf43acdbd2bef456 Mon Sep 17 00:00:00 2001 From: liqiang-fit2cloud Date: Mon, 17 Oct 2022 18:24:28 +0800 Subject: [PATCH] refactor: "" -> StringUtils.EMPTY --- .../api/parse/ApiImportAbstractParser.java | 2 +- .../utils/ApiTestDefinitionDiffUtilImpl.java | 2 +- .../commons/utils/JSONSchemaToDocumentUtil.java | 6 +++--- .../controller/home/ApiHomeController.java | 4 ++-- .../ApiDefinitionExecResultService.java | 6 +++--- .../service/definition/ApiDefinitionService.java | 16 ++++++++-------- .../service/definition/ApiModuleService.java | 6 +++--- .../service/definition/ApiTestCaseService.java | 6 +++--- .../service/definition/EsbApiParamService.java | 6 +++--- .../plan/TestPlanScenarioCaseService.java | 2 +- .../scenario/ApiScenarioModuleService.java | 8 ++++---- .../ApiScenarioReportStructureService.java | 2 +- .../service/scenario/ApiScenarioService.java | 12 ++++++------ .../gateway/service/SystemParameterService.java | 2 +- .../gateway/service/UserLoginService.java | 2 +- .../src/main/java/io/metersphere/dto/Body.java | 10 +++++----- .../main/java/io/metersphere/dto/KeyValue.java | 2 +- .../service/FileRepositoryService.java | 8 ++++---- .../service/IssueTemplateService.java | 4 ++-- 19 files changed, 53 insertions(+), 53 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/ApiImportAbstractParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/ApiImportAbstractParser.java index a3d1dfa170..8d743f9d42 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/ApiImportAbstractParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/ApiImportAbstractParser.java @@ -194,7 +194,7 @@ public abstract class ApiImportAbstractParser implements ApiImportParser { } protected void addHeader(List headers, String key, String value) { - addHeader(headers, key, value, "", StringUtils.EMPTY, true); + addHeader(headers, key, value, StringUtils.EMPTY, StringUtils.EMPTY, true); } protected void addHeader(List headers, String key, String value, String description, String contentType, boolean required) { diff --git a/api-test/backend/src/main/java/io/metersphere/commons/utils/ApiTestDefinitionDiffUtilImpl.java b/api-test/backend/src/main/java/io/metersphere/commons/utils/ApiTestDefinitionDiffUtilImpl.java index d7ccf1b344..c171acfe85 100644 --- a/api-test/backend/src/main/java/io/metersphere/commons/utils/ApiTestDefinitionDiffUtilImpl.java +++ b/api-test/backend/src/main/java/io/metersphere/commons/utils/ApiTestDefinitionDiffUtilImpl.java @@ -370,7 +370,7 @@ public class ApiTestDefinitionDiffUtilImpl implements ApiDefinitionDiffUtil { OperatingLogDetails detailsOld = new OperatingLogDetails(); detailsOld.setColumns(columnsOld); - List diffColumns = ReflexObjectUtil.compared(detailsOld, detailsNew, ""); + List diffColumns = ReflexObjectUtil.compared(detailsOld, detailsNew, StringUtils.EMPTY); return diffColumns; } diff --git a/api-test/backend/src/main/java/io/metersphere/commons/utils/JSONSchemaToDocumentUtil.java b/api-test/backend/src/main/java/io/metersphere/commons/utils/JSONSchemaToDocumentUtil.java index 58c0aaf023..61767feeb0 100644 --- a/api-test/backend/src/main/java/io/metersphere/commons/utils/JSONSchemaToDocumentUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/commons/utils/JSONSchemaToDocumentUtil.java @@ -166,8 +166,8 @@ public class JSONSchemaToDocumentUtil { if (obj.isJsonArray()) { JsonArray itemsObject = obj.getAsJsonArray(); List elements = new LinkedList<>(); - array.add(new DocumentElement(propertyName, StringUtils.EMPTY, StringUtils.EMPTY, requiredList.contains("" + i + ""), elements)); - analyzeArray("", itemsObject, elements, requiredList); + array.add(new DocumentElement(propertyName, StringUtils.EMPTY, StringUtils.EMPTY, requiredList.contains(StringUtils.EMPTY + i + StringUtils.EMPTY), elements)); + analyzeArray(StringUtils.EMPTY, itemsObject, elements, requiredList); } else if (obj.isJsonObject()) { List requiredItems = new ArrayList<>(); if (obj.getAsJsonObject().get(PropertyConstant.REQUIRED) != null) { @@ -179,7 +179,7 @@ public class JSONSchemaToDocumentUtil { analyzeProperty(array, String.valueOf(i), obj.getAsJsonObject(), CollectionUtils.isNotEmpty(requiredItems) ? requiredItems : requiredList); } else { JsonPrimitive primitive = (JsonPrimitive) obj; - array.add(new DocumentElement(propertyName, primitive.getAsString(), "", requiredList.contains(propertyName), null)); + array.add(new DocumentElement(propertyName, primitive.getAsString(), StringUtils.EMPTY, requiredList.contains(propertyName), null)); } } } diff --git a/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java b/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java index f802573737..ef31310c99 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java @@ -326,8 +326,8 @@ public class ApiHomeController { dataDTO.setId(selectData.getId()); dataDTO.setTestPlanDTOList(selectData.getTestPlanDTOList()); } else { - dataDTO.setCaseName(""); - dataDTO.setTestPlan(""); + dataDTO.setCaseName(StringUtils.EMPTY); + dataDTO.setTestPlan(StringUtils.EMPTY); } returnList.add(dataDTO); } diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java index 8e9b7bd2c2..e49aac4c71 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java @@ -208,8 +208,8 @@ public class ApiDefinitionExecResultService { public void editStatus(ApiDefinitionExecResult saveResult, String type, String status, Long time, String reportId, String testId) { String name = testId; - String version = ""; - String projectId = ""; + String version = StringUtils.EMPTY; + String projectId = StringUtils.EMPTY; if (StringUtils.equalsAnyIgnoreCase(type, ApiRunMode.API_PLAN.name(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name(), ApiRunMode.MANUAL_PLAN.name())) { TestPlanApiCase testPlanApiCase = testPlanApiCaseMapper.selectByPrimaryKey(testId); ApiTestCaseWithBLOBs caseWithBLOBs = null; @@ -291,7 +291,7 @@ public class ApiDefinitionExecResultService { reportResult.setUserId(String.valueOf(dto.getExtendedParameters().get("userId"))); } String status = item.isSuccess() ? ApiReportStatus.SUCCESS.name() : ApiReportStatus.ERROR.name(); - String triggerMode = ""; + String triggerMode = StringUtils.EMPTY; if (reportResult != null) { status = reportResult.getStatus(); triggerMode = reportResult.getTriggerMode(); diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java index 4a093df36f..dc1572faf1 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java @@ -215,7 +215,7 @@ public class ApiDefinitionService { resList.forEach(i -> { Project project = projectMapper.selectByPrimaryKey(i.getProjectId()); if (project == null) { - i.setProjectName(""); + i.setProjectName(StringUtils.EMPTY); i.setVersionEnable(false); } else { i.setProjectName(project.getName()); @@ -582,7 +582,7 @@ public class ApiDefinitionService { } if (StringUtils.isEmpty(moduleId)) { - moduleId = ""; + moduleId = StringUtils.EMPTY; } if (nodeMap.containsKey(moduleId)) { nodeMap.get(moduleId).add(apiDefinition); @@ -729,7 +729,7 @@ public class ApiDefinitionService { if (StringUtils.isNotEmpty(request.getTags()) && !StringUtils.equals(request.getTags(), "[]")) { test.setTags(request.getTags()); } else { - test.setTags(""); + test.setTags(StringUtils.EMPTY); } this.setModule(test); @@ -884,7 +884,7 @@ public class ApiDefinitionService { if (StringUtils.isNotEmpty(request.getTags()) && !StringUtils.equals(request.getTags(), "[]")) { test.setTags(request.getTags()); } else { - test.setTags(""); + test.setTags(StringUtils.EMPTY); } if (apiDefinitionMapper.selectByPrimaryKey(test.getId()) == null) { apiDefinitionMapper.insert(test); @@ -1016,7 +1016,7 @@ public class ApiDefinitionService { if (StringUtils.isBlank(apiTestCaseWithBLOBs.getPriority())) { apiTestCaseWithBLOBs.setPriority("P0"); } - apiTestCaseWithBLOBs.setStatus(""); + apiTestCaseWithBLOBs.setStatus(StringUtils.EMPTY); if (StringUtils.isNotBlank(apiTestCaseWithBLOBs.getId())) { BeanUtils.copyBean(apiTestCaseDTO, apiTestCaseWithBLOBs); @@ -1351,7 +1351,7 @@ public class ApiDefinitionService { } if (!StringUtils.equals(apiDefinition.getTags(), existApi.getTags())) { - if (apiDefinition.getTags() != null && Objects.equals(apiDefinition.getTags(), "") && existApi.getTags() != null && Objects.equals(existApi.getTags(), "")) { + if (apiDefinition.getTags() != null && Objects.equals(apiDefinition.getTags(), StringUtils.EMPTY) && existApi.getTags() != null && Objects.equals(existApi.getTags(), StringUtils.EMPTY)) { return true; } } @@ -1611,7 +1611,7 @@ public class ApiDefinitionService { Map paramMap = new HashMap<>(); paramMap.put("url", request.getSwaggerUrl()); NoticeModel noticeModel = NoticeModel.builder().operator(project.getCreateUser()).context(context).testId(scheduleId).subject(Translator.get("swagger_url_scheduled_import_notification")).paramMap(paramMap).event(NoticeConstants.Event.EXECUTE_SUCCESSFUL).build(); - noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel); + noticeSendService.send(NoticeConstants.Mode.SCHEDULE, StringUtils.EMPTY, noticeModel); } if (!StringUtils.equals(request.getType(), SCHEDULE) && CollectionUtils.isNotEmpty(apiImportSendNoticeDTOS)) { for (ApiImportSendNoticeDTO apiImportSendNoticeDTO : apiImportSendNoticeDTOS) { @@ -1649,7 +1649,7 @@ public class ApiDefinitionService { paramMap.put("url", request.getSwaggerUrl()); paramMap.put("projectId", request.getProjectId()); NoticeModel noticeModel = NoticeModel.builder().operator(project.getCreateUser()).context(context).testId(scheduleId).subject(Translator.get("swagger_url_scheduled_import_notification")).paramMap(paramMap).event(NoticeConstants.Event.EXECUTE_FAILED).build(); - noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel); + noticeSendService.send(NoticeConstants.Mode.SCHEDULE, StringUtils.EMPTY, noticeModel); } } diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java index 0d4cafb33d..a5eb5aa090 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java @@ -448,7 +448,7 @@ public class ApiModuleService extends NodeTreeService { MSException.throwException(Translator.get("node_deep_limit")); } if (PropertyConstant.ROOT.equals(rootNode.getId())) { - rootPath = ""; + rootPath = StringUtils.EMPTY; } ApiModule apiDefinitionNode = new ApiModule(); apiDefinitionNode.setId(rootNode.getId()); @@ -1149,7 +1149,7 @@ public class ApiModuleService extends NodeTreeService { } private void removeRepeatOrigin(List data, Boolean fullCoverage, List optionDatas) { - LinkedHashMap> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getName() + (t.getModulePath() == null ? "" : t.getModulePath()), LinkedHashMap::new, Collectors.toList())); + LinkedHashMap> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getName() + (t.getModulePath() == null ? StringUtils.EMPTY : t.getModulePath()), LinkedHashMap::new, Collectors.toList())); if (fullCoverage) { methodPathMap.forEach((k, v) -> optionDatas.add(v.get(v.size() - 1))); } else { @@ -1159,7 +1159,7 @@ public class ApiModuleService extends NodeTreeService { private void removeHttpRepeat(List data, Boolean fullCoverage, boolean urlRepeat, List optionDatas) { if (urlRepeat) { - LinkedHashMap> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getName() + t.getMethod() + t.getPath() + (t.getModulePath() == null ? "" : t.getModulePath()), LinkedHashMap::new, Collectors.toList())); + LinkedHashMap> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getName() + t.getMethod() + t.getPath() + (t.getModulePath() == null ? StringUtils.EMPTY : t.getModulePath()), LinkedHashMap::new, Collectors.toList())); if (fullCoverage) { methodPathMap.forEach((k, v) -> optionDatas.add(v.get(v.size() - 1))); } else { diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java index ff0a73905e..f60adca2a8 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java @@ -431,7 +431,7 @@ public class ApiTestCaseService { test.setVersion(request.getVersion() == null ? 0 : request.getVersion() + 1); test.setVersionId(request.getVersionId()); if (StringUtils.equals("[]", request.getTags())) { - test.setTags(""); + test.setTags(StringUtils.EMPTY); } else { test.setTags(request.getTags()); } @@ -474,7 +474,7 @@ public class ApiTestCaseService { final ApiTestCaseWithBLOBs test = new ApiTestCaseWithBLOBs(); test.setId(request.getId()); test.setName(request.getName()); - test.setStatus(""); + test.setStatus(StringUtils.EMPTY); test.setCaseStatus(request.getCaseStatus()); if (StringUtils.isEmpty(request.getCaseStatus())) { test.setCaseStatus(ApiTestDataStatus.UNDERWAY.getValue()); @@ -492,7 +492,7 @@ public class ApiTestCaseService { test.setOrder(ServiceUtils.getNextOrder(request.getProjectId(), extApiTestCaseMapper::getLastOrder)); test.setVersionId(request.getVersionId()); if (StringUtils.equals("[]", request.getTags())) { - test.setTags(""); + test.setTags(StringUtils.EMPTY); } else { test.setTags(request.getTags()); } diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/EsbApiParamService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/EsbApiParamService.java index 991a7d2599..b9bfca03a1 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/EsbApiParamService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/EsbApiParamService.java @@ -122,13 +122,13 @@ public class EsbApiParamService { returnObj = JSONUtil.parseObject(requestString); JSONArray esbDataArray = JSONUtil.parseArray(esbParamBlobs.getDataStruct()); if (esbDataArray == null) { - returnObj.put("esbDataStruct", ""); + returnObj.put("esbDataStruct", StringUtils.EMPTY); } else { returnObj.put("esbDataStruct", esbDataArray); } JSONArray responseDataArray = JSONUtil.parseArray(esbParamBlobs.getResponseDataStruct()); if (responseDataArray == null) { - returnObj.put("backEsbDataStruct", ""); + returnObj.put("backEsbDataStruct", StringUtils.EMPTY); } else { returnObj.put("backEsbDataStruct", responseDataArray); } @@ -297,7 +297,7 @@ public class EsbApiParamService { //通过报文模版中的变量参数,解析报文数据结构,生成对应的xml数据 private String genValueFromEsbDataStructByParam(List dataStructRequestList, String param) { - String returnValue = ""; + String returnValue = StringUtils.EMPTY; if (StringUtils.isNotEmpty(param)) { //多层结构使用"."来表示。aaa.bb.cc 代表的是dataStructRequestList中,aaa节点下,bb节点下的cc节点数据 String[] paramArr = param.split("\\."); diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java index 420923fe5b..be66ec90d4 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java @@ -245,7 +245,7 @@ public class TestPlanScenarioCaseService { ScenarioEnv scenarioEnv = apiAutomationService.getApiScenarioProjectId(id); list = new ArrayList<>(scenarioEnv.getProjectIds()); } - list.forEach(l -> newEnvMap.put(l, envMap == null ? "" : envMap.getOrDefault(l, ""))); + list.forEach(l -> newEnvMap.put(l, envMap == null ? StringUtils.EMPTY : envMap.getOrDefault(l, StringUtils.EMPTY))); TestPlanApiScenario testPlanApiScenario = new TestPlanApiScenario(); testPlanApiScenario.setId(UUID.randomUUID().toString()); testPlanApiScenario.setCreateUser(SessionUtils.getUserId()); diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioModuleService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioModuleService.java index 77865e45e6..49f7cd5a14 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioModuleService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioModuleService.java @@ -272,7 +272,7 @@ public class ApiScenarioModuleService extends NodeTreeService apiScenarios = queryByModuleIds(request); apiScenarios.forEach(apiScenario -> { String modulePath = apiScenario.getModulePath(); - StringBuilder path = new StringBuilder(modulePath == null ? "" : modulePath); + StringBuilder path = new StringBuilder(modulePath == null ? StringUtils.EMPTY : modulePath); List pathLists = Arrays.asList(path.toString().split("/")); if (pathLists.size() > request.getLevel()) { pathLists.set(request.getLevel(), request.getName()); @@ -380,7 +380,7 @@ public class ApiScenarioModuleService extends NodeTreeService optionData = new ArrayList<>(); //覆盖模式留重复的最后一个,不覆盖留第一个 - LinkedHashMap> nameModuleMapList = data.stream().collect(Collectors.groupingBy(t -> t.getName() + (t.getModulePath() == null ? "" : t.getModulePath()), LinkedHashMap::new, Collectors.toList())); + LinkedHashMap> nameModuleMapList = data.stream().collect(Collectors.groupingBy(t -> t.getName() + (t.getModulePath() == null ? StringUtils.EMPTY : t.getModulePath()), LinkedHashMap::new, Collectors.toList())); removeRepeatOrigin(fullCoverage, optionData, nameModuleMapList); //处理模块 @@ -550,7 +550,7 @@ public class ApiScenarioModuleService extends NodeTreeService t.getApiScenarioModuleId().equals(chooseModuleId)).collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), scenario -> scenario)); } } else { - nameModuleMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + (t.getModulePath() == null ? "" : t.getModulePath()), scenario -> scenario)); + nameModuleMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + (t.getModulePath() == null ? StringUtils.EMPTY : t.getModulePath()), scenario -> scenario)); repeatDataMap = repeatApiScenarioWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), scenario -> scenario)); } //处理数据 diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java index 0f7e0385df..150a893e34 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java @@ -216,7 +216,7 @@ public class ApiScenarioReportStructureService { children.setAllIndex(dto.getAllIndex() + "_" + (children.getIndex() == 0 ? (i + 1) : children.getIndex())); children.setResourceId(resourceId + "_" + children.getAllIndex()); } else { - children.setAllIndex("" + (children.getIndex() == 0 ? (i + 1) : children.getIndex())); + children.setAllIndex(StringUtils.EMPTY + (children.getIndex() == 0 ? (i + 1) : children.getIndex())); children.setResourceId(resourceId + "_" + children.getAllIndex()); } dto.getChildren().add(children); diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index 3113eb55b7..bb7da855a5 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -211,7 +211,7 @@ public class ApiScenarioService { if (MapUtils.isNotEmpty(request.getFilters()) && request.getFilters().containsKey(ApiTestConstants.LAST_RESULT)) { if (request.getFilters().get(ApiTestConstants.LAST_RESULT) != null && request.getFilters().get(ApiTestConstants.LAST_RESULT).contains(ApiReportStatus.PENDING.name())) { - request.getFilters().get(ApiTestConstants.LAST_RESULT).add(""); + request.getFilters().get(ApiTestConstants.LAST_RESULT).add(StringUtils.EMPTY); } if (request.getFilters().get(ApiTestConstants.LAST_RESULT) != null && request.getFilters().get(ApiTestConstants.LAST_RESULT).contains(ApiTestConstants.FAKE_ERROR)) { request.getFilters().get(ApiTestConstants.LAST_RESULT).add(ApiReportStatus.FAKE_ERROR.name()); @@ -267,7 +267,7 @@ public class ApiScenarioService { checkScenarioNum(request); final ApiScenarioWithBLOBs scenario = buildSaveScenario(request); scenario.setVersion(0); - scenario.setLastResult(""); + scenario.setLastResult(StringUtils.EMPTY); scenario.setCreateTime(System.currentTimeMillis()); scenario.setNum(nextNum); scenario.setOrder(ServiceUtils.getNextOrder(scenario.getProjectId(), extApiScenarioMapper::getLastOrder)); @@ -447,7 +447,7 @@ public class ApiScenarioService { scenario.setProjectId(request.getProjectId()); scenario.setCustomNum(request.getCustomNum()); if (StringUtils.equals(request.getTags(), "[]")) { - scenario.setTags(""); + scenario.setTags(StringUtils.EMPTY); } else { scenario.setTags(request.getTags()); } @@ -644,7 +644,7 @@ public class ApiScenarioService { checkNameExist(apiScenarioRequest, false); } if (StringUtils.isEmpty(moduleId)) { - moduleId = ""; + moduleId = StringUtils.EMPTY; } if (nodeMap.containsKey(moduleId)) { nodeMap.get(moduleId).add(api); @@ -1037,7 +1037,7 @@ public class ApiScenarioService { ScenarioToPerformanceInfoDTO returnDTO = new ScenarioToPerformanceInfoDTO(); List ids = request.getIds(); List apiScenarios = extApiScenarioMapper.selectIds(ids); - String id = ""; + String id = StringUtils.EMPTY; if (!apiScenarios.isEmpty()) { id = apiScenarios.get(0).getId(); } @@ -1239,7 +1239,7 @@ public class ApiScenarioService { scenarioWithBLOBs.setUserId(request.getUserId()); } scenarioWithBLOBs.setDescription(request.getDescription()); - scenarioWithBLOBs.setLastResult(""); + scenarioWithBLOBs.setLastResult(StringUtils.EMPTY); Boolean openCustomNum = apiTestImportRequest.getOpenCustomNum(); List list = new ArrayList<>(); diff --git a/framework/gateway/src/main/java/io/metersphere/gateway/service/SystemParameterService.java b/framework/gateway/src/main/java/io/metersphere/gateway/service/SystemParameterService.java index f4c2c79e38..6b0124a995 100644 --- a/framework/gateway/src/main/java/io/metersphere/gateway/service/SystemParameterService.java +++ b/framework/gateway/src/main/java/io/metersphere/gateway/service/SystemParameterService.java @@ -24,7 +24,7 @@ public class SystemParameterService { public String getValue(String key) { SystemParameter param = systemParameterMapper.selectByPrimaryKey(key); if (param == null || StringUtils.isBlank(param.getParamValue())) { - return ""; + return StringUtils.EMPTY; } return param.getParamValue(); } diff --git a/framework/gateway/src/main/java/io/metersphere/gateway/service/UserLoginService.java b/framework/gateway/src/main/java/io/metersphere/gateway/service/UserLoginService.java index 0c681ee21f..9aa42d634e 100644 --- a/framework/gateway/src/main/java/io/metersphere/gateway/service/UserLoginService.java +++ b/framework/gateway/src/main/java/io/metersphere/gateway/service/UserLoginService.java @@ -233,7 +233,7 @@ public class UserLoginService { user.setLastProjectId(projects.get(0).getId()); } } else { - user.setLastProjectId(""); + user.setLastProjectId(StringUtils.EMPTY); } } // 执行变更 diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/dto/Body.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/dto/Body.java index 8b1e562fdf..023d85a253 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/dto/Body.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/dto/Body.java @@ -82,7 +82,7 @@ public class Body { } else { if (StringUtils.isNotEmpty(this.getRaw()) || this.getJsonSchema() != null) { parseJonBodyMock(); - KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true); + KeyValue keyValue = new KeyValue(StringUtils.EMPTY, "JSON-SCHEMA", this.getRaw(), true, true); sampler.setPostBodyRaw(true); keyValue.setEnable(true); keyValue.setUrlEncode(false); @@ -163,7 +163,7 @@ public class Body { if (StringUtils.isBlank(mimetype)) { mimetype = ContentType.APPLICATION_OCTET_STREAM.getMimeType(); } - list.add(new HTTPFileArg(path, isBinary ? "" : paramName, mimetype)); + list.add(new HTTPFileArg(path, isBinary ? StringUtils.EMPTY : paramName, mimetype)); }); } } @@ -181,9 +181,9 @@ public class Body { } public void init() { - this.type = ""; - this.raw = ""; - this.format = ""; + this.type = StringUtils.EMPTY; + this.raw = StringUtils.EMPTY; + this.format = StringUtils.EMPTY; } public void initKvs() { diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/dto/KeyValue.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/dto/KeyValue.java index 00cc655ab6..13b21d7606 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/dto/KeyValue.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/dto/KeyValue.java @@ -55,7 +55,7 @@ public class KeyValue { } public KeyValue(String name, String value, String description, boolean required) { - this(name, value, description, "", required); + this(name, value, description, StringUtils.EMPTY, required); } public boolean valueIsNotEmpty() { diff --git a/project-management/backend/src/main/java/io/metersphere/service/FileRepositoryService.java b/project-management/backend/src/main/java/io/metersphere/service/FileRepositoryService.java index 68d4196279..0202e52dba 100644 --- a/project-management/backend/src/main/java/io/metersphere/service/FileRepositoryService.java +++ b/project-management/backend/src/main/java/io/metersphere/service/FileRepositoryService.java @@ -141,19 +141,19 @@ public class FileRepositoryService { } else if (StringUtils.equals(fileAssociation.getType(), FileAssociationType.CASE.name())) { ApiTestCase testCase = apiCaseMap.get(fileAssociation.getSourceId()); if (testCase != null) { - caseId = testCase.getNum() == null ? "" : testCase.getNum().toString(); + caseId = testCase.getNum() == null ? StringUtils.EMPTY : testCase.getNum().toString(); caseName = testCase.getName(); } } else if (StringUtils.equals(fileAssociation.getType(), FileAssociationType.SCENARIO.name())) { ApiScenario testCase = scenarioMap.get(fileAssociation.getSourceId()); if (testCase != null) { - caseId = testCase.getNum() == null ? "" : testCase.getNum().toString(); + caseId = testCase.getNum() == null ? StringUtils.EMPTY : testCase.getNum().toString(); caseName = testCase.getName(); } } else if (StringUtils.equals(fileAssociation.getType(), "TEST_CASE")) { TestCase testCase = testCaseMap.get(fileAssociation.getSourceId()); if (testCase != null) { - caseId = testCase.getNum() == null ? "" : testCase.getNum().toString(); + caseId = testCase.getNum() == null ? StringUtils.EMPTY : testCase.getNum().toString(); caseName = testCase.getName(); } } @@ -166,7 +166,7 @@ public class FileRepositoryService { for (LoadTestFileDTO loadTestFile : loadTestFileList) { LoadTest loadTest = loadTestFile.getLoadTest(); if (loadTest != null) { - FileRelevanceCaseDTO dto = new FileRelevanceCaseDTO(loadTestFile.getFileId(), loadTest.getNum() + "", loadTest.getName(), "LOAD_CASE" + FileRelevanceCaseDTO dto = new FileRelevanceCaseDTO(loadTestFile.getFileId(), loadTest.getNum() + StringUtils.EMPTY, loadTest.getName(), "LOAD_CASE" , fileCommitIdMap.get(loadTestFile.getFileId())); list.add(dto); } diff --git a/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java b/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java index 7e67ea5b27..72c91e9fda 100644 --- a/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java +++ b/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java @@ -407,7 +407,7 @@ public class IssueTemplateService extends TemplateBaseService { options.removeIf(sourceOption -> StringUtils.contains(tarCustomField.getOptions(), sourceOption.getText().toString())); if (CollectionUtils.isNotEmpty(options)) { optionsStr = JSON.toJSONString(options); - optionsStr = StringUtils.replace(tarCustomField.getOptions(), "]", ",") + StringUtils.replace(optionsStr, "[", ""); + optionsStr = StringUtils.replace(tarCustomField.getOptions(), "]", ",") + StringUtils.replace(optionsStr, "[", StringUtils.EMPTY); } else { optionsStr = tarCustomField.getOptions(); } @@ -434,7 +434,7 @@ public class IssueTemplateService extends TemplateBaseService { if (sourceCustomFieldTemplate.getDefaultValue() != null && tarCustomField.getOptions().contains(sourceCustomFieldTemplate.getDefaultValue())) { defaultValue = sourceCustomFieldTemplate.getDefaultValue(); } else { - defaultValue = ""; + defaultValue = StringUtils.EMPTY; } tarCustomFieldTemplate.setDefaultValue(defaultValue); customFieldTemplateRecords.add(tarCustomFieldTemplate);