Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
937652d9
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
937652d9
编写于
9月 04, 2019
作者:
N
nancyzrh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
for assertion
上级
74ca500b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
0 deletion
+52
-0
sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/predicate/PredicateAssert.java
...re/parse/integrate/asserts/predicate/PredicateAssert.java
+29
-0
sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/jaxb/predicate/value/ExpectedPredicateCompareRightValue.java
...b/predicate/value/ExpectedPredicateCompareRightValue.java
+23
-0
未找到文件。
sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/asserts/predicate/PredicateAssert.java
浏览文件 @
937652d9
...
...
@@ -19,12 +19,23 @@ package org.apache.shardingsphere.core.parse.integrate.asserts.predicate;
import
lombok.RequiredArgsConstructor
;
import
org.apache.shardingsphere.core.parse.integrate.asserts.SQLStatementAssertMessage
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.ExpectedExpressionSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.complex.ExpectedCommonExpressionSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.complex.ExpectedSubquerySegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.simple.ExpectedLiteralExpressionSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.simple.ExpectedParamMarkerExpressionSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.predicate.ExpectedAndPredicate
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.predicate.ExpectedColumnSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.predicate.ExpectedPredicateSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.predicate.ExpectedWhereSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.predicate.value.ExpectedPredicateCompareRightValue
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.column.ColumnSegment
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.expr.ExpressionSegment
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.expr.complex.CommonExpressionSegment
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.expr.complex.ComplexExpressionSegment
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.expr.complex.SubquerySegment
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.expr.simple.LiteralExpressionSegment
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.expr.simple.ParameterMarkerExpressionSegment
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.predicate.AndPredicate
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.predicate.PredicateSegment
;
import
org.apache.shardingsphere.core.parse.sql.segment.dml.predicate.WhereSegment
;
...
...
@@ -103,7 +114,25 @@ public final class PredicateAssert {
assertThat
(
assertMessage
.
getFullAssertMessage
(
"column segment table name assertion error: "
),
actual
.
getOwner
().
isPresent
()
?
actual
.
getOwner
().
get
().
getTableName
()
:
null
,
is
(
expected
.
getOwner
().
getName
()));
}
/**
* assert expr and operation
* @param actual
* @param expected
*/
private
void
assertCompareRightValue
(
final
PredicateCompareRightValue
actual
,
final
ExpectedPredicateCompareRightValue
expected
)
{
assertThat
(
assertMessage
.
getFullAssertMessage
(
"right value operator assertion error: "
),
actual
.
getOperator
(),
is
(
expected
.
getOperator
()));
if
(
actual
.
getExpression
()
instanceof
ParameterMarkerExpressionSegment
)
{
assertThat
(
assertMessage
.
getFullAssertMessage
(
"parameter marker expression parameterMarkerindex assertion error"
),((
ParameterMarkerExpressionSegment
)
actual
.
getExpression
()).
getParameterMarkerIndex
(),
is
(
expected
.
findExpectedExpression
(
ExpectedParamMarkerExpressionSegment
.
class
).
getParameterMarkerIndex
()));
}
if
(
actual
.
getExpression
()
instanceof
CommonExpressionSegment
)
{
assertThat
(
assertMessage
.
getFullAssertMessage
(
"common expression text assertion error: "
),((
ComplexExpressionSegment
)
actual
.
getExpression
()).
getText
(),
is
(
expected
.
findExpectedExpression
(
ExpectedCommonExpressionSegment
.
class
).
getText
()));
}
if
(
actual
.
getExpression
()
instanceof
SubquerySegment
)
{
assertThat
(
assertMessage
.
getFullAssertMessage
(
"subquery segment text assertion error: "
),((
ComplexExpressionSegment
)
actual
.
getExpression
()).
getText
(),
is
(
expected
.
findExpectedExpression
(
ExpectedSubquerySegment
.
class
).
getText
()));
}
if
(
actual
.
getExpression
()
instanceof
LiteralExpressionSegment
)
{
assertThat
(
assertMessage
.
getFullAssertMessage
(
"literal assertion error:"
),((
LiteralExpressionSegment
)
actual
.
getExpression
()).
getLiterals
().
toString
(),
is
(
expected
.
findExpectedExpression
(
ExpectedLiteralExpressionSegment
.
class
).
getLiterals
().
toString
()));
}
}
}
sharding-core/sharding-core-parse/sharding-core-parse-test/src/test/java/org/apache/shardingsphere/core/parse/integrate/jaxb/predicate/value/ExpectedPredicateCompareRightValue.java
浏览文件 @
937652d9
...
...
@@ -19,7 +19,9 @@ package org.apache.shardingsphere.core.parse.integrate.jaxb.predicate.value;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.ExpectedExpressionSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.complex.ExpectedCommonExpressionSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.complex.ExpectedComplexExpressionSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.complex.ExpectedSubquerySegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.simple.ExpectedLiteralExpressionSegment
;
import
org.apache.shardingsphere.core.parse.integrate.jaxb.expr.simple.ExpectedParamMarkerExpressionSegment
;
...
...
@@ -48,4 +50,25 @@ public final class ExpectedPredicateCompareRightValue implements ExpectedPredica
@XmlElement
(
name
=
"param-marker-expression"
)
private
ExpectedParamMarkerExpressionSegment
paramMarkerExpression
;
/**
* find expected expression
* @param expectedExpressionSegment
* @return expression segment
*/
public
<
T
extends
ExpectedExpressionSegment
>
T
findExpectedExpression
(
final
Class
<
T
>
expectedExpressionSegment
)
{
if
(
expectedExpressionSegment
.
isAssignableFrom
(
ExpectedParamMarkerExpressionSegment
.
class
))
{
return
(
T
)
paramMarkerExpression
;
}
if
(
expectedExpressionSegment
.
isAssignableFrom
(
ExpectedLiteralExpressionSegment
.
class
))
{
return
(
T
)
literalExpression
;
}
if
(
expectedExpressionSegment
.
isAssignableFrom
(
ExpectedCommonExpressionSegment
.
class
))
{
return
(
T
)
commonExpressionSegment
;
}
if
(
expectedExpressionSegment
.
isAssignableFrom
(
ExpectedComplexExpressionSegment
.
class
))
{
return
(
T
)
subquerySegment
;
}
return
null
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录