fix: 修复开源版编译报错
This commit is contained in:
parent
e086e352bc
commit
54fc921bd5
|
@ -19,7 +19,6 @@ import io.metersphere.jmeter.utils.ScriptEngineUtils;
|
|||
import io.metersphere.plugin.core.MsParameter;
|
||||
import io.metersphere.plugin.core.MsTestElement;
|
||||
import io.metersphere.track.service.TestPlanApiCaseService;
|
||||
import io.metersphere.xpack.ui.impl.CommandConfig;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -37,7 +36,7 @@ public class ParameterConfig extends MsParameter {
|
|||
/**
|
||||
* UI 指令全局配置
|
||||
*/
|
||||
private CommandConfig commandConfig;
|
||||
private Object commandConfig;
|
||||
/**
|
||||
* 缓存同一批请求的认证信息
|
||||
*/
|
||||
|
|
|
@ -27,7 +27,6 @@ import io.metersphere.dto.RunModeConfigDTO;
|
|||
import io.metersphere.plugin.core.MsTestElement;
|
||||
import io.metersphere.service.EnvironmentGroupProjectService;
|
||||
import io.metersphere.vo.BooleanPool;
|
||||
import io.metersphere.xpack.ui.hashtree.MsUiScenario;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
|
@ -72,36 +71,6 @@ public class GenerateHashTreeUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static MsUiScenario parseUiScenario(String scenarioDefinition) {
|
||||
MsUiScenario msUiScenario = JSONObject.parseObject(scenarioDefinition, MsUiScenario.class);
|
||||
parseUiScenario(scenarioDefinition, msUiScenario);
|
||||
return msUiScenario;
|
||||
}
|
||||
|
||||
public static void parseUiScenario(String scenarioDefinition, MsUiScenario scenario) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
try {
|
||||
JSONObject element = JSON.parseObject(scenarioDefinition);
|
||||
ElementUtil.dataFormatting(element);
|
||||
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
||||
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
||||
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
|
||||
new TypeReference<LinkedList<MsTestElement>>() {
|
||||
});
|
||||
scenario.setHashTree(elements);
|
||||
}
|
||||
if (element != null && StringUtils.isNotEmpty(element.getString("variables"))) {
|
||||
LinkedList<ScenarioVariable> variables = mapper.readValue(element.getString("variables"),
|
||||
new TypeReference<LinkedList<ScenarioVariable>>() {
|
||||
});
|
||||
scenario.setVariables(variables);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static LinkedList<MsTestElement> getScenarioHashTree(String definition) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
package com.test;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.Application;
|
||||
import io.metersphere.xpack.ui.dto.SideDTO;
|
||||
import io.metersphere.xpack.ui.impl.CommandConfig;
|
||||
import io.metersphere.xpack.ui.service.UiAutomationService;
|
||||
import io.metersphere.xpack.ui.util.TemplateUtils;
|
||||
import io.metersphere.xpack.ui.util.WebDriverSamplerHelper;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
/**
|
||||
* UI 相关单元测试
|
||||
*/
|
||||
public class UITest {
|
||||
|
||||
@Resource
|
||||
private UiAutomationService uiAutomationService;
|
||||
|
||||
/**
|
||||
* 测试脚本转换是否正常
|
||||
*/
|
||||
@Test
|
||||
public void testWebdriverScript() {
|
||||
// 获取由 SELENIUM IDE 导出的 json 文件地址
|
||||
String sidePath = this.getClass().getClassLoader().getResource("selenium-example/baidu.side").getPath();
|
||||
// 读取文件内容
|
||||
String sideDefinition = TemplateUtils.readContent(sidePath);
|
||||
// 将 json 字符串转化成 SideDTO 对象,再调用 getFullWebDriverScript 方法翻译成最终的 webdriver 脚本
|
||||
// 全局脚本配置
|
||||
CommandConfig globalConfig = new CommandConfig();
|
||||
globalConfig.setSecondsWaitWindowOnLoad(10);
|
||||
String str = WebDriverSamplerHelper.getFullWebDriverScript(JSONObject.parseObject(sideDefinition, SideDTO.class), globalConfig);
|
||||
System.out.println(str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUIRun() {
|
||||
uiAutomationService.run("");
|
||||
try {
|
||||
Thread.sleep(1000 * 60 * 5);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue