refactor(系统设置): 完善插件测试用例

This commit is contained in:
AgAngle 2023-10-18 19:41:25 +08:00 committed by jianxing
parent 848d817e60
commit abbb7fc4d8
10 changed files with 16 additions and 16 deletions

View File

@ -185,6 +185,7 @@ plugin.exist=插件名称或文件名已存在
plugin.type.exist=插件类型已存在 plugin.type.exist=插件类型已存在
plugin.script.exist=脚本id重复 plugin.script.exist=脚本id重复
plugin.script.format=脚本格式错误 plugin.script.format=脚本格式错误
plugin.parse.error=插件解析失败
# serviceIntegration # serviceIntegration
service_integration.id.not_blank=ID不能为空 service_integration.id.not_blank=ID不能为空
service_integration.id.length_range=ID长度必须在{min}和{max}之间 service_integration.id.length_range=ID长度必须在{min}和{max}之间

View File

@ -188,6 +188,7 @@ plugin.exist=plugin name or filename already exists
plugin.type.exist=plugin type already exists plugin.type.exist=plugin type already exists
plugin.script.exist=duplicate script id plugin.script.exist=duplicate script id
plugin.script.format=malformed script plugin.script.format=malformed script
plugin.parse.error=plugin parsing failed
# serviceIntegration # serviceIntegration
service_integration.id.not_blank=id cannot be empty service_integration.id.not_blank=id cannot be empty
service_integration.id.length_range=id length must be between {min} and {max} service_integration.id.length_range=id length must be between {min} and {max}

View File

@ -187,6 +187,7 @@ plugin.exist=插件名称或文件名已存在
plugin.type.exist=插件类型已存在 plugin.type.exist=插件类型已存在
plugin.script.exist=脚本id重复 plugin.script.exist=脚本id重复
plugin.script.format=脚本格式错误 plugin.script.format=脚本格式错误
plugin.parse.error=插件解析失败
# serviceIntegration # serviceIntegration
service_integration.id.not_blank=ID不能为空 service_integration.id.not_blank=ID不能为空
service_integration.id.length_range=ID长度必须在{min}和{max}之间 service_integration.id.length_range=ID长度必须在{min}和{max}之间

View File

@ -187,6 +187,7 @@ plugin.exist=插件名稱或文件名已存在
plugin.type.exist=插件類型已存在 plugin.type.exist=插件類型已存在
plugin.script.exist=腳本id重複 plugin.script.exist=腳本id重複
plugin.script.format=腳本格式錯誤 plugin.script.format=腳本格式錯誤
plugin.parse.error=插件解析失敗
# serviceIntegration # serviceIntegration
service_integration.id.not_blank=ID不能為空 service_integration.id.not_blank=ID不能為空
service_integration.id.length_range=ID長度必須在{min}和{max}之間 service_integration.id.length_range=ID長度必須在{min}和{max}之間

View File

@ -27,7 +27,8 @@ public enum SystemResultCode implements IResultCode {
PLUGIN_SCRIPT_EXIST(101010, "plugin.script.exist"), PLUGIN_SCRIPT_EXIST(101010, "plugin.script.exist"),
PLUGIN_SCRIPT_FORMAT(101011, "plugin.script.format"), PLUGIN_SCRIPT_FORMAT(101011, "plugin.script.format"),
NO_PROJECT_USER_ROLE_PERMISSION(101012, "project_user_role_permission_error"), NO_PROJECT_USER_ROLE_PERMISSION(101012, "project_user_role_permission_error"),
NO_GLOBAL_USER_ROLE_PERMISSION(101013, "no_global_user_role_permission_error"); NO_GLOBAL_USER_ROLE_PERMISSION(101013, "no_global_user_role_permission_error"),
PLUGIN_PARSE_ERROR(101014, "plugin.parse.error");
private final int code; private final int code;
private final String message; private final String message;

View File

@ -38,6 +38,7 @@ import java.sql.Driver;
import java.util.*; import java.util.*;
import static io.metersphere.system.controller.result.SystemResultCode.PLUGIN_EXIST; import static io.metersphere.system.controller.result.SystemResultCode.PLUGIN_EXIST;
import static io.metersphere.system.controller.result.SystemResultCode.PLUGIN_PARSE_ERROR;
/** /**
* @author jianxing * @author jianxing
@ -142,7 +143,10 @@ public class PluginService {
// 删除插件 // 删除插件
pluginLoadService.unloadPlugin(id); pluginLoadService.unloadPlugin(id);
pluginLoadService.deletePluginFile(file.getOriginalFilename()); pluginLoadService.deletePluginFile(file.getOriginalFilename());
throw e; if (e instanceof MSException) {
throw e;
}
throw new MSException(PLUGIN_PARSE_ERROR, e);
} }
return plugin; return plugin;
} }

View File

@ -287,8 +287,7 @@ public class OrganizationCustomFieldControllerTests extends BaseTest {
List<CustomField> refFields = organizationCustomFieldService.getByRefId(customField.getId()); List<CustomField> refFields = organizationCustomFieldService.getByRefId(customField.getId());
List<Project> orgProjects = getProjectByOrgId(customField.getScopeId()); List<Project> orgProjects = getProjectByOrgId(customField.getScopeId());
// 校验所有项目下是否都有同步变更 // 校验所有项目下是否都有同步变更
/* Assertions.assertEquals(getCustomFieldByScopeId(customField.getScopeId()).size(), Assertions.assertEquals(refFields.size(), orgProjects.size());
getCustomFieldByScopeId(orgProjects.get(0).getId()).size() * orgProjects.size());*/
refFields.forEach(refField -> { refFields.forEach(refField -> {
Assertions.assertEquals(refField.getScene(), customField.getScene()); Assertions.assertEquals(refField.getScene(), customField.getScene());
Assertions.assertEquals(refField.getRemark(), customField.getRemark()); Assertions.assertEquals(refField.getRemark(), customField.getRemark());
@ -306,12 +305,6 @@ public class OrganizationCustomFieldControllerTests extends BaseTest {
return projectMapper.selectByExample(projectExample); return projectMapper.selectByExample(projectExample);
} }
private List<CustomField> getCustomFieldByScopeId(String scopeId) {
CustomFieldExample example = new CustomFieldExample();
example.createCriteria().andScopeIdEqualTo(scopeId);
return customFieldMapper.selectByExample(example);
}
private void changeOrgTemplateEnable(boolean enable) { private void changeOrgTemplateEnable(boolean enable) {
if (enable) { if (enable) {
organizationParameterMapper.deleteByPrimaryKey(DEFAULT_ORGANIZATION_ID, OrganizationParameterConstants.ORGANIZATION_FUNCTIONAL_TEMPLATE_ENABLE_KEY); organizationParameterMapper.deleteByPrimaryKey(DEFAULT_ORGANIZATION_ID, OrganizationParameterConstants.ORGANIZATION_FUNCTIONAL_TEMPLATE_ENABLE_KEY);

View File

@ -149,22 +149,20 @@ public class PluginControllerTests extends BaseTest {
// @@校验插件脚本解析失败 // @@校验插件脚本解析失败
// TODO 缺少有效jar包 File scriptParseFile = new File(
/* File scriptParseFile = new File(
this.getClass().getClassLoader().getResource("file/metersphere-plugin-script-parse-error.jar") this.getClass().getClassLoader().getResource("file/metersphere-plugin-script-parse-error.jar")
.getPath() .getPath()
); );
assertErrorCode(this.requestMultipart(DEFAULT_ADD, assertErrorCode(this.requestMultipart(DEFAULT_ADD,
getDefaultMultiPartParam(request, scriptParseFile)), PLUGIN_SCRIPT_FORMAT);*/ getDefaultMultiPartParam(request, scriptParseFile)), PLUGIN_SCRIPT_FORMAT);
// @@校验插件脚本ID重复 // @@校验插件脚本ID重复
// TODO 缺少有效jar包 File scriptIdRepeatFile = new File(
/* File scriptIdRepeatFile = new File(
this.getClass().getClassLoader().getResource("file/metersphere-plugin-script-id-repeat-error.jar") this.getClass().getClassLoader().getResource("file/metersphere-plugin-script-id-repeat-error.jar")
.getPath() .getPath()
); );
assertErrorCode(this.requestMultipart(DEFAULT_ADD, assertErrorCode(this.requestMultipart(DEFAULT_ADD,
getDefaultMultiPartParam(request, scriptIdRepeatFile)), PLUGIN_SCRIPT_EXIST); // @@校验插件脚本ID重复*/ getDefaultMultiPartParam(request, scriptIdRepeatFile)), PLUGIN_SCRIPT_EXIST); // @@校验插件脚本ID重复
// @@校验日志 // @@校验日志
checkLog(this.addPlugin.getId(), OperationLogType.ADD); checkLog(this.addPlugin.getId(), OperationLogType.ADD);