build: JMeter hashTree 升级处理

This commit is contained in:
fit2-zhao 2023-06-25 15:01:35 +08:00 committed by fit2-zhao
parent 8603b1cc2c
commit 99c0b4a0a7
2 changed files with 0 additions and 1134 deletions

View File

@ -2,16 +2,10 @@ package io.metersphere.plugin.api.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.metersphere.plugin.util.PluginLogUtils;
import lombok.Data;
import org.apache.jmeter.save.SaveService;
import org.apache.jorphan.collections.HashTree;
import org.apache.jorphan.collections.ListedHashTree;
import java.io.ByteArrayOutputStream;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
@Data
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@ -40,39 +34,6 @@ public abstract class TestElementDTO implements Serializable {
// 父类
private TestElementDTO parent;
/**
* 公共环境逐层传递如果自身有环境 以自身引用环境为准否则以公共环境作为请求环境
*/
public void toHashTree(HashTree tree, List<TestElementDTO> hashTree, BaseConfigDTO config) {
if (hashTree != null && !hashTree.isEmpty()) {
for (TestElementDTO el : hashTree) {
el.toHashTree(tree, el.hashTree, config);
}
}
}
/**
* 转换JMX
*
* @param hashTree
* @return
*/
public String getJmx(HashTree hashTree) {
try (ByteArrayOutputStream bas = new ByteArrayOutputStream()) {
SaveService.saveTree(hashTree, bas);
return bas.toString();
} catch (Exception e) {
PluginLogUtils.error("HashTree error, can't log jmx scenarioDefinition");
}
return null;
}
public HashTree generateHashTree(BaseConfigDTO config) {
HashTree jmeterTestPlanHashTree = new ListedHashTree();
this.toHashTree(jmeterTestPlanHashTree, this.hashTree, config);
return jmeterTestPlanHashTree;
}
}