Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
kt-keystone
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
kt-keystone
Commits
2e684750
提交
2e684750
authored
1月 14, 2022
作者:
黄夏豪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(base): 补充了baseJS
上级
98d885aa
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
124 行增加
和
1 行删除
+124
-1
CheckPointUtil.java
kt-base/src/main/java/org/matrix/util/CheckPointUtil.java
+1
-1
baseJS.js
kt-base/src/main/resources/baseJS.js
+123
-0
没有找到文件。
kt-base/src/main/java/org/matrix/util/CheckPointUtil.java
浏览文件 @
2e684750
...
@@ -161,7 +161,7 @@ public class CheckPointUtil {
...
@@ -161,7 +161,7 @@ public class CheckPointUtil {
"}"
;
"}"
;
Object
jsonObject
=
Configuration
.
defaultConfiguration
().
jsonProvider
().
parse
(
json
);
Object
jsonObject
=
Configuration
.
defaultConfiguration
().
jsonProvider
().
parse
(
json
);
CheckPointUtil
checkPointUtil
=
new
CheckPointUtil
(
"
test
.js"
);
CheckPointUtil
checkPointUtil
=
new
CheckPointUtil
(
"
baseJS
.js"
);
CheckPointResultDetail
checkPointResultDetail
=
checkPointUtil
.
jsonPathCheck
(
new
JsonPathCheckPoint
(
CheckPointResultDetail
checkPointResultDetail
=
checkPointUtil
.
jsonPathCheck
(
new
JsonPathCheckPoint
(
"contains({$..className},\"一班\")"
"contains({$..className},\"一班\")"
),
),
...
...
kt-base/src/main/resources/baseJS.js
0 → 100644
浏览文件 @
2e684750
//a跟b进行比较,对象类型分为以下几种:基础类型、数组、普通对象
function
equal
(
a
,
b
)
{
var
aType
=
Object
.
prototype
.
toString
.
call
(
a
);
var
bType
=
Object
.
prototype
.
toString
.
call
(
b
);
switch
(
aType
)
{
case
"[object Array]"
:
//数组类型
switch
(
bType
)
{
case
"[object Array]"
:
return
JSON
.
stringify
(
a
)
==
JSON
.
stringify
(
b
);
default
:
for
(
var
i
=
0
;
i
<
a
.
length
;
i
++
)
{
if
(
JSON
.
stringify
(
a
[
i
])
!=
JSON
.
stringify
(
b
))
{
return
false
;
}
}
return
true
;
}
break
default
:
//基础类型和对象类型
switch
(
bType
)
{
case
"[object Array]"
:
return
equal
(
b
,
a
);
default
:
return
JSON
.
stringify
(
a
)
===
JSON
.
stringify
(
b
)
}
}
return
JSON
.
stringify
(
a
)
===
JSON
.
stringify
(
b
)
}
function
contains
(
sourceValue
,
compareValue
)
{
var
sourceValueType
=
Object
.
prototype
.
toString
.
call
(
sourceValue
);
var
compareValueType
=
Object
.
prototype
.
toString
.
call
(
compareValue
);
if
(
sourceValueType
===
"[object Object]"
)
{
for
(
var
i
=
0
;
i
<
Object
.
keys
(
sourceValue
).
length
;
i
++
)
{
var
souceKey
=
Object
.
keys
(
sourceValue
)[
i
];
if
(
equal
(
sourceValue
[
souceKey
],
compareValue
))
{
return
true
;
};
}
return
false
;
}
else
if
(
sourceValueType
==
"[object Array]"
)
{
switch
(
compareValueType
)
{
//如果数组包含的话,需要a种全包含b种的参数,例如: [1,2,3]比[1,2]为true , [1,2,3]比[1,2,3,4]为false
case
"[object Array]"
:
//如果compareValue的长度 大于 sourceValue 则一定不包含
if
(
sourceValue
.
length
<
compareValue
.
length
)
{
return
false
;
}
for
(
var
i
=
0
;
i
<
compareValue
.
length
;
i
++
)
{
var
innerFlag
=
false
;
for
(
var
j
=
0
;
j
<
sourceValue
.
length
;
j
++
)
{
if
(
JSON
.
stringify
(
compareValue
[
i
])
==
JSON
.
stringify
(
sourceValue
[
j
]))
{
innerFlag
=
true
;
break
;
}
}
if
(
!
innerFlag
)
{
return
false
;
}
}
return
true
;
case
"[object Object]"
:
for
(
var
i
=
0
;
i
<
sourceValue
.
length
;
i
++
)
{
if
(
JSON
.
stringify
(
sourceValue
[
i
])
==
JSON
.
stringify
(
compareValue
)
)
{
return
true
;
}
}
return
false
;
default
:
return
sourceValue
.
indexOf
(
compareValue
)
>
-
1
?
true
:
false
;
}
return
false
;
}
else
{
return
JSON
.
stringify
(
sourceValue
).
indexOf
(
JSON
.
stringify
(
compareValue
))
>
-
1
?
true
:
false
}
}
function
BaseEntity
(
value
)
{
this
.
type
=
Object
.
prototype
.
toString
.
call
(
value
);
if
(
this
.
type
!=
'[object Object]'
&&
this
.
type
!=
'[object Array]'
)
{
try
{
this
.
value
=
JSON
.
parse
(
value
);
this
.
type
=
Object
.
prototype
.
toString
.
call
(
this
.
value
);
}
catch
(
error
)
{
this
.
value
=
value
;
}
}
else
{
this
.
value
=
value
;
}
}
BaseEntity
.
prototype
.
get
=
function
(
key
)
{
return
this
.
value
[
key
]
}
BaseEntity
.
prototype
.
length
=
function
(
key
)
{
return
this
.
value
.
length
}
BaseEntity
.
prototype
.
contains
=
function
(
key
)
{
if
(
key
instanceof
BaseEntity
){
return
contains
(
this
.
value
,
key
.
value
)
}
else
{
return
contains
(
this
.
value
,
key
)
}
}
BaseEntity
.
prototype
.
equal
=
function
(
key
)
{
if
(
key
instanceof
BaseEntity
){
return
equal
(
this
.
value
,
key
.
value
)
}
else
{
return
equal
(
this
.
value
,
key
)
}
}
var
a
=
new
BaseEntity
(
'{"name":1,"age":2}'
);
var
b
=
new
BaseEntity
(
'{"name":1,"age":3}'
);
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论