strongduanmu commented on a change in pull request #12295:
URL: https://github.com/apache/shardingsphere/pull/12295#discussion_r704977310
##########
File path:
shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/insert/values/InsertValueContextTest.java
##########
@@ -82,4 +88,17 @@ public void assertGetValueWhenLiteralExpressionSegment() {
private Collection<ExpressionSegment> makeLiteralExpressionSegment(final
Object literalObject) {
return Collections.singleton(new LiteralExpressionSegment(0, 10,
literalObject));
}
+
+ @Test
+ public void assertGetParameterCount() {
+ Collection<ExpressionSegment> assignments = Arrays.asList(
+ new LiteralExpressionSegment(0, 10, null),
+ new ExpressionProjectionSegment(0, 10, ""),
+ new ParameterMarkerExpressionSegment(0, 10, 5),
+ new BinaryOperationExpression(0, 0, new ColumnSegment(0, 0,
new IdentifierValue("")), new ParameterMarkerExpressionSegment(0, 10, 5), "=",
"")
+ );
+ List<Object> parameters = Arrays.asList("", "");
+ InsertValueContext insertValueContext = new
InsertValueContext(assignments, parameters, 0);
+ assertEquals("expect has 2 parameter.",
insertValueContext.getParameterCount(), 2);
Review comment:
@CodingBingo Please replace assertEquals with assertThat.
##########
File path:
shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/insert/values/OnDuplicateUpdateContextTest.java
##########
@@ -137,4 +152,19 @@ public void assertGetColumn() {
ColumnSegment column = onDuplicateUpdateContext.getColumn(0);
assertThat(column,
is(assignments.iterator().next().getColumns().get(0)));
}
+
+ @Test
+ public void assertParameterCount() {
+ List<AssignmentSegment> assignments = Arrays.asList(
+ makeBinaryOperationExpression(),
+ makeAssignmentSegment(new ParameterMarkerExpressionSegment(0,
10, 5)),
+ makeAssignmentSegment(new LiteralExpressionSegment(0, 10, new
Object()))
+ );
+ int doestNotMatterParametersOffset = 0;
+ String doesNotMatterParameterValue = "";
+ List<Object> parameters = Arrays.asList(doesNotMatterParameterValue,
doesNotMatterParameterValue);
+ OnDuplicateUpdateContext onDuplicateUpdateContext = new
OnDuplicateUpdateContext(assignments, parameters,
doestNotMatterParametersOffset);
+ assertEquals("expect has 2 parameter.",
onDuplicateUpdateContext.getParameterCount(), 2);
Review comment:
@CodingBingo Please replace assertEquals with assertThat.
##########
File path:
shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/insert/values/OnDuplicateUpdateContextTest.java
##########
@@ -109,6 +111,19 @@ private AssignmentSegment makeAssignmentSegment(final
SimpleExpressionSegment ex
AssignmentSegment result = new
ColumnAssignmentSegment(doesNotMatterLexicalIndex, doesNotMatterLexicalIndex,
columnSegments, expressionSegment);
return result;
}
+
+ private AssignmentSegment makeBinaryOperationExpression() {
Review comment:
@CodingBingo createBinaryOperationExpression may be better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]