diff --git a/backend/pom.xml b/backend/pom.xml index be89a74d2e..c54fc88b7c 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -283,6 +283,13 @@ 2.0.22 + + + org.codehaus.groovy + groovy-jsr223 + 2.5.10 + + org.graalvm.sdk diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index 31fed91906..508300ef5c 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -171,7 +171,7 @@ public class ApiDefinitionController { @PostMapping(value = "/import", consumes = {"multipart/form-data"}) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) public ApiDefinitionImport testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) { - return apiDefinitionService.apiTestImport(file, request); + return apiDefinitionService.apiTestImport(file, request);//95821329-9eaa-4d2a-aa24-e6f912994716" } @PostMapping(value = "/export/{type}") diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/ESBParser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/ESBParser.java index 0c6c51fdd0..be67fbadb6 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/ESBParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/ESBParser.java @@ -80,9 +80,9 @@ public class ESBParser extends EsbAbstractParser { font.setFontHeightInPoints((short) 9); Map cellStyleMap = createCellStle(workbook); XSSFSheet headSheet = workbook.createSheet("公共报文头"); - generateSheet(headSheet,true, font,cellStyleMap); + generateSheet(headSheet, font, cellStyleMap); XSSFSheet bodySheet = workbook.createSheet("接口报文信息"); - generateSheet(bodySheet, false,font,cellStyleMap); + generateSheet(bodySheet, font, cellStyleMap); return workbook; } @@ -99,24 +99,24 @@ public class ESBParser extends EsbAbstractParser { style.setBorderTop(BorderStyle.THIN); String name = ""; - if(colorIndex == IndexedColors.LIGHT_GREEN.getIndex()){ + if (colorIndex == IndexedColors.LIGHT_GREEN.getIndex()) { style.setFillForegroundColor(new XSSFColor(new java.awt.Color(204, 255, 204))); name = "green"; - }else if(colorIndex == IndexedColors.ORCHID.getIndex()){ + } else if (colorIndex == IndexedColors.ORCHID.getIndex()) { style.setFillForegroundColor(new XSSFColor(new java.awt.Color(151, 50, 101))); name = "pop"; - }else if(colorIndex == IndexedColors.YELLOW.getIndex()){ + } else if (colorIndex == IndexedColors.YELLOW.getIndex()) { style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 153))); name = "yellow"; - }else{ + } else { name = "default"; } - cellStype.put(name,style); + cellStype.put(name, style); } return cellStype; } - private static void generateSheet(XSSFSheet sheet,boolean isHead, XSSFFont font,Map cellStyleMap) { + private static void generateSheet(XSSFSheet sheet, XSSFFont font, Map cellStyleMap) { if (sheet == null) { return; } @@ -125,22 +125,12 @@ public class ESBParser extends EsbAbstractParser { sheet.setColumnWidth(1, 4000); sheet.setColumnWidth(2, 4000); sheet.setColumnWidth(3, 4000); - if(isHead){ - sheet.setColumnWidth(4, 880); - sheet.setColumnWidth(5, 4000); - sheet.setColumnWidth(6, 4000); - sheet.setColumnWidth(7, 4000); - sheet.setColumnWidth(8, 4000); - sheet.setColumnWidth(9, 4000); - }else { - sheet.setColumnWidth(4, 4000); - sheet.setColumnWidth(5, 880); - sheet.setColumnWidth(6, 4000); - sheet.setColumnWidth(7, 4000); - sheet.setColumnWidth(8, 4000); - sheet.setColumnWidth(9, 4000); - sheet.setColumnWidth(10, 4000); - } + sheet.setColumnWidth(4, 880); + sheet.setColumnWidth(5, 4000); + sheet.setColumnWidth(6, 4000); + sheet.setColumnWidth(7, 4000); + sheet.setColumnWidth(8, 4000); + sheet.setColumnWidth(9, 4000); /** * 模版生成: @@ -156,210 +146,210 @@ public class ESBParser extends EsbAbstractParser { * row9: 3:请输入STRING(具体长度) 或 ARRAY; 8:同3 */ XSSFRow row1 = sheet.createRow(0); - setCellValue("交易码", row1.createCell(0), font,cellStyleMap.get("default")); - setCellValue("交易名称", row1.createCell(1), font,cellStyleMap.get("default")); - setCellValue("", row1.createCell(2), font,cellStyleMap.get("default")); - setCellValue("", row1.createCell(3), font,cellStyleMap.get("default")); - if(isHead){ - setCellValue("", row1.createCell(4), font,cellStyleMap.get("default")); - setCellValue("服务名称", row1.createCell(5), font,cellStyleMap.get("default")); - setCellValue("服务场景", row1.createCell(6), font,cellStyleMap.get("default")); - setCellValue("", row1.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row1.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row1.createCell(9), font,cellStyleMap.get("default")); + setCellValue("交易码", row1.createCell(0), font, cellStyleMap.get("default")); + setCellValue("交易名称", row1.createCell(1), font, cellStyleMap.get("default")); + setCellValue("", row1.createCell(2), font, cellStyleMap.get("default")); + setCellValue("", row1.createCell(3), font, cellStyleMap.get("default")); +// if (isHead) { + setCellValue("", row1.createCell(4), font, cellStyleMap.get("default")); + setCellValue("服务名称", row1.createCell(5), font, cellStyleMap.get("default")); + setCellValue("服务场景", row1.createCell(6), font, cellStyleMap.get("default")); + setCellValue("", row1.createCell(7), font, cellStyleMap.get("default")); + setCellValue("", row1.createCell(8), font, cellStyleMap.get("default")); + setCellValue("", row1.createCell(9), font, cellStyleMap.get("default")); - }else{ - setCellValue("", row1.createCell(4), font,cellStyleMap.get("default")); - setCellValue("", row1.createCell(5), font,cellStyleMap.get("pop")); - setCellValue("服务名称", row1.createCell(6), font,cellStyleMap.get("default")); - setCellValue("服务场景", row1.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row1.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row1.createCell(9), font,cellStyleMap.get("default")); - setCellValue("", row1.createCell(10), font,cellStyleMap.get("default")); - } +// } else { +// setCellValue("", row1.createCell(4), font, cellStyleMap.get("default")); +// setCellValue("", row1.createCell(5), font, cellStyleMap.get("pop")); +// setCellValue("服务名称", row1.createCell(6), font, cellStyleMap.get("default")); +// setCellValue("服务场景", row1.createCell(7), font, cellStyleMap.get("default")); +// setCellValue("", row1.createCell(8), font, cellStyleMap.get("default")); +// setCellValue("", row1.createCell(9), font, cellStyleMap.get("default")); +// setCellValue("", row1.createCell(10), font, cellStyleMap.get("default")); +// } XSSFRow row2 = sheet.createRow(1); - setCellValue("请输入交易码(必填)", row2.createCell(0), font,cellStyleMap.get("default")); - setCellValue("请输入交易名称(必填)", row2.createCell(1), font,cellStyleMap.get("default")); - setCellValue("", row2.createCell(2), font,cellStyleMap.get("default")); - setCellValue("", row2.createCell(3), font,cellStyleMap.get("default")); - if(isHead){ - setCellValue("", row2.createCell(4), font,cellStyleMap.get("pop")); - setCellValue("请输入服务名称(如果不填,则以交易名称为主)", row2.createCell(5), font,null); - setCellValue("请输入服务场景(选填)", row2.createCell(6), font,cellStyleMap.get("default")); - setCellValue("", row2.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row2.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row2.createCell(9), font,cellStyleMap.get("default")); - }else{ - setCellValue("", row2.createCell(4), font,cellStyleMap.get("default")); - setCellValue("", row2.createCell(5), font,cellStyleMap.get("pop")); - setCellValue("请输入服务名称(如果不填,则以交易名称为主)", row2.createCell(6), font,null); - setCellValue("请输入服务场景(选填)", row2.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row2.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row2.createCell(9), font,cellStyleMap.get("default")); - setCellValue("", row2.createCell(10), font,cellStyleMap.get("default")); - } + setCellValue("请输入交易码(必填)", row2.createCell(0), font, cellStyleMap.get("default")); + setCellValue("请输入交易名称(必填)", row2.createCell(1), font, cellStyleMap.get("default")); + setCellValue("", row2.createCell(2), font, cellStyleMap.get("default")); + setCellValue("", row2.createCell(3), font, cellStyleMap.get("default")); +// if (isHead) { + setCellValue("", row2.createCell(4), font, cellStyleMap.get("pop")); + setCellValue("请输入服务名称(如果不填,则以交易名称为主)", row2.createCell(5), font, null); + setCellValue("请输入服务场景(选填)", row2.createCell(6), font, cellStyleMap.get("default")); + setCellValue("", row2.createCell(7), font, cellStyleMap.get("default")); + setCellValue("", row2.createCell(8), font, cellStyleMap.get("default")); + setCellValue("", row2.createCell(9), font, cellStyleMap.get("default")); +// } else { +// setCellValue("", row2.createCell(4), font, cellStyleMap.get("default")); +// setCellValue("", row2.createCell(5), font, cellStyleMap.get("pop")); +// setCellValue("请输入服务名称(如果不填,则以交易名称为主)", row2.createCell(6), font, null); +// setCellValue("请输入服务场景(选填)", row2.createCell(7), font, cellStyleMap.get("default")); +// setCellValue("", row2.createCell(8), font, cellStyleMap.get("default")); +// setCellValue("", row2.createCell(9), font, cellStyleMap.get("default")); +// setCellValue("", row2.createCell(10), font, cellStyleMap.get("default")); +// } XSSFRow row3 = sheet.createRow(2); - setCellValue("", row3.createCell(0), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(1), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(2), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(3), font,cellStyleMap.get("yellow")); - if(isHead){ - setCellValue("", row3.createCell(4), font,cellStyleMap.get("yellow")); - setCellValue("请输入系统名称", row3.createCell(5), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(6), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(7), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(8), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(9), font,cellStyleMap.get("yellow")); - CellRangeAddress region1 = new CellRangeAddress(2, 2, 0, 3); - sheet.addMergedRegion(region1); - CellRangeAddress region2 = new CellRangeAddress(2, 2, 5, 9); - sheet.addMergedRegion(region2); - }else{ - setCellValue("", row3.createCell(4), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(5), font,cellStyleMap.get("yellow")); - setCellValue("请输入系统名称", row3.createCell(6), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(7), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(8), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(9), font,cellStyleMap.get("yellow")); - setCellValue("", row3.createCell(10), font,cellStyleMap.get("yellow")); - CellRangeAddress region1 = new CellRangeAddress(2, 2, 0, 4); - sheet.addMergedRegion(region1); - CellRangeAddress region2 = new CellRangeAddress(2, 2, 6, 10); - sheet.addMergedRegion(region2); - } + setCellValue("", row3.createCell(0), font, cellStyleMap.get("yellow")); + setCellValue("", row3.createCell(1), font, cellStyleMap.get("yellow")); + setCellValue("", row3.createCell(2), font, cellStyleMap.get("yellow")); + setCellValue("", row3.createCell(3), font, cellStyleMap.get("yellow")); +// if (isHead) { + setCellValue("", row3.createCell(4), font, cellStyleMap.get("yellow")); + setCellValue("请输入系统名称", row3.createCell(5), font, cellStyleMap.get("yellow")); + setCellValue("", row3.createCell(6), font, cellStyleMap.get("yellow")); + setCellValue("", row3.createCell(7), font, cellStyleMap.get("yellow")); + setCellValue("", row3.createCell(8), font, cellStyleMap.get("yellow")); + setCellValue("", row3.createCell(9), font, cellStyleMap.get("yellow")); + CellRangeAddress region1 = new CellRangeAddress(2, 2, 0, 3); + sheet.addMergedRegion(region1); + CellRangeAddress region2 = new CellRangeAddress(2, 2, 5, 9); + sheet.addMergedRegion(region2); +// } else { +// setCellValue("", row3.createCell(4), font, cellStyleMap.get("yellow")); +// setCellValue("", row3.createCell(5), font, cellStyleMap.get("yellow")); +// setCellValue("请输入系统名称", row3.createCell(6), font, cellStyleMap.get("yellow")); +// setCellValue("", row3.createCell(7), font, cellStyleMap.get("yellow")); +// setCellValue("", row3.createCell(8), font, cellStyleMap.get("yellow")); +// setCellValue("", row3.createCell(9), font, cellStyleMap.get("yellow")); +// setCellValue("", row3.createCell(10), font, cellStyleMap.get("yellow")); +// CellRangeAddress region1 = new CellRangeAddress(2, 2, 0, 4); +// sheet.addMergedRegion(region1); +// CellRangeAddress region2 = new CellRangeAddress(2, 2, 6, 10); +// sheet.addMergedRegion(region2); +// } XSSFRow row4 = sheet.createRow(3); - setCellValue("英文名称", row4.createCell(0), font,cellStyleMap.get("yellow")); - setCellValue("中文名称", row4.createCell(1), font,cellStyleMap.get("yellow")); - setCellValue("数据类型/长度", row4.createCell(2), font,cellStyleMap.get("yellow")); - if(isHead){ - setCellValue("备注", row4.createCell(3), font,cellStyleMap.get("yellow")); - setCellValue("", row4.createCell(4), font,cellStyleMap.get("pop")); - setCellValue("英文名称", row4.createCell(5), font,cellStyleMap.get("yellow")); - setCellValue("数据类型/长度", row4.createCell(6), font,cellStyleMap.get("yellow")); - setCellValue("中文名称", row4.createCell(7), font,cellStyleMap.get("yellow")); - setCellValue("备注", row4.createCell(8), font,cellStyleMap.get("yellow")); - setCellValue("所在报文位置", row4.createCell(9), font,cellStyleMap.get("yellow")); - }else { - setCellValue("是否必输", row4.createCell(3), font,cellStyleMap.get("yellow")); - setCellValue("备注", row4.createCell(4), font,cellStyleMap.get("yellow")); - setCellValue("", row4.createCell(5), font,cellStyleMap.get("pop")); - setCellValue("英文名称", row4.createCell(6), font,cellStyleMap.get("yellow")); - setCellValue("数据类型/长度", row4.createCell(7), font,cellStyleMap.get("yellow")); - setCellValue("中文名称", row4.createCell(8), font,cellStyleMap.get("yellow")); - setCellValue("备注", row4.createCell(9), font,cellStyleMap.get("yellow")); - setCellValue("所在报文位置", row4.createCell(10), font,cellStyleMap.get("yellow")); - } + setCellValue("英文名称", row4.createCell(0), font, cellStyleMap.get("yellow")); + setCellValue("中文名称", row4.createCell(1), font, cellStyleMap.get("yellow")); + setCellValue("数据类型/长度", row4.createCell(2), font, cellStyleMap.get("yellow")); +// if (isHead) { + setCellValue("备注", row4.createCell(3), font, cellStyleMap.get("yellow")); + setCellValue("", row4.createCell(4), font, cellStyleMap.get("pop")); + setCellValue("英文名称", row4.createCell(5), font, cellStyleMap.get("yellow")); + setCellValue("数据类型/长度", row4.createCell(6), font, cellStyleMap.get("yellow")); + setCellValue("中文名称", row4.createCell(7), font, cellStyleMap.get("yellow")); + setCellValue("备注", row4.createCell(8), font, cellStyleMap.get("yellow")); + setCellValue("所在报文位置", row4.createCell(9), font, cellStyleMap.get("yellow")); +// } else { +// setCellValue("是否必输", row4.createCell(3), font, cellStyleMap.get("yellow")); +// setCellValue("备注", row4.createCell(4), font, cellStyleMap.get("yellow")); +// setCellValue("", row4.createCell(5), font, cellStyleMap.get("pop")); +// setCellValue("英文名称", row4.createCell(6), font, cellStyleMap.get("yellow")); +// setCellValue("数据类型/长度", row4.createCell(7), font, cellStyleMap.get("yellow")); +// setCellValue("中文名称", row4.createCell(8), font, cellStyleMap.get("yellow")); +// setCellValue("备注", row4.createCell(9), font, cellStyleMap.get("yellow")); +// setCellValue("所在报文位置", row4.createCell(10), font, cellStyleMap.get("yellow")); +// } XSSFRow row5 = sheet.createRow(4); - setCellValue("输入", row5.createCell(0), font,cellStyleMap.get("green")); - setCellValue("", row5.createCell(1), font,cellStyleMap.get("green")); - setCellValue("", row5.createCell(2), font,cellStyleMap.get("green")); - setCellValue("", row5.createCell(3), font,cellStyleMap.get("green")); - setCellValue("", row5.createCell(4), font,cellStyleMap.get("green")); - setCellValue("", row5.createCell(5), font,cellStyleMap.get("green")); - setCellValue("", row5.createCell(6), font,cellStyleMap.get("green")); - setCellValue("", row5.createCell(7), font,cellStyleMap.get("green")); - setCellValue("", row5.createCell(8), font,cellStyleMap.get("green")); - setCellValue("", row5.createCell(9), font,cellStyleMap.get("green")); - if(!isHead){ - setCellValue("", row5.createCell(10), font,cellStyleMap.get("green")); - } + setCellValue("输入", row5.createCell(0), font, cellStyleMap.get("green")); + setCellValue("", row5.createCell(1), font, cellStyleMap.get("green")); + setCellValue("", row5.createCell(2), font, cellStyleMap.get("green")); + setCellValue("", row5.createCell(3), font, cellStyleMap.get("green")); + setCellValue("", row5.createCell(4), font, cellStyleMap.get("green")); + setCellValue("", row5.createCell(5), font, cellStyleMap.get("green")); + setCellValue("", row5.createCell(6), font, cellStyleMap.get("green")); + setCellValue("", row5.createCell(7), font, cellStyleMap.get("green")); + setCellValue("", row5.createCell(8), font, cellStyleMap.get("green")); + setCellValue("", row5.createCell(9), font, cellStyleMap.get("green")); +// if (!isHead) { +// setCellValue("", row5.createCell(10), font, cellStyleMap.get("green")); +// } XSSFRow row6 = sheet.createRow(5); - setCellValue("", row6.createCell(0), font,cellStyleMap.get("default")); - setCellValue("", row6.createCell(1), font,cellStyleMap.get("default")); - setCellValue("请输入STRING(具体长度) 或 ARRAY", row6.createCell(2), font,cellStyleMap.get("default")); - setCellValue("", row6.createCell(3), font,cellStyleMap.get("default")); - if(isHead){ - setCellValue("", row6.createCell(4), font,cellStyleMap.get("pop")); - setCellValue("", row6.createCell(5), font,cellStyleMap.get("default")); - setCellValue("请输入STRING(具体长度) 或 ARRAY", row6.createCell(6), font,cellStyleMap.get("default")); - setCellValue("", row6.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row6.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row6.createCell(9), font,cellStyleMap.get("default")); - }else { - setCellValue("", row6.createCell(4), font,cellStyleMap.get("default")); - setCellValue("", row6.createCell(5), font,cellStyleMap.get("pop")); - setCellValue("", row6.createCell(6), font,cellStyleMap.get("default")); - setCellValue("请输入STRING(具体长度) 或 ARRAY", row6.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row6.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row6.createCell(9), font,cellStyleMap.get("default")); - setCellValue("", row6.createCell(10), font,cellStyleMap.get("default")); - } + setCellValue("", row6.createCell(0), font, cellStyleMap.get("default")); + setCellValue("", row6.createCell(1), font, cellStyleMap.get("default")); + setCellValue("请输入STRING(具体长度) 或 ARRAY", row6.createCell(2), font, cellStyleMap.get("default")); + setCellValue("", row6.createCell(3), font, cellStyleMap.get("default")); +// if (isHead) { + setCellValue("", row6.createCell(4), font, cellStyleMap.get("pop")); + setCellValue("", row6.createCell(5), font, cellStyleMap.get("default")); + setCellValue("请输入STRING(具体长度) 或 ARRAY", row6.createCell(6), font, cellStyleMap.get("default")); + setCellValue("", row6.createCell(7), font, cellStyleMap.get("default")); + setCellValue("", row6.createCell(8), font, cellStyleMap.get("default")); + setCellValue("", row6.createCell(9), font, cellStyleMap.get("default")); +// } else { +// setCellValue("", row6.createCell(4), font, cellStyleMap.get("default")); +// setCellValue("", row6.createCell(5), font, cellStyleMap.get("pop")); +// setCellValue("", row6.createCell(6), font, cellStyleMap.get("default")); +// setCellValue("请输入STRING(具体长度) 或 ARRAY", row6.createCell(7), font, cellStyleMap.get("default")); +// setCellValue("", row6.createCell(8), font, cellStyleMap.get("default")); +// setCellValue("", row6.createCell(9), font, cellStyleMap.get("default")); +// setCellValue("", row6.createCell(10), font, cellStyleMap.get("default")); +// } XSSFRow row7 = sheet.createRow(6); - setCellValue("", row7.createCell(1), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(2), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(3), font,cellStyleMap.get("default")); - if(isHead){ - setCellValue("", row7.createCell(4), font,cellStyleMap.get("pop")); - setCellValue("", row7.createCell(5), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(6), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(9), font,cellStyleMap.get("default")); - }else { - setCellValue("", row7.createCell(4), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(5), font,cellStyleMap.get("pop")); - setCellValue("", row7.createCell(6), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(9), font,cellStyleMap.get("default")); - setCellValue("", row7.createCell(10), font,cellStyleMap.get("default")); - } + setCellValue("", row7.createCell(1), font, cellStyleMap.get("default")); + setCellValue("", row7.createCell(2), font, cellStyleMap.get("default")); + setCellValue("", row7.createCell(3), font, cellStyleMap.get("default")); +// if (isHead) { + setCellValue("", row7.createCell(4), font, cellStyleMap.get("pop")); + setCellValue("", row7.createCell(5), font, cellStyleMap.get("default")); + setCellValue("", row7.createCell(6), font, cellStyleMap.get("default")); + setCellValue("", row7.createCell(7), font, cellStyleMap.get("default")); + setCellValue("", row7.createCell(8), font, cellStyleMap.get("default")); + setCellValue("", row7.createCell(9), font, cellStyleMap.get("default")); +// } else { +// setCellValue("", row7.createCell(4), font, cellStyleMap.get("default")); +// setCellValue("", row7.createCell(5), font, cellStyleMap.get("pop")); +// setCellValue("", row7.createCell(6), font, cellStyleMap.get("default")); +// setCellValue("", row7.createCell(7), font, cellStyleMap.get("default")); +// setCellValue("", row7.createCell(8), font, cellStyleMap.get("default")); +// setCellValue("", row7.createCell(9), font, cellStyleMap.get("default")); +// setCellValue("", row7.createCell(10), font, cellStyleMap.get("default")); +// } XSSFRow row8 = sheet.createRow(7); - setCellValue("输出", row8.createCell(0), font,cellStyleMap.get("green")); - setCellValue("", row8.createCell(1), font,cellStyleMap.get("green")); - setCellValue("", row8.createCell(2), font,cellStyleMap.get("green")); - setCellValue("", row8.createCell(3), font,cellStyleMap.get("green")); - setCellValue("", row8.createCell(4), font,cellStyleMap.get("green")); - setCellValue("", row8.createCell(5), font,cellStyleMap.get("green")); - setCellValue("", row8.createCell(6), font,cellStyleMap.get("green")); - setCellValue("", row8.createCell(7), font,cellStyleMap.get("green")); - setCellValue("", row8.createCell(8), font,cellStyleMap.get("green")); - setCellValue("", row8.createCell(9), font,cellStyleMap.get("green")); - if(!isHead){ - setCellValue("", row8.createCell(10), font,cellStyleMap.get("green")); - } + setCellValue("输出", row8.createCell(0), font, cellStyleMap.get("green")); + setCellValue("", row8.createCell(1), font, cellStyleMap.get("green")); + setCellValue("", row8.createCell(2), font, cellStyleMap.get("green")); + setCellValue("", row8.createCell(3), font, cellStyleMap.get("green")); + setCellValue("", row8.createCell(4), font, cellStyleMap.get("green")); + setCellValue("", row8.createCell(5), font, cellStyleMap.get("green")); + setCellValue("", row8.createCell(6), font, cellStyleMap.get("green")); + setCellValue("", row8.createCell(7), font, cellStyleMap.get("green")); + setCellValue("", row8.createCell(8), font, cellStyleMap.get("green")); + setCellValue("", row8.createCell(9), font, cellStyleMap.get("green")); +// if (!isHead) { +// setCellValue("", row8.createCell(10), font, cellStyleMap.get("green")); +// } XSSFRow row9 = sheet.createRow(8); - setCellValue("", row9.createCell(0), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(1), font,cellStyleMap.get("default")); - setCellValue("请输入STRING(具体长度) 或 ARRAY", row9.createCell(2), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(3), font,cellStyleMap.get("default")); - if(isHead){ - setCellValue("", row9.createCell(4), font,cellStyleMap.get("pop")); - setCellValue("", row9.createCell(5), font,cellStyleMap.get("default")); - setCellValue("请输入STRING(具体长度) 或 ARRAY", row9.createCell(6), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(9), font,cellStyleMap.get("default")); - }else { - setCellValue("", row9.createCell(4), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(5), font,cellStyleMap.get("pop")); - setCellValue("", row9.createCell(6), font,cellStyleMap.get("default")); - setCellValue("请输入STRING(具体长度) 或 ARRAY", row9.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(7), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(8), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(9), font,cellStyleMap.get("default")); - setCellValue("", row9.createCell(10), font,cellStyleMap.get("default")); - } + setCellValue("", row9.createCell(0), font, cellStyleMap.get("default")); + setCellValue("", row9.createCell(1), font, cellStyleMap.get("default")); + setCellValue("请输入STRING(具体长度) 或 ARRAY", row9.createCell(2), font, cellStyleMap.get("default")); + setCellValue("", row9.createCell(3), font, cellStyleMap.get("default")); +// if (isHead) { + setCellValue("", row9.createCell(4), font, cellStyleMap.get("pop")); + setCellValue("", row9.createCell(5), font, cellStyleMap.get("default")); + setCellValue("请输入STRING(具体长度) 或 ARRAY", row9.createCell(6), font, cellStyleMap.get("default")); + setCellValue("", row9.createCell(7), font, cellStyleMap.get("default")); + setCellValue("", row9.createCell(8), font, cellStyleMap.get("default")); + setCellValue("", row9.createCell(9), font, cellStyleMap.get("default")); +// } else { +// setCellValue("", row9.createCell(4), font, cellStyleMap.get("default")); +// setCellValue("", row9.createCell(5), font, cellStyleMap.get("pop")); +// setCellValue("", row9.createCell(6), font, cellStyleMap.get("default")); +// setCellValue("请输入STRING(具体长度) 或 ARRAY", row9.createCell(7), font, cellStyleMap.get("default")); +// setCellValue("", row9.createCell(7), font, cellStyleMap.get("default")); +// setCellValue("", row9.createCell(8), font, cellStyleMap.get("default")); +// setCellValue("", row9.createCell(9), font, cellStyleMap.get("default")); +// setCellValue("", row9.createCell(10), font, cellStyleMap.get("default")); +// } } - private static void setCellValue(String textValue, Cell cell, XSSFFont font,XSSFCellStyle cellStyle) { + private static void setCellValue(String textValue, Cell cell, XSSFFont font, XSSFCellStyle cellStyle) { // HSSFRichTextString richString = new HSSFRichTextString(textValue); XSSFRichTextString richString = new XSSFRichTextString(textValue); richString.applyFont(font); - if(cellStyle!=null){ + if (cellStyle != null) { cell.setCellStyle(cellStyle); } cell.setCellValue(richString); @@ -368,12 +358,9 @@ public class ESBParser extends EsbAbstractParser { @Override public ApiDefinitionImport parse(InputStream source, ApiTestImportRequest request) throws Exception { - EsbSheetDataStruct esbImportDataStruct = new EsbSheetDataStruct(); EsbExcelDataStruct excelDataStruct = this.esbImport(source); - this.projectId = request.getProjectId(); ApiDefinitionImport definitionImport = this.parseApiDefinitionImport(excelDataStruct, request); - return definitionImport; } @@ -411,21 +398,21 @@ public class ESBParser extends EsbAbstractParser { int descIndex = 9; int apiPositionIndex = 10; int cellCount = 11; - if(isHeadSheet){ +// if (isHeadSheet) { apiNameIndex = 5; apiDescIndex = 6; chineNameIndex = 7; descIndex = 8; apiPositionIndex = 9; cellCount = 10; - } +// } int rowCount = headSheet.getLastRowNum(); //根据模版样式,如果不是报文头,则要取接口信息 if (!isHeadSheet) { Row interfaceInfoRow = headSheet.getRow(1); if (interfaceInfoRow != null) { - List rowDataArr = this.getRowDataByStartIndexAndEndIndex(interfaceInfoRow, 0, cellCount-1); + List rowDataArr = this.getRowDataByStartIndexAndEndIndex(interfaceInfoRow, 0, cellCount - 1); if (rowDataArr.size() >= cellCount) { String interfaceCode = rowDataArr.get(simpleCodeIndex); String interfaceName = rowDataArr.get(apiNameIndex); @@ -437,13 +424,13 @@ public class ESBParser extends EsbAbstractParser { } } } - //超过5行为空白,直接退出。 + //超过10行为空白,直接退出。 //部分office/wpf生成的文件会出现几万多空行,容易造成内存溢出。这里进行判断,连续五行为空白时认为读取结束。 int blankRowCount = 0; boolean isRequest = true; for (int startRow = REQUEST_MESSAGE_ROW; startRow < rowCount; startRow++) { Row row = headSheet.getRow(startRow); - List rowDataArr = this.getRowDataByStartIndexAndEndIndex(row, 0, cellCount-1); + List rowDataArr = this.getRowDataByStartIndexAndEndIndex(row, 0, cellCount - 1); boolean isBlankRow = this.checkBlankRow(rowDataArr, cellCount); if (!isBlankRow) { String cellFlag = rowDataArr.get(0); @@ -456,7 +443,7 @@ public class ESBParser extends EsbAbstractParser { isRequest = false; } blankRowCount++; - if (blankRowCount > 5) { + if (blankRowCount > 10) { break; } } else { @@ -512,7 +499,7 @@ public class ESBParser extends EsbAbstractParser { Cell cell = row.getCell(i); if (cell != null) { returnArray.add(getCellValue(cell)); - }else { + } else { returnArray.add(""); } } @@ -618,6 +605,8 @@ public class ESBParser extends EsbAbstractParser { apiDefinition.setMethod("ESB"); apiDefinition.setId(apiId); apiDefinition.setProjectId(this.projectId); + apiDefinition.setModuleId(importRequest.getModuleId()); + apiDefinition.setModulePath(importRequest.getModulePath()); apiDefinition.setRequest(genTCPSampler()); if (StringUtils.equalsIgnoreCase("schedule", importRequest.getType())) { apiDefinition.setUserId(importRequest.getUserId()); 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 2d88dde7f5..d70423500e 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 @@ -130,7 +130,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { } // 1.8 之前历史数据 - if(StringUtils.isEmpty(this.getProjectId()) && config.getConfig()!= null && !config.getConfig().isEmpty()){ + if (StringUtils.isEmpty(this.getProjectId()) && config.getConfig() != null && !config.getConfig().isEmpty()) { this.setProjectId("historyProjectID"); } @@ -154,10 +154,11 @@ public class MsHTTPSamplerProxy extends MsTestElement { } URL urlObject = new URL(url); sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8")); - if (urlObject.getPort() > 0 && urlObject.getPort() != 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) { - sampler.setPort(urlObject.getPort()); - } else { + + if (urlObject.getPort() > 0 && urlObject.getPort() == 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) { sampler.setProperty("HTTPSampler.port", this.getPort()); + } else { + sampler.setPort(urlObject.getPort()); } sampler.setProtocol(urlObject.getProtocol()); sampler.setPath(urlObject.getPath()); diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java index fa14afa7fa..3ecf48632c 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -333,10 +333,6 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl for (SampleResult subResult : result.getSubResults()) { requestResult.getSubRequestResults().add(getRequestResult(subResult)); } - for (SampleResult subResult : result.getSubResults()) { - requestResult.getSubRequestResults().add(getRequestResult(subResult)); - } - ResponseResult responseResult = requestResult.getResponseResult(); responseResult.setBody(result.getResponseDataAsString()); responseResult.setHeaders(result.getResponseHeaders()); diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 80ff621285..f29e46d379 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -182,25 +182,19 @@ public class TestCaseService { List caseList = testCaseMapper.selectByExampleWithBLOBs(example); - // 如果上边字段全部相同,去检查 steps 和 remark - boolean isExt = false; - String caseRemark = testCase.getRemark(); - if (StringUtils.isBlank(caseRemark)) { - caseRemark = ""; - } + // 如果上边字段全部相同,去检查 remark 和 steps if (!CollectionUtils.isEmpty(caseList)) { + String caseRemark = testCase.getRemark(); + String caseSteps = testCase.getSteps(); for (TestCaseWithBLOBs tc : caseList) { String steps = tc.getSteps(); String remark = tc.getRemark(); - if (StringUtils.equals(steps, testCase.getSteps()) && StringUtils.equals(remark, caseRemark)) { - //MSException.throwException(Translator.get("test_case_already_exists")); - isExt = true; + if (StringUtils.equals(steps, caseSteps) && StringUtils.equals(remark, caseRemark)) { + //MSException.throwException(Translator.get("test_case_already_exists")); + return tc; } } } - if (isExt) { - return caseList.get(0); - } } return null; } diff --git a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java index 8a65db8a7b..d9d672385a 100644 --- a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java +++ b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java @@ -113,8 +113,8 @@ public class XmindCaseParser { for (int i = 0; i < nodes.length; i++) { if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) { process.add(Translator.get("module_not_null"), path); - } else if (nodes[i].trim().length() > 30) { - process.add(Translator.get("module") + Translator.get("test_track.length_less_than") + "30", path + nodes[i].trim()); + } else if (nodes[i].trim().length() > 100) { + process.add(Translator.get("module") + Translator.get("test_track.length_less_than") + "100", path + nodes[i].trim()); } else { path += nodes[i].trim() + "/"; } @@ -150,8 +150,8 @@ public class XmindCaseParser { if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) { process.add(Translator.get("test_case") + Translator.get("module_not_null"), nodePath + data.getName()); break; - } else if (nodes[i].trim().length() > 30) { - process.add(Translator.get("module") + Translator.get("test_track.length_less_than") + "30 ", nodes[i].trim()); + } else if (nodes[i].trim().length() > 100) { + process.add(Translator.get("module") + Translator.get("test_track.length_less_than") + "100 ", nodes[i].trim()); break; } } diff --git a/backend/src/main/java/org/apache/jmeter/util/JSR223TestElement.java b/backend/src/main/java/org/apache/jmeter/util/JSR223TestElement.java index 9f70de2d49..ba173d2d98 100644 --- a/backend/src/main/java/org/apache/jmeter/util/JSR223TestElement.java +++ b/backend/src/main/java/org/apache/jmeter/util/JSR223TestElement.java @@ -24,6 +24,7 @@ import java.io.FileReader; import java.io.IOException; import java.io.Serializable; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Properties; @@ -34,6 +35,10 @@ import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; +import io.metersphere.base.domain.JarConfig; +import io.metersphere.commons.utils.CommonBeanFactory; +import io.metersphere.commons.utils.LogUtil; +import io.metersphere.service.JarConfigService; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.collections.map.LRUMap; import org.apache.commons.lang3.StringUtils; @@ -45,9 +50,11 @@ import org.apache.jmeter.threads.JMeterContext; import org.apache.jmeter.threads.JMeterContextService; import org.apache.jmeter.threads.JMeterVariables; import org.apache.jorphan.util.JOrphanUtils; +import org.codehaus.groovy.jsr223.GroovyScriptEngineImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + /** * Base class for JSR223 Test elements * @@ -166,6 +173,9 @@ public abstract class JSR223TestElement extends ScriptingTestElement */ protected Object processFileOrScript(ScriptEngine scriptEngine, final Bindings pBindings) throws IOException, ScriptException { + + this.loadGroovyJar(scriptEngine); + Bindings bindings = pBindings; if (bindings == null) { bindings = scriptEngine.createBindings(); @@ -250,6 +260,37 @@ public abstract class JSR223TestElement extends ScriptingTestElement } } + /** + * groovy 使用的是自己的类加载器, + * 这里再执行脚本前,使用 groovy的加载器加载jar包, + * 解决groovy脚本无法使用jar包的问题 + * @Auth jianxing + * @param scriptEngine + */ + public static void loadGroovyJar(ScriptEngine scriptEngine) { + if (scriptEngine instanceof GroovyScriptEngineImpl) { + GroovyScriptEngineImpl groovyScriptEngine = (GroovyScriptEngineImpl) scriptEngine; + + JarConfigService jarConfigService = CommonBeanFactory.getBean(JarConfigService.class); + List jars = jarConfigService.list(); + + jars.forEach(jarConfig -> { + try { + String path = jarConfig.getPath(); + File file = new File(path); + if (file.isDirectory() && !path.endsWith("/")) { + file = new File(path + "/"); + } + groovyScriptEngine.getClassLoader().addURL(file.toURI().toURL()); + } catch (Exception e) { + e.printStackTrace(); + LogUtil.error(e.getMessage(), e); + } + }); + + } + } + /** * @return boolean true if element is not compilable or if compilation succeeds * @throws IOException if script is missing @@ -351,4 +392,4 @@ public abstract class JSR223TestElement extends ScriptingTestElement public void setScriptLanguage(String s) { scriptLanguage = s; } -} \ No newline at end of file +} diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 747530bac6..bcb263b3c8 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -147,7 +147,7 @@ password_format_is_incorrect=有效密码:8-30位,英文大小写字母+数 please_input_workspace_member=请填写该工作空间相关人员 test_case_report_template_repeat=同一工作空间下不能存在同名模版 plan_name_already_exists=测试计划名称已存在 -test_case_already_exists_excel=导入文件中存在重复用例 +test_case_already_exists_excel=文件中存在多条相同用例 test_case_module_already_exists=同层级下已存在该模块名称 api_test_name_already_exists=测试名称已经存在 functional_method_tip=功能测试不支持自动方式 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 577cd6b3ac..eccfd47a3a 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -147,7 +147,7 @@ password_format_is_incorrect=有效密碼:8-30位,英文大小寫字母+數 please_input_workspace_member=請填寫該工作空間相關人員 test_case_report_template_repeat=同壹工作空間下不能存在同名模版 plan_name_already_exists=測試計劃名稱已存在 -test_case_already_exists_excel=導入文件中存在重復用例 +test_case_already_exists_excel=文件中存在多條相同用例 test_case_module_already_exists=同層級下已存在該模塊名稱 api_test_name_already_exists=測試名稱已經存在 functional_method_tip=功能測試不支持自動方式 diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue index 556fa95b77..180b05750b 100644 --- a/frontend/src/business/components/api/automation/ApiAutomation.vue +++ b/frontend/src/business/components/api/automation/ApiAutomation.vue @@ -197,6 +197,10 @@ currentScenario.apiScenarioModuleId = this.nodeTree[0].id; currentScenario.modulePath = this.nodeTree[0].path; } + + if (this.selectNodeIds && this.selectNodeIds.length > 0) { + currentScenario.apiScenarioModuleId = this.selectNodeIds[0]; + } this.tabs.push({label: label, name: name, currentScenario: currentScenario}); } if (tab.name === 'edit') { diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 8978fd056a..09d3cdf8ce 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -100,7 +100,14 @@
- {{ currentScenario.name === undefined || '' ? $t('api_test.scenario.name') : currentScenario.name }} + + + + {{ currentScenario.name === undefined || '' ? $t('api_test.scenario.name') : currentScenario.name }} + + {{$t('api_test.automation.step_total')}}:{{scenarioDefinition.length}} @@ -447,7 +454,7 @@ }, }, methods: { - setModule(id,data) { + setModule(id, data) { this.currentScenario.apiScenarioModuleId = id; this.currentScenario.modulePath = data.path; }, @@ -1250,4 +1257,14 @@ font-size: 18px; } + .scenario-name { + display: inline-block; + margin: 0 5px; + overflow-x: hidden; + padding-bottom: 0; + text-overflow: ellipsis; + vertical-align: middle; + white-space: nowrap; + width: 200px; + } diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index 98897767fe..22f83ec111 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -64,7 +64,7 @@
-
diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 659458f6cb..3abdc02222 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -302,6 +302,9 @@ api.moduleId = this.nodeTree[0].id; api.modulePath = this.nodeTree[0].path; } + if (this.selectNodeIds && this.selectNodeIds.length > 0) { + api.moduleId = this.selectNodeIds[0]; + } this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api); }, handleTabClose() { diff --git a/frontend/src/business/components/api/definition/components/assertion/ApiJsonPathSuggestButton.vue b/frontend/src/business/components/api/definition/components/assertion/ApiJsonPathSuggestButton.vue index f708459ab3..5bb93b7bef 100644 --- a/frontend/src/business/components/api/definition/components/assertion/ApiJsonPathSuggestButton.vue +++ b/frontend/src/business/components/api/definition/components/assertion/ApiJsonPathSuggestButton.vue @@ -1,6 +1,6 @@