提交 1f5c07a4 authored 作者: 黄夏豪's avatar 黄夏豪

fix(base): 修了一些小问题

上级 6952c6a0
......@@ -152,7 +152,7 @@ public class HttpClientActuator implements Actuator {
if (!StringUtils.isEmpty(httpRequestDetail.getStringValue())){
LogQueueRuntime.addNewLog(this.getClass(), HTTP_ACTUATOR, String.format("[HTTP执行器] 本次发送请求参数: %s", JsonUtil.toJsonPretty(httpRequestDetail.getStringValue())));
}else if (httpRequestDetail.getRequestBodies()!=null&&httpRequestDetail.getRequestBodies().size()>0){
LogQueueRuntime.addNewLog(this.getClass(), HTTP_ACTUATOR, String.format("[HTTP执行器] 本次发送请求参数: %s", JsonFormatUtil.formatJson(JSONObject.toJSONString(httpRequestDetail.getRequestBodies()))));
LogQueueRuntime.addNewLog(this.getClass(), HTTP_ACTUATOR, String.format("[HTTP执行器] 本次发送请求参数: %s", JsonUtil.toJsonPretty(httpRequestDetail.getRequestBodies())));
}else {
LogQueueRuntime.addNewLog(this.getClass(), HTTP_ACTUATOR, String.format("[HTTP执行器] 本次发送请求无参数"));
}
......
......@@ -25,6 +25,7 @@ import org.matrix.exception.GlobalException;
import org.matrix.socket.queue.LogQueueRuntime;
import org.matrix.util.BeanFlattener;
import org.matrix.util.JsonFormatUtil;
import org.matrix.util.JsonUtil;
import org.springframework.stereotype.Component;
import java.util.*;
......@@ -210,7 +211,7 @@ public class MoveActuator implements Actuator {
LogQueueRuntime.addNewLog(getClass(),MOVE_ACTUATOR, String.format(
"当前执行的行为策略 = %s, 行为名 = %s, 动作名 = %s , 动作id = %d , 动作池里的变量 = %s",
strategy.getDes(),move.getName(),action.getName(),action.getId(), JsonFormatUtil.formatJson(JSONObject.toJSONString(res))));
strategy.getDes(),move.getName(),action.getName(),action.getId(), JsonUtil.toJsonPretty(res)));
log.info("[动作执行器] 动作执行完毕");
}
......
......@@ -29,9 +29,8 @@ import org.matrix.socket.queue.LogQueueRuntime;
import org.matrix.socket.vo.CaseExecuteVo;
import org.matrix.socket.vo.SocketResponseMessage;
import org.matrix.socket.vo.TestExecuteLog;
import org.matrix.util.JsonFormatUtil;
import org.matrix.util.JsonUtil;
import org.matrix.util.SpringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
......@@ -51,7 +50,7 @@ import static org.matrix.enums.ModuleType.HTTP_ACTUATOR;
@Component
public class CaseActuator implements Actuator {
@Autowired
final
HttpRequestConfig httpRequestConfig;
final
......@@ -63,16 +62,15 @@ public class CaseActuator implements Actuator {
private final IExecutionHistoryService executionHistoryService;
private final String baseJsPath = "syntaxCheck.js";
private final ExecutionStatusMonitorSocketHandler executionStatusMonitorSocketHandler;
public CaseActuator(CheckPointActuator checkPointActuator, HttpClientActuator httpClientActuator, IExecutionHistoryService executionHistoryService, ExecutionStatusMonitorSocketHandler executionStatusMonitorSocketHandler, IDataSourceService dataSourceService) {
public CaseActuator(CheckPointActuator checkPointActuator, HttpClientActuator httpClientActuator, IExecutionHistoryService executionHistoryService, ExecutionStatusMonitorSocketHandler executionStatusMonitorSocketHandler, IDataSourceService dataSourceService, HttpRequestConfig httpRequestConfig) {
this.checkPointActuator = checkPointActuator;
this.httpClientActuator = httpClientActuator;
this.executionHistoryService = executionHistoryService;
this.executionStatusMonitorSocketHandler = executionStatusMonitorSocketHandler;
this.dataSourceService = dataSourceService;
this.httpRequestConfig = httpRequestConfig;
}
......@@ -97,7 +95,7 @@ public class CaseActuator implements Actuator {
testCaseBto.getTestData());
//执行中置动作
executeMove(testCaseBto.getTestCase().getMoveAfterTest()
, envId, projectId, baseTestCaseResponseDetail != null ? baseTestCaseResponseDetail.getResponseBody() : null, MoveStrategy.MID_MOVE);
, envId, projectId, baseTestCaseResponseDetail.getResponseBody(), MoveStrategy.MID_MOVE);
//进行检验
CheckPointResult checkPointResult = getCheckPointResult(testCaseBto.getTestCase(),
testCaseBto.getTestData(),
......@@ -106,7 +104,7 @@ public class CaseActuator implements Actuator {
baseTestCaseResponseDetail);
//执行后置动作
executeMove(testCaseBto.getTestCase().getMoveAfterCase()
, envId, projectId, baseTestCaseResponseDetail != null ? baseTestCaseResponseDetail.getResponseBody() : null, MoveStrategy.AFT_MOVE);
, envId, projectId, baseTestCaseResponseDetail.getResponseBody(), MoveStrategy.AFT_MOVE);
TestDataExecuteResult testDataExecuteResult = new TestDataExecuteResult(
dataStartTime,
LocalDateTime.now(),
......@@ -115,7 +113,7 @@ public class CaseActuator implements Actuator {
testCaseBto.getTestData().getId(),
baseTestCaseResponseDetail,
checkPointResult);
LogQueueRuntime.addNewLog(this.getClass(), CASE_ACTUATOR, JSON.toJSONString(testDataExecuteResult));
LogQueueRuntime.addNewLog(this.getClass(), CASE_ACTUATOR, "[用例执行器] 本次用例执行结果" + JsonUtil.toJsonPretty(testDataExecuteResult));
return testDataExecuteResult;
}
......@@ -148,7 +146,7 @@ public class CaseActuator implements Actuator {
LogQueueRuntime.addNewLog(this.getClass(), CASE_ACTUATOR, "[用例执行器] 即将开始执行中置动作");
//执行中置动作
executeMove(testCaseBto.getTestCase().getMoveAfterTest()
, envId, projectId, baseTestCaseResponseDetail != null ? baseTestCaseResponseDetail.getResponseBody() : null, MoveStrategy.MID_MOVE);
, envId, projectId, baseTestCaseResponseDetail.getResponseBody(), MoveStrategy.MID_MOVE);
CheckPointResult checkPointResult = getCheckPointResult(testCaseBto.getTestCase(),
testData,
envId,
......@@ -164,10 +162,10 @@ public class CaseActuator implements Actuator {
checkPointResult
);
resultList.add(testDataExecuteResult);
LogQueueRuntime.addNewLog(this.getClass(), CASE_ACTUATOR, "[用例执行器] 用例执行结果:" + JsonFormatUtil.formatJson(JSONObject.toJSONString(testDataExecuteResult)));
LogQueueRuntime.addNewLog(this.getClass(), CASE_ACTUATOR, "[用例执行器] 用例执行结果:" + JsonUtil.toJsonPretty(testDataExecuteResult));
//执行后置动作
executeMove(testCaseBto.getTestCase().getMoveAfterCase()
, envId, projectId, baseTestCaseResponseDetail != null ? baseTestCaseResponseDetail.getResponseBody() : null, MoveStrategy.AFT_MOVE);
, envId, projectId, baseTestCaseResponseDetail.getResponseBody(), MoveStrategy.AFT_MOVE);
changeExecutionHistoryStatus(ExecutionHistoryStatus.FINISH);
} catch (Exception e) {
dataSourceService.switchMainDataSource();
......@@ -247,11 +245,11 @@ public class CaseActuator implements Actuator {
/**
* 根据Case的Detail进行Case的核心部分执行
*
* @param envId
* @param projectId
* @param testCase
* @param testData
* @return
* @param envId 环境ID
* @param projectId 项目ID
* @param testCase 测试用例
* @param testData 测试数据
* @return 执行后的返回值
*/
private HttpResponseDetail executionCaseDetail(
Long envId, Long projectId, TestCase testCase, TestData testData) {
......@@ -265,9 +263,9 @@ public class CaseActuator implements Actuator {
HttpResponseDetail httpResponseDetail = httpClientActuator.sendHttpRequest(httpRequestDetail, envId, projectId);
String responseBody = httpResponseDetail.getResponseBody();
if (StringUtils.isEmpty(responseBody)){
LogQueueRuntime.addNewLog(this.getClass(), HTTP_ACTUATOR, String.format("[HTTP执行器] 本次请求结果为空"));
LogQueueRuntime.addNewLog(this.getClass(), HTTP_ACTUATOR, "[HTTP执行器] 本次请求结果为空");
}else {
LogQueueRuntime.addNewLog(this.getClass(), HTTP_ACTUATOR, String.format("[HTTP执行器] 本次请求结果:%s",JsonFormatUtil.formatJson(responseBody)));
LogQueueRuntime.addNewLog(this.getClass(), HTTP_ACTUATOR, String.format("[HTTP执行器] 本次请求结果:%s",JsonUtil.toJsonPretty(responseBody)));
}
return httpResponseDetail;
......@@ -317,7 +315,7 @@ public class CaseActuator implements Actuator {
}
}
Boolean hasInit = false;
boolean hasInit = false;
for (TestCaseListDataBto testCaseListDataBto : testCaseListDataBtoList) {
LocalDateTime caseStartTime = LocalDateTime.now();
try {
......@@ -368,7 +366,7 @@ public class CaseActuator implements Actuator {
LocalDateTime.now(),
testCaseListDataBto.getTestCase().getId(),
testCaseListDataBto.getTestCase().getName(),
TestCaseTypeEnum.getTypeByValue(testCaseListDataBto.getTestCase().getType()).toString(),
Objects.requireNonNull(TestCaseTypeEnum.getTypeByValue(testCaseListDataBto.getTestCase().getType())).toString(),
testCaseListDataBto.getTestCase().getDetail(),
testCaseListDataBto.getTestCase().getDes(),
testCaseListDataBto.getTestCase().getMoveBefore(),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论