huangdx0726 commented on code in PR #19027:
URL: https://github.com/apache/shardingsphere/pull/19027#discussion_r918474275
##########
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/AssistQueryAndPlainInsertColumnsTokenGeneratorTest.java:
##########
@@ -67,7 +68,30 @@ public void assertGenerateSQLTokens() {
tokenGenerator.setEncryptRule(mockEncryptRule());
Collection<InsertColumnsToken> actual =
tokenGenerator.generateSQLTokens(mockInsertStatementContext());
assertThat(actual.size(), is(1));
- // TODO add more assertions for actual value
+
+ Iterator<InsertColumnsToken> iterator = actual.iterator();
+ InsertColumnsToken insertColumnsToken = iterator.next();
+ assertThat(insertColumnsToken.getStartIndex(), is(1));
+
+ InsertStatementContext insertStatementContext =
mockInsertStatementContext();
+ ColumnSegment columnSegment = mock(ColumnSegment.class,
RETURNS_DEEP_STUBS);
+ when(columnSegment.getIdentifier().getValue()).thenReturn("foo_col");
+ when(columnSegment.getStopIndex()).thenReturn(1);
+
when(insertStatementContext.getSqlStatement().getColumns()).thenReturn(Collections.singleton(columnSegment));
+ Collection<InsertColumnsToken> insertColumnsTokens =
tokenGenerator.generateSQLTokens(insertStatementContext);
+ InsertColumnsToken compareInsertColumnsToken =
insertColumnsTokens.iterator().next();
+ assertTrue(insertColumnsToken.compareTo(compareInsertColumnsToken) <
0);
+
+ insertStatementContext = mock(InsertStatementContext.class,
RETURNS_DEEP_STUBS);
+
when(insertStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue()).thenReturn("foo_tbl");
+ actual = tokenGenerator.generateSQLTokens(insertStatementContext);
+ assertThat(actual.size(), is(0));
+
+ columnSegment = mock(ColumnSegment.class, RETURNS_DEEP_STUBS);
+ when(columnSegment.getIdentifier().getValue()).thenReturn("bar_col");
+
when(insertStatementContext.getSqlStatement().getColumns()).thenReturn(Collections.singleton(columnSegment));
+ actual = tokenGenerator.generateSQLTokens(insertStatementContext);
+ assertThat(actual.size(), is(0));
Review Comment:
I will fix it
--
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]