pparthenhs commented on a change in pull request #15775:
URL: https://github.com/apache/shardingsphere/pull/15775#discussion_r819311870



##########
File path: 
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/check/consistency/CRC32MatchMySQLSingleTableDataCalculatorTest.java
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.data.pipeline.mysql.check.consistency;
+
+import 
org.apache.shardingsphere.data.pipeline.api.check.consistency.DataCalculateParameter;
+import 
org.apache.shardingsphere.data.pipeline.api.datasource.PipelineDataSourceWrapper;
+import 
org.apache.shardingsphere.data.pipeline.core.exception.PipelineDataConsistencyCheckFailedException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.stream.StreamSupport;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class CRC32MatchMySQLSingleTableDataCalculatorTest {
+
+    @Mock
+    private DataCalculateParameter dataCalculateParameter;
+
+    private PipelineDataSourceWrapper pipelineJobPrepareFailedException;
+
+    @Before
+    public void setUp() throws SQLException {
+        pipelineJobPrepareFailedException = 
mock(PipelineDataSourceWrapper.class, RETURNS_DEEP_STUBS);
+        Collection<String> columnNames = Arrays.asList("fieldOne", "fieldTwo", 
"fieldThree");
+        
when(dataCalculateParameter.getLogicTableName()).thenReturn("tableName");
+        when(dataCalculateParameter.getColumnNames()).thenReturn(columnNames);
+        
when(dataCalculateParameter.getDataSource()).thenReturn(pipelineJobPrepareFailedException);
+    }
+
+    @Test
+    public void assertCRC32MatchMySQLSingleTableDataCalculatorSuccess() {
+        String algorithmType = new 
CRC32MatchMySQLSingleTableDataCalculator().getAlgorithmType();
+        assertThat(algorithmType, is("CRC32_MATCH"));
+    }
+
+    @Test
+    public void assertGetDatabaseTypesSuccess() {
+        Collection<String> databaseTypes = new 
CRC32MatchMySQLSingleTableDataCalculator().getDatabaseTypes();
+        assertThat(databaseTypes.size(), is(1));
+        assertThat(databaseTypes.stream().findFirst().get(), is("MySQL"));
+    }
+
+    @Test
+    public void assertCalculateSuccess() {
+        Iterable<Object> calculate = new 
CRC32MatchMySQLSingleTableDataCalculator().calculate(dataCalculateParameter);
+        long calculateSize = StreamSupport.stream(calculate.spliterator(), 
false).count();

Review comment:
       > Could we verify certain `sql` is passed in 
`connection.prepareStatement(sql)`, e.g.
   > 
   > ```
   > SELECT BIT_XOR(CAST(CRC32(`fieldOne`) AS UNSIGNED)) AS checksum FROM 
`tableName`
   > ```
   
   
   Dear @sandynz, 
   
   Thank you for your comments and your collaboration.
   
   Regarding the other comment, I resolved them and I think now we are ready. 
But regarding the mentioned comment, is not clear to me how we could improve it.
   
   I am looking forward to your feedback, and I remain always at your disposal.
   
   Best Regards, 
   Panagiotis Parthenis




-- 
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]


Reply via email to