From a5ac19d71adac78bfd7620e375658d54579e950e Mon Sep 17 00:00:00 2001 From: MeterSphere Bot <78466014+metersphere-bot@users.noreply.github.com> Date: Fri, 12 Aug 2022 15:25:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=A7=E8=A1=8C=E6=B2=A1=E6=9C=89csv?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E5=9C=BA=E6=99=AF=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E7=9A=84=E7=BC=BA=E9=99=B7=20(#16831)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: wxg0103 <727495428@qq.com> --- .../api/dto/definition/parse/Swagger2Parser.java | 2 +- .../api/dto/definition/request/ElementUtil.java | 7 +++++-- backend/src/main/resources/i18n/messages_en_US.properties | 1 + backend/src/main/resources/i18n/messages_zh_CN.properties | 1 + backend/src/main/resources/i18n/messages_zh_TW.properties | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java index 781c48c502..80e8a19e58 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java @@ -39,7 +39,7 @@ public class Swagger2Parser extends SwaggerAbstractParser { if (StringUtils.isNotBlank(request.getSwaggerUrl())) { try { // 使用 url 导入 swagger - swagger = new SwaggerParser().read(request.getSwaggerUrl(), auths, true); + swagger = new SwaggerParser().read(request.getSwaggerUrl(), auths, false); } catch (Exception e) { LoggerUtil.error(e); MSException.throwException(e.getMessage()); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index 14144aa7ef..f08a76faf9 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -26,6 +26,7 @@ import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.FileUtils; import io.metersphere.commons.utils.LogUtil; import io.metersphere.constants.RunModeConstants; +import io.metersphere.i18n.Translator; import io.metersphere.jmeter.utils.ScriptEngineUtils; import io.metersphere.plugin.core.MsParameter; import io.metersphere.plugin.core.MsTestElement; @@ -113,9 +114,11 @@ public class ElementUtil { csvDataSet.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName()); csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding()); - if (CollectionUtils.isNotEmpty(item.getFiles())) { + if (CollectionUtils.isEmpty(item.getFiles())) { + MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ " + Translator.get("csv_no_exist") + " ]"); + } else { if (!config.isOperating() && !new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) { - MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ CSV文件不存在 ]"); + MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ " + Translator.get("csv_no_exist") + " ]"); } csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()); } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 22758d980b..6c94c125b2 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -409,3 +409,4 @@ ui_element_already_exists_data=An element with the same name already exists serial=Serial parallel=Parallel plan_warning=The test plan does not have an associated executable use case +csv_no_exist=CSV file does not exist diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 93bed0842e..464b4de49c 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -408,3 +408,4 @@ ui_element_already_exists_data=已经存在同名元素 serial=串行 parallel=并行 plan_warning=测试计划没有关联可执行的用例 +csv_no_exist=CSV文件不存在 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 341349e58b..079e1c7c0a 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -407,3 +407,4 @@ ui_element_already_exists_data=已經存在同名元素 serial=串行 parallel=並行 plan_warning=測試計劃沒有關聯可執行的用例 +csv_no_exist=CSV檔案不存在