This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a17ebb695c8 Add test cases on 
RecordSingleTableInventoryCalculatedResult (#33403)
a17ebb695c8 is described below

commit a17ebb695c85c0a0f90a84caaa935ea89b5e6e4e
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Oct 25 17:11:59 2024 +0800

    Add test cases on RecordSingleTableInventoryCalculatedResult (#33403)
    
    * Add test cases on PipelineJobMetaData
    
    * Add test cases on IncrementalTaskAckCallback
    
    * Add test cases on RecordSingleTableInventoryCalculatedResult
---
 ...rdSingleTableInventoryCalculatedResultTest.java | 35 ++++++++++++++++++----
 .../core/src/test/resources/logback-test.xml       |  2 ++
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git 
a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/result/RecordSingleTableInventoryCalculatedResultTest.java
 
b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/result/RecordSingleTableInventoryCalculatedResultTest.java
index 408a8d28adf..e788b9549a9 100644
--- 
a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/result/RecordSingleTableInventoryCalculatedResultTest.java
+++ 
b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/result/RecordSingleTableInventoryCalculatedResultTest.java
@@ -29,18 +29,37 @@ import java.util.Map;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 
 class RecordSingleTableInventoryCalculatedResultTest {
     
     @Test
-    void assertEmptyRecordsEquals() {
+    void assertNotEqualsWithNull() {
+        assertFalse(new RecordSingleTableInventoryCalculatedResult(0, 
Collections.emptyList()).equals(null));
+    }
+    
+    @Test
+    void assertEqualsWithSameObject() {
+        RecordSingleTableInventoryCalculatedResult calculatedResult = new 
RecordSingleTableInventoryCalculatedResult(0, Collections.emptyList());
+        assertThat(calculatedResult, is(calculatedResult));
+    }
+    
+    @Test
+    void assertNotEqualsWithDifferentClassType() {
+        RecordSingleTableInventoryCalculatedResult actual = new 
RecordSingleTableInventoryCalculatedResult(0, Collections.emptyList());
+        Object expected = new Object();
+        assertThat(actual, not(expected));
+    }
+    
+    @Test
+    void assertEqualsWithEmptyRecords() {
         RecordSingleTableInventoryCalculatedResult actual = new 
RecordSingleTableInventoryCalculatedResult(0, Collections.emptyList());
         RecordSingleTableInventoryCalculatedResult expected = new 
RecordSingleTableInventoryCalculatedResult(0, Collections.emptyList());
         assertThat(actual, is(expected));
     }
     
     @Test
-    void assertFullTypeRecordsEquals() {
+    void assertEqualsWithFullTypeRecords() {
         RecordSingleTableInventoryCalculatedResult actual = new 
RecordSingleTableInventoryCalculatedResult(1000, 
Arrays.asList(buildFixedFullTypeRecord(), buildFixedFullTypeRecord()));
         RecordSingleTableInventoryCalculatedResult expected = new 
RecordSingleTableInventoryCalculatedResult(1000, 
Arrays.asList(buildFixedFullTypeRecord(), buildFixedFullTypeRecord()));
         assertThat(actual, is(expected));
@@ -61,19 +80,19 @@ class RecordSingleTableInventoryCalculatedResultTest {
     }
     
     @Test
-    void assertRecordsCountNotEquals() {
+    void assertNotEqualsWithDifferentRecordsCount() {
         assertThat(new RecordSingleTableInventoryCalculatedResult(1000, 
Collections.singletonList(buildFixedFullTypeRecord())),
                 not(new RecordSingleTableInventoryCalculatedResult(1000, 
Collections.emptyList())));
     }
     
     @Test
-    void assertMaxUniqueKeyValueNotEquals() {
+    void assertNotEqualsWithDifferentMaxUniqueKeyValue() {
         assertThat(new RecordSingleTableInventoryCalculatedResult(1000, 
Collections.singletonList(buildFixedFullTypeRecord())),
                 not(new RecordSingleTableInventoryCalculatedResult(1001, 
Collections.singletonList(buildFixedFullTypeRecord()))));
     }
     
     @Test
-    void assertRandomColumnValueNotEquals() {
+    void assertNotEqualsWithDifferentRandomColumnValue() {
         Map<String, Object> record = buildFixedFullTypeRecord();
         RecordSingleTableInventoryCalculatedResult result1 = new 
RecordSingleTableInventoryCalculatedResult(1000, 
Collections.singletonList(record));
         record.forEach((key, value) -> {
@@ -90,4 +109,10 @@ class RecordSingleTableInventoryCalculatedResultTest {
     private Map<String, Object> modifyColumnValueRandomly(final Map<String, 
Object> record, final String key) {
         return ConsistencyCheckDataBuilder.modifyColumnValueRandomly(record, 
key);
     }
+    
+    @Test
+    void assertHashcode() {
+        assertThat(new RecordSingleTableInventoryCalculatedResult(1000, 
Collections.emptyList()).hashCode(),
+                is(new RecordSingleTableInventoryCalculatedResult(1000, 
Collections.emptyList()).hashCode()));
+    }
 }
diff --git a/kernel/data-pipeline/core/src/test/resources/logback-test.xml 
b/kernel/data-pipeline/core/src/test/resources/logback-test.xml
index 37d07d0f7c2..83ed04a1beb 100644
--- a/kernel/data-pipeline/core/src/test/resources/logback-test.xml
+++ b/kernel/data-pipeline/core/src/test/resources/logback-test.xml
@@ -29,6 +29,8 @@
     <logger 
name="org.apache.shardingsphere.data.pipeline.core.datasource.PipelineDataSource"
 level="off" />
     <logger 
name="org.apache.shardingsphere.data.pipeline.core.query.JDBCStreamQueryBuilder"
 level="off" />
     <logger 
name="org.apache.shardingsphere.data.pipeline.core.task.TaskExecuteCallback" 
level="off" />
+    <logger 
name="org.apache.shardingsphere.data.pipeline.core.consistencycheck.result.RecordSingleTableInventoryCalculatedResult"
 level="off" />
+    <logger 
name="org.apache.shardingsphere.data.pipeline.core.consistencycheck.DataConsistencyCheckUtils"
 level="off" />
     
     <root>
         <level value="error" />

Reply via email to