fix(测试计划): 修复执行找不到环境问题
This commit is contained in:
parent
d34cfbd93b
commit
d2300ea5a7
|
@ -322,6 +322,7 @@ public class ApiAutomationService {
|
|||
|
||||
/**
|
||||
* 更新时如果有删除自定义请求,则删除对应body文件
|
||||
*
|
||||
* @param scenario
|
||||
*/
|
||||
public void deleteUpdateBodyFile(ApiScenarioWithBLOBs scenario) {
|
||||
|
@ -528,7 +529,8 @@ public class ApiAutomationService {
|
|||
JSONObject element = JSON.parseObject(definition);
|
||||
try {
|
||||
if (element != null) {
|
||||
return objectMapper.readValue(element.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {});
|
||||
return objectMapper.readValue(element.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {
|
||||
});
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
|
@ -839,7 +841,11 @@ public class ApiAutomationService {
|
|||
StringBuilder builder = new StringBuilder();
|
||||
for (ApiScenarioWithBLOBs apiScenarioWithBLOBs : apiScenarios) {
|
||||
try {
|
||||
boolean haveEnv = checkScenarioEnv(apiScenarioWithBLOBs);
|
||||
TestPlanApiScenario testPlanApiScenario = null;
|
||||
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(apiScenarioWithBLOBs.getId())) {
|
||||
testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(request.getScenarioTestPlanIdMap().get(apiScenarioWithBLOBs.getId()));
|
||||
}
|
||||
boolean haveEnv = checkScenarioEnv(apiScenarioWithBLOBs, testPlanApiScenario);
|
||||
if (!haveEnv) {
|
||||
builder.append(apiScenarioWithBLOBs.getName()).append("; ");
|
||||
}
|
||||
|
@ -899,7 +905,7 @@ public class ApiAutomationService {
|
|||
APIScenarioReportResult report;
|
||||
Map<String, String> planEnvMap = new HashMap<>();
|
||||
//如果是测试计划页面触发的执行方式,生成报告时createScenarioReport第二个参数需要特殊处理
|
||||
if (StringUtils.equalsAny(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(),ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
||||
if (StringUtils.equalsAny(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
||||
String testPlanScenarioId = item.getId();
|
||||
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(item.getId())) {
|
||||
testPlanScenarioId = request.getScenarioTestPlanIdMap().get(item.getId());
|
||||
|
@ -910,11 +916,11 @@ public class ApiAutomationService {
|
|||
planEnvMap = JSON.parseObject(environment, Map.class);
|
||||
}
|
||||
}
|
||||
if(request.isTestPlanScheduleJob()){
|
||||
if (request.isTestPlanScheduleJob()) {
|
||||
String savedScenarioId = testPlanScenarioId + ":" + request.getTestPlanReportId();
|
||||
report = createScenarioReport(reportId, savedScenarioId, item.getName(), request.getTriggerMode(),
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), null);
|
||||
}else{
|
||||
} else {
|
||||
report = createScenarioReport(reportId, testPlanScenarioId, item.getName(), request.getTriggerMode(),
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), null);
|
||||
}
|
||||
|
@ -1062,7 +1068,7 @@ public class ApiAutomationService {
|
|||
//如果是测试计划页面触发的执行方式,生成报告时createScenarioReport第二个参数需要特殊处理
|
||||
APIScenarioReportResult report = null;
|
||||
// if (StringUtils.equals(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) {
|
||||
if (StringUtils.equalsAny(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(),ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
||||
if (StringUtils.equalsAny(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name())) {
|
||||
String testPlanScenarioId = item.getId();
|
||||
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(item.getId())) {
|
||||
testPlanScenarioId = request.getScenarioTestPlanIdMap().get(item.getId());
|
||||
|
@ -1073,11 +1079,11 @@ public class ApiAutomationService {
|
|||
scenario.setEnvironmentMap(JSON.parseObject(environment, Map.class));
|
||||
}
|
||||
}
|
||||
if(request.isTestPlanScheduleJob()){
|
||||
if (request.isTestPlanScheduleJob()) {
|
||||
String savedScenarioId = testPlanScenarioId + ":" + request.getTestPlanReportId();
|
||||
report = createScenarioReport(group.getName(), savedScenarioId, item.getName(), request.getTriggerMode(),
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), null);
|
||||
}else{
|
||||
} else {
|
||||
report = createScenarioReport(group.getName(), testPlanScenarioId, item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(),
|
||||
request.getExecuteType(), item.getProjectId(), request.getReportUserID(), request.getConfig());
|
||||
}
|
||||
|
@ -1101,13 +1107,16 @@ public class ApiAutomationService {
|
|||
return jmeterHashTree;
|
||||
}
|
||||
|
||||
private boolean checkScenarioEnv(ApiScenarioWithBLOBs apiScenarioWithBLOBs) {
|
||||
private boolean checkScenarioEnv(ApiScenarioWithBLOBs apiScenarioWithBLOBs, TestPlanApiScenario testPlanApiScenarios) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String definition = apiScenarioWithBLOBs.getScenarioDefinition();
|
||||
MsScenario scenario = JSONObject.parseObject(definition, MsScenario.class);
|
||||
boolean isEnv = true;
|
||||
Map<String, String> envMap = scenario.getEnvironmentMap();
|
||||
if (testPlanApiScenarios != null && StringUtils.isNotEmpty(testPlanApiScenarios.getEnvironment())) {
|
||||
envMap = JSON.parseObject(testPlanApiScenarios.getEnvironment(), Map.class);
|
||||
}
|
||||
ScenarioEnv apiScenarioEnv = getApiScenarioEnv(definition);
|
||||
// 所有请求非全路径检查环境
|
||||
if (!apiScenarioEnv.getFullUrl()) {
|
||||
|
@ -1662,14 +1671,14 @@ public class ApiAutomationService {
|
|||
ApiScenrioExportJmx scenrioExportJmx = new ApiScenrioExportJmx(item.getName(), apiTestService.updateJmxString(jmx, null, true).getXml());
|
||||
//扫描需要哪些文件
|
||||
JmxInfoDTO dto = apiTestService.updateJmxString(jmx, item.getName(), true);
|
||||
if(MapUtils.isNotEmpty(dto.getAttachFiles())){
|
||||
if (MapUtils.isNotEmpty(dto.getAttachFiles())) {
|
||||
List<String> fileList = new ArrayList<>();
|
||||
for (String fileName: dto.getAttachFiles().values()) {
|
||||
if(!fileList.contains(fileName)){
|
||||
for (String fileName : dto.getAttachFiles().values()) {
|
||||
if (!fileList.contains(fileName)) {
|
||||
fileList.add(fileName);
|
||||
}
|
||||
}
|
||||
if(!fileList.isEmpty()){
|
||||
if (!fileList.isEmpty()) {
|
||||
scenrioExportJmx.setFiles(fileList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class NoticeController {
|
|||
private NoticeService noticeService;
|
||||
|
||||
@PostMapping("save/message/task")
|
||||
@MsAuditLog(module = "organization_message_settings", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#messageDetail.id)", msClass = NoticeService.class)
|
||||
@MsAuditLog(module = "organization_message_settings", type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#messageDetail.id)", msClass = NoticeService.class)
|
||||
public void saveMessage(@RequestBody MessageDetail messageDetail) {
|
||||
noticeService.saveMessageTask(messageDetail);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue