Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
kt-keystone
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
kt-keystone
Commits
e3717b47
提交
e3717b47
authored
3月 22, 2022
作者:
Matrix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(base): 重新配置了映射路径
上级
e344839e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
53 行增加
和
13 行删除
+53
-13
MoveActuator.java
...src/main/java/org/matrix/actuators/move/MoveActuator.java
+41
-9
MoveStrategy.java
...src/main/java/org/matrix/actuators/move/MoveStrategy.java
+10
-3
ResourcesConfig.java
...main/java/org/matrix/autotest/config/ResourcesConfig.java
+2
-1
没有找到文件。
kt-base/src/main/java/org/matrix/actuators/move/MoveActuator.java
浏览文件 @
e3717b47
...
...
@@ -13,10 +13,13 @@ import org.matrix.actuators.sql.SqlExpDetail;
import
org.matrix.actuators.usecase.CaseActuator
;
import
org.matrix.actuators.util.CompleteExpressionUtil
;
import
org.matrix.database.entity.Action
;
import
org.matrix.database.entity.Move
;
import
org.matrix.database.entity.TestCaseBTO
;
import
org.matrix.database.service.IMoveService
;
import
org.matrix.database.service.ITestDataService
;
import
org.matrix.database.service.impl.ActionServiceImpl
;
import
org.matrix.enums.ActionType
;
import
org.matrix.enums.MoveType
;
import
org.matrix.exception.GlobalException
;
import
org.matrix.socket.queue.LogQueueRuntime
;
import
org.matrix.util.BeanFlattener
;
...
...
@@ -55,6 +58,7 @@ public class MoveActuator implements Actuator {
private
final
SqlExpActuator
sqlExpActuator
;
private
final
HttpClientActuator
httpActuator
;
private
final
ITestDataService
dataService
;
private
final
IMoveService
moveService
;
private
final
CaseActuator
caseActuator
;
private
final
CompleteExpressionUtil
expressionUtil
;
/**
...
...
@@ -62,12 +66,13 @@ public class MoveActuator implements Actuator {
*/
private
ThreadLocal
<
Map
<
String
,
List
<
Map
<
String
,
Object
>>>>
resSet
=
ThreadLocal
.
withInitial
(
HashMap:
:
new
);
public
MoveActuator
(
CompleteExpressionUtil
resultUtil
,
ActionServiceImpl
actionService
,
SqlExpActuator
sqlExpActuator
,
HttpClientActuator
httpActuator
,
ITestDataService
dataService
,
CaseActuator
caseActuator
,
CompleteExpressionUtil
expressionUtil
)
{
public
MoveActuator
(
CompleteExpressionUtil
resultUtil
,
ActionServiceImpl
actionService
,
SqlExpActuator
sqlExpActuator
,
HttpClientActuator
httpActuator
,
ITestDataService
dataService
,
IMoveService
moveService
,
CaseActuator
caseActuator
,
CompleteExpressionUtil
expressionUtil
)
{
this
.
resultUtil
=
resultUtil
;
this
.
actionService
=
actionService
;
this
.
sqlExpActuator
=
sqlExpActuator
;
this
.
httpActuator
=
httpActuator
;
this
.
dataService
=
dataService
;
this
.
moveService
=
moveService
;
this
.
caseActuator
=
caseActuator
;
this
.
expressionUtil
=
expressionUtil
;
}
...
...
@@ -135,7 +140,7 @@ public class MoveActuator implements Actuator {
if
(
pathResolution
)
{
finalValue
=
expressionUtil
.
completeJsonPathExpression
(
jsonPath
,
finalValue
);
}
LogQueueRuntime
.
addNewLog
(
this
.
getClass
(),
SYNTAX_PARSE
,
String
.
format
(
"初始语法 = %s ,解析结果 = %s"
,
dynamicString
,
finalValue
));
LogQueueRuntime
.
addNewLog
(
this
.
getClass
(),
SYNTAX_PARSE
,
String
.
format
(
"初始语法 = %s ,解析结果 = %s"
,
dynamicString
,
finalValue
));
return
finalValue
;
}
...
...
@@ -152,7 +157,11 @@ public class MoveActuator implements Actuator {
* @param caseResultData 测试用例执行后保留下的结果集,该参数在前置策略中可以为null,在中间/后置策略中必须要提供合理的结果集对象
* @param strategy 动作的策略,即是前置/中间/后置,具体查看{@link MoveStrategy}
*/
@SuppressWarnings
(
"DuplicatedCode"
)
public
void
runMove
(
Long
moveId
,
Long
envId
,
Long
projectId
,
String
caseResultData
,
MoveStrategy
strategy
)
{
Move
move
=
Optional
.
ofNullable
(
moveService
.
getById
(
moveId
))
.
orElseThrow
(()
->
new
GlobalException
(
String
.
format
(
"没有找到指定的action动作对象,提供查询的moveId = %d,envId = %d"
,
moveId
,
envId
)));
Action
action
=
actionService
.
findByMoveAndEnv
(
moveId
,
envId
)
.
orElseThrow
(()
->
new
GlobalException
(
String
.
format
(
"没有找到指定的action动作对象,提供查询的moveId = %d,envId = %d"
,
moveId
,
envId
)));
LogQueueRuntime
.
addNewLog
(
this
.
getClass
(),
MOVE_ACTUATOR
,
String
.
format
(
"准备执行行为动作,动作策略: %s,行为Id =%d ,动作id = %d"
,
strategy
,
moveId
,
action
.
getId
()));
...
...
@@ -176,26 +185,49 @@ public class MoveActuator implements Actuator {
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
res
=
resSet
.
get
();
// 分类处理 + 结果集处理(如果不存在则put数据,如果存在则替换数据)
LogQueueRuntime
.
addNewLog
(
this
.
getClass
(),
MOVE_ACTUATOR
,
String
.
format
(
"正在执行动作 actionId = %d,动作类型 = %s,动作策略 = %s,动作参数 = %s"
,
action
.
getId
(),
action
,
strategy
,
runtimeDetail
));
LogQueueRuntime
.
addNewLog
(
this
.
getClass
(),
MOVE_ACTUATOR
,
String
.
format
(
"正在执行动作 actionId = %d,动作类型 = %s,动作策略 = %s,动作参数 = %s"
,
action
.
getId
(),
action
,
strategy
,
runtimeDetail
));
if
(
actionType
==
SQL_ACTION
)
{
List
<
Map
<
String
,
Object
>>
resultMap
=
sqlActionHandler
(
envId
,
projectId
,
runtimeDetail
);
res
.
put
(
key
,
resultMap
);
}
else
if
(
actionType
==
HTTP_ACTION
)
{
res
.
put
(
key
,
Lists
.
newArrayList
(
detail2Map
(
httpActionHandler
(
envId
,
projectId
,
runtimeDetail
))));
HttpResponseDetail
detail
=
httpActionHandler
(
envId
,
projectId
,
runtimeDetail
);
Map
<
String
,
Object
>
detailMap
=
detail2Map
(
detail
);
moveTypeHandler
(
strategy
,
move
,
detail
,
detailMap
);
res
.
put
(
key
,
Lists
.
newArrayList
(
detailMap
));
}
else
if
(
actionType
==
CASE_ACTION
)
{
res
.
put
(
key
,
Lists
.
newArrayList
(
detail2Map
(
caseActionHandler
(
envId
,
projectId
,
runtimeDetail
))));
HttpResponseDetail
detail
=
caseActionHandler
(
envId
,
projectId
,
runtimeDetail
);
Map
<
String
,
Object
>
detailMap
=
detail2Map
(
detail
);
moveTypeHandler
(
strategy
,
move
,
detail
,
detailMap
);
res
.
put
(
key
,
Lists
.
newArrayList
(
detailMap
));
}
else
if
(
actionType
==
WAIT_ACTION
)
{
waitActionHandler
(
runtimeDetail
);
}
else
{
throw
new
GlobalException
(
"[行为执行器]不支持的行为类型: "
+
actionType
);
}
// 如果动作类型时登录且是前置动作,设置COOKIE到变量池中
LogQueueRuntime
.
addNewLog
(
getClass
(),
MOVE_ACTUATOR
,
String
.
format
(
"当前执行的行为策略 = %s, 行为名 = %s, 动作名 = %s , 动作id = %d , 动作池里的变量 = %s"
,
strategy
.
getDes
(),
move
.
getName
(),
action
.
getName
(),
action
.
getId
(),
res
));
log
.
info
(
"[动作执行器] 动作执行完毕"
);
}
/**
* 依据行为的动作类型来决定操作逻辑
*
* @param strategy 行为策略
* @param move 行为
* @param detail 动作执行后的返回值对象
* @param detailMap 用于存放到动作结果池里的Map
*/
private
void
moveTypeHandler
(
MoveStrategy
strategy
,
Move
move
,
HttpResponseDetail
detail
,
Map
<
String
,
Object
>
detailMap
)
{
if
(
strategy
==
PRE_MOVE
&&
move
.
getMoveType
()
==
MoveType
.
LOGIN
)
{
Arrays
.
stream
(
detail
.
getResponse
().
getHeaders
(
"SET_COOKIE"
))
.
filter
(
header
->
header
.
getValue
().
contains
(
"JSESSIONID"
))
.
findFirst
()
.
ifPresent
(
session
->
detailMap
.
put
(
"SESSION_ID"
,
session
));
}
}
/**
* 清理结果集
*/
...
...
@@ -242,7 +274,7 @@ public class MoveActuator implements Actuator {
throw
new
GlobalException
(
"[行为执行器]行为语法里定位部分的语法没有提供合适的actionId!例如需要提供pre1,pre2,您提供的部分是: "
+
col
);
}
String
key
=
strategy
+
"_"
+
actionId
;
LogQueueRuntime
.
addNewLog
(
this
.
getClass
(),
MOVE_ACTUATOR
,
"KEY值拼接完成,KEY值 = "
+
key
);
LogQueueRuntime
.
addNewLog
(
this
.
getClass
(),
MOVE_ACTUATOR
,
"KEY值拼接完成,KEY值 = "
+
key
);
return
new
MoveRegularObject
(
key
,
colArray
[
1
]);
}
...
...
kt-base/src/main/java/org/matrix/actuators/move/MoveStrategy.java
浏览文件 @
e3717b47
package
org
.
matrix
.
actuators
.
move
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* MoveStrategy.
*
...
...
@@ -7,18 +10,22 @@ package org.matrix.actuators.move;
* @since 2022/3/7 at 3:11 PM
* Suffering is the most powerful teacher of life.
*/
@AllArgsConstructor
@Getter
public
enum
MoveStrategy
{
/**
* 前置动作
*/
PRE_MOVE
,
PRE_MOVE
(
"前置动作"
)
,
/**
* 中间动作
*/
MID_MOVE
,
MID_MOVE
(
"中间动作"
)
,
/**
* 后置动作
*/
AFT_MOVE
;
AFT_MOVE
(
"后置动作"
);
private
final
String
des
;
}
kt-web/src/main/java/org/matrix/autotest/config/ResourcesConfig.java
浏览文件 @
e3717b47
...
...
@@ -15,7 +15,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
public
class
ResourcesConfig
implements
WebMvcConfigurer
{
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
//localhost:8765/res/css/bootstrap.css
String
fileUrl
=
"file:"
+
System
.
getProperty
(
"user.dir"
)
+
"/htmls/"
;
registry
.
addResourceHandler
(
"/**"
).
addResourceLocations
(
fileUrl
);
registry
.
addResourceHandler
(
"/
res/
**"
).
addResourceLocations
(
fileUrl
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论