refactor(接口测试): 优化插件加载过滤掉非api使用的插件
This commit is contained in:
parent
2ffb2fa6db
commit
ca40ec1332
|
@ -23,6 +23,7 @@ import io.metersphere.commons.utils.GenerateHashTreeUtil;
|
|||
import io.metersphere.utils.LoggerUtil;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -204,12 +205,11 @@ public class ApiJMeterFileService {
|
|||
new TreeSet<>(Comparator.comparing(Plugin::getPluginId))), ArrayList::new));
|
||||
plugins.forEach(item -> {
|
||||
File file = new File(item.getSourcePath());
|
||||
if (file.isDirectory() && !item.getSourcePath().endsWith("/")) {
|
||||
file = new File(item.getSourcePath() + "/");
|
||||
}
|
||||
byte[] fileByte = FileUtils.fileToByte(file);
|
||||
if (fileByte != null) {
|
||||
jarFiles.put(file.getName(), fileByte);
|
||||
if (file.exists() && !file.isDirectory()) {
|
||||
byte[] fileByte = FileUtils.fileToByte(file);
|
||||
if (ArrayUtils.isNotEmpty(fileByte)) {
|
||||
jarFiles.put(file.getName(), fileByte);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ public class PluginService {
|
|||
List<PluginDTO> lists = new LinkedList<>();
|
||||
try {
|
||||
PluginExample example = new PluginExample();
|
||||
example.createCriteria().andScenarioEqualTo(PluginScenario.api.name());
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
name = "%" + name + "%";
|
||||
example.createCriteria().andNameLike(name);
|
||||
|
@ -158,6 +159,7 @@ public class PluginService {
|
|||
|
||||
public List<Plugin> list() {
|
||||
PluginExample example = new PluginExample();
|
||||
example.createCriteria().andScenarioEqualTo(PluginScenario.api.name());
|
||||
List<Plugin> plugins = pluginMapper.selectByExample(example);
|
||||
return plugins;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue