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

jianbin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new f87347513d test: Improve the test case coverage of [sqlparser] module 
to 70% (#6608)
f87347513d is described below

commit f87347513d4ca8cbb448af8b0963aceee72d69d0
Author: traitsisgiorgos <[email protected]>
AuthorDate: Fri Jul 12 13:14:13 2024 +0300

    test: Improve the test case coverage of [sqlparser] module to 70% (#6608)
---
 changes/en-us/2.x.md                               |   2 +
 changes/zh-cn/2.x.md                               |   2 +
 .../apache/seata/sqlparser/EscapeSymbolTest.java   |  39 +++
 .../seata/sqlparser/SQLParsingExceptionTest.java   |  49 ++++
 .../org/apache/seata/sqlparser/SQLTypeTest.java    |  46 ++++
 .../seata/sqlparser/struct/ColumnMetaTest.java     | 188 ++++++++++++++
 .../seata/sqlparser/struct/IndexMetaTest.java      | 275 +++++++++++++++++++++
 .../seata/sqlparser/struct/IndexTypeTest.java      |  48 ++++
 .../sqlparser/struct/NotPlaceHolderExprTest.java   |  38 +++
 .../apache/seata/sqlparser/struct/NullTest.java    |  37 +++
 .../seata/sqlparser/struct/SqlDefaultExprTest.java |  34 +++
 .../seata/sqlparser/struct/SqlMethodExprTest.java  |  36 +++
 .../sqlparser/struct/SqlSequenceExprTest.java      |  62 +++++
 .../seata/sqlparser/struct/TableMetaTest.java      | 229 +++++++++++++++++
 14 files changed, 1085 insertions(+)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index cc56c09952..e8a244ab0f 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -34,6 +34,7 @@ Add changes here for all PR submitted to the 2.x branch.
 
 
 ### test:
+- [[#6608](https://github.com/apache/incubator-seata/pull/6608)] add unit test 
for sql-parser-core
 - [[#6647](https://github.com/apache/incubator-seata/pull/6647)] improve the 
test case coverage of saga module to 70%
 
 
@@ -48,6 +49,7 @@ Thanks to these contributors for their code commits. Please 
report an unintended
 - [Bughue](https://github.com/Bughue)
 - [funky-eyes](https://github.com/funky-eyes)
 - [tanyaofei](https://github.com/tanyaofei)
+- [traitsisgiorgos](https://github.com/traitsisgiorgos)
 - [wanghongzhou](https://github.com/wanghongzhou)
 - [ggbocoder](https://github.com/ggbocoder)
 - [xjlgod](https://github.com/xjlgod)
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 43991dbf04..de858465c9 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -34,6 +34,7 @@
 ### security:
 
 ### test:
+- [[#6608](https://github.com/apache/incubator-seata/pull/6608)] 
添加sql-parser-core模块测试用例
 - [[#6647](https://github.com/apache/incubator-seata/pull/6647)] 
增加saga模块的测试用例覆盖率
 
 
@@ -49,6 +50,7 @@
 - [Bughue](https://github.com/Bughue)
 - [funky-eyes](https://github.com/funky-eyes)
 - [tanyaofei](https://github.com/tanyaofei)
+- [traitsisgiorgos](https://github.com/traitsisgiorgos)
 - [wanghongzhou](https://github.com/wanghongzhou)
 - [ggbocoder](https://github.com/ggbocoder)
 - [xjlgod](https://github.com/xjlgod)
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/EscapeSymbolTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/EscapeSymbolTest.java
new file mode 100644
index 0000000000..d0725520cd
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/EscapeSymbolTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.seata.sqlparser;
+
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class EscapeSymbolTest {
+
+    @Test
+    public void testGetLeftSymbol() {
+        char expectedLeftSymbol = '"';
+        EscapeSymbol escapeSymbol = new EscapeSymbol(expectedLeftSymbol, '"');
+        assertEquals(expectedLeftSymbol, escapeSymbol.getLeftSymbol(),
+                "The left symbol should be '" + expectedLeftSymbol + "'");
+    }
+
+    @Test
+    public void testGetRightSymbol() {
+        char expectedRightSymbol = '"';
+        EscapeSymbol escapeSymbol = new EscapeSymbol('"', expectedRightSymbol);
+        assertEquals(expectedRightSymbol, escapeSymbol.getRightSymbol(),
+                "The right symbol should be '" + expectedRightSymbol + "'");
+    }
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/SQLParsingExceptionTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/SQLParsingExceptionTest.java
new file mode 100644
index 0000000000..b8ee6c5873
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/SQLParsingExceptionTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.seata.sqlparser;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import org.junit.jupiter.api.Test;
+
+public class SQLParsingExceptionTest {
+    @Test
+    public void testConstructorWithMessage() {
+        String message = "Test message";
+        SQLParsingException exception = new SQLParsingException(message);
+        assertEquals(message, exception.getMessage(), "Message should match");
+        assertNull(exception.getCause(), "Cause should be null");
+    }
+
+    @Test
+    public void testConstructorWithMessageAndCause() {
+        String message = "Test message";
+        Throwable cause = new IllegalArgumentException("Test cause");
+        SQLParsingException exception = new SQLParsingException(message, 
cause);
+        assertEquals(message, exception.getMessage(), "Message should match");
+        assertEquals(cause, exception.getCause(), "Cause should match");
+    }
+
+    @Test
+    public void testConstructorWithCause() {
+        Throwable cause = new IllegalArgumentException("Test cause");
+        SQLParsingException exception = new SQLParsingException(cause);
+        assertEquals(cause.toString(), exception.getMessage(), "Message should 
be cause's toString");
+        assertEquals(cause, exception.getCause(), "Cause should match");
+    }
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/SQLTypeTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/SQLTypeTest.java
new file mode 100644
index 0000000000..3b4cb62e3b
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/SQLTypeTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.seata.sqlparser;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+public class SQLTypeTest {
+
+    @Test
+    public void testValue() {
+        assertEquals(0, SQLType.SELECT.value(), "SELECT value should be 0");
+        assertEquals(1, SQLType.INSERT.value(), "INSERT value should be 1");
+        // Add more assertions for other enum constants
+    }
+
+    @Test
+    public void testValueOf() {
+        assertEquals(SQLType.SELECT, SQLType.valueOf(0), "Should retrieve 
SELECT for value 0");
+        assertEquals(SQLType.INSERT, SQLType.valueOf(1), "Should retrieve 
INSERT for value 1");
+        // Add more assertions for other integer values
+    }
+
+    @Test
+    public void testValueOfInvalid() {
+        assertThrows(IllegalArgumentException.class, () -> 
SQLType.valueOf(100),
+                "Should throw IllegalArgumentException for invalid value");
+    }
+
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/ColumnMetaTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/ColumnMetaTest.java
new file mode 100644
index 0000000000..50f41ff120
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/ColumnMetaTest.java
@@ -0,0 +1,188 @@
+/*
+ * 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.seata.sqlparser.struct;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+public class ColumnMetaTest {
+
+    @Test
+    public void testEqualsAndHashCode() {
+        // Create two instances with identical properties
+        ColumnMeta column1 = new ColumnMeta();
+        ColumnMeta column2 = new ColumnMeta();
+
+        // Test equality for two newly created instances
+        assertTrue(column1.equals(column2));
+        assertEquals(column1.hashCode(), column2.hashCode());
+
+        // Modify some properties of column1
+        column1.setTableName("table1");
+        column1.setColumnName("column1");
+        column1.setDataType(1);
+
+        // Test inequality after modifying properties
+        assertFalse(column1.equals(column2));
+        assertNotEquals(column1.hashCode(), column2.hashCode());
+
+        // Create a copy of column1 with the same properties
+        ColumnMeta column3 = new ColumnMeta();
+        column3.setTableName("table1");
+        column3.setColumnName("column1");
+        column3.setDataType(1);
+
+        // Test equality with the copy
+        assertTrue(column1.equals(column3));
+        assertEquals(column1.hashCode(), column3.hashCode());
+
+    }
+
+    @Test
+    public void testAutoincrement() {
+        ColumnMeta column = new ColumnMeta();
+
+        // Test default value
+        assertFalse(column.isAutoincrement());
+
+        // Set autoincrement to YES
+        column.setIsAutoincrement("YES");
+        assertTrue(column.isAutoincrement());
+
+        // Set autoincrement to NO
+        column.setIsAutoincrement("NO");
+        assertFalse(column.isAutoincrement());
+    }
+
+    @Test
+    public void testGetTableCat() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setTableCat("tableCat");
+        assertEquals(columnMeta.getTableCat(), "tableCat".trim());
+    }
+
+    @Test
+    public void testSetGetColumnName() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setColumnName("columnName");
+        assertEquals("columnName".trim(), columnMeta.getColumnName());
+    }
+
+    @Test
+    public void testSetGetDataType() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setDataType(2);
+        assertEquals(2, columnMeta.getDataType());
+    }
+
+    @Test
+    public void testSetGetDataTypeName() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setDataTypeName("dataTypeName");
+        assertEquals("dataTypeName".trim(), columnMeta.getDataTypeName());
+    }
+
+    @Test
+    public void testSetGetColumnSize() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setColumnSize(2);
+        assertEquals(2, columnMeta.getColumnSize());
+    }
+
+    @Test
+    public void testSetGetDemicalDigits() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setDecimalDigits(2);
+        assertEquals(2, columnMeta.getDecimalDigits());
+    }
+
+    @Test
+    public void testSetGetNumPrecRadix() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setNumPrecRadix(10);
+        assertEquals(10, columnMeta.getNumPrecRadix());
+    }
+
+    @Test
+    public void testSetGetNullAble() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setNullAble(5);
+        assertEquals(5, columnMeta.getNullAble());
+    }
+
+    @Test
+    public void testSetGetRemarks() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setRemarks("remarks");
+        assertEquals("remarks".trim(), columnMeta.getRemarks());
+    }
+
+    @Test
+    public void testSetGetColumnDef() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setColumnDef("columnDef");
+        assertEquals("columnDef", columnMeta.getColumnDef());
+    }
+
+    @Test
+    public void testSetGetSqlDataType() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setSqlDataType(1);
+        assertEquals(1, columnMeta.getSqlDataType());
+    }
+
+    @Test
+    public void testSetGetSqlDatetimeSub() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setSqlDatetimeSub(2);
+        assertEquals(2, columnMeta.getSqlDatetimeSub());
+    }
+
+    @Test
+    public void testSetGetCharOctetLength() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        Object charOctetLength = 255;
+        columnMeta.setCharOctetLength(charOctetLength);
+        assertEquals(charOctetLength, columnMeta.getCharOctetLength());
+    }
+
+    @Test
+    public void testSetGetOrdinalPosition() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setOrdinalPosition(3);
+        assertEquals(3, columnMeta.getOrdinalPosition());
+    }
+
+    @Test
+    public void testSetGetIsOnUpdate() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setOnUpdate(true);
+        assertTrue(columnMeta.isOnUpdate());
+    }
+
+    @Test
+    public void testSetGetIsCaseSensitive() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        columnMeta.setCaseSensitive(true);
+        assertTrue(columnMeta.isCaseSensitive());
+    }
+
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/IndexMetaTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/IndexMetaTest.java
new file mode 100644
index 0000000000..bceef1e471
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/IndexMetaTest.java
@@ -0,0 +1,275 @@
+/*
+ * 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.seata.sqlparser.struct;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+
+public class IndexMetaTest {
+    @Test
+    public void testGetSetValues() {
+        IndexMeta indexMeta = new IndexMeta();
+        List<ColumnMeta> values = Arrays.asList(new ColumnMeta(), new 
ColumnMeta());
+        indexMeta.setValues(values);
+        assertEquals(values, indexMeta.getValues());
+    }
+
+    @Test
+    public void testIsSetNonUnique() {
+        IndexMeta indexMeta = new IndexMeta();
+        indexMeta.setNonUnique(true);
+        assertTrue(indexMeta.isNonUnique());
+        indexMeta.setNonUnique(false);
+        assertFalse(indexMeta.isNonUnique());
+    }
+
+    @Test
+    public void testGetSetIndexQualifier() {
+        IndexMeta indexMeta = new IndexMeta();
+        String indexQualifier = "qualifier";
+        indexMeta.setIndexQualifier(indexQualifier);
+        assertEquals(indexQualifier, indexMeta.getIndexQualifier());
+    }
+
+    @Test
+    public void testGetSetIndexName() {
+        IndexMeta indexMeta = new IndexMeta();
+        String indexName = "indexName";
+        indexMeta.setIndexName(indexName);
+        assertEquals(indexName, indexMeta.getIndexName());
+    }
+
+    @Test
+    public void testGetSetType() {
+        IndexMeta indexMeta = new IndexMeta();
+        short type = 1;
+        indexMeta.setType(type);
+        assertEquals(type, indexMeta.getType());
+    }
+
+    @Test
+    public void testGetSetAscOrDesc() {
+        IndexMeta indexMeta = new IndexMeta();
+        String ascOrDesc = "A";
+        indexMeta.setAscOrDesc(ascOrDesc);
+        assertEquals(ascOrDesc, indexMeta.getAscOrDesc());
+    }
+
+    @Test
+    public void testGetSetCardinality() {
+        IndexMeta indexMeta = new IndexMeta();
+        long cardinality = 100L;
+        indexMeta.setCardinality(cardinality);
+        assertEquals(cardinality, indexMeta.getCardinality());
+    }
+
+    @Test
+    public void testGetSetOrdinalPosition() {
+        IndexMeta indexMeta = new IndexMeta();
+        int ordinalPosition = 1;
+        indexMeta.setOrdinalPosition(ordinalPosition);
+        assertEquals(ordinalPosition, indexMeta.getOrdinalPosition());
+    }
+
+    @Test
+    public void testGetSetIndextype() {
+        IndexMeta indexMeta = new IndexMeta();
+        IndexType indextype = IndexType.NORMAL;
+        indexMeta.setIndextype(indextype);
+        assertEquals(indextype, indexMeta.getIndextype(), "Indextype should be 
set and retrieved correctly");
+    }
+
+    @Test
+    public void testEqualsSameObject() {
+        IndexMeta indexMeta = new IndexMeta();
+        assertTrue(indexMeta.equals(indexMeta), "An object should be equal to 
itself");
+    }
+
+    @Test
+    public void testEqualsNullObject() {
+        IndexMeta indexMeta = new IndexMeta();
+        assertFalse(indexMeta.equals(null), "An object should not be equal to 
null");
+    }
+
+    @Test
+    public void testEqualsDifferentType() {
+        IndexMeta indexMeta = new IndexMeta();
+        String differentType = "I am not an IndexMeta";
+        assertFalse(indexMeta.equals(differentType), "An object should not be 
equal to an object of a different type");
+    }
+
+    @Test
+    public void testEqualsIdenticalObjects() {
+        IndexType indexType = IndexType.PRIMARY;
+        IndexMeta indexMeta1 = new IndexMeta();
+        indexMeta1.setValues(Arrays.asList(new ColumnMeta(), new 
ColumnMeta()));
+        indexMeta1.setNonUnique(true);
+        indexMeta1.setIndexQualifier("qualifier");
+        indexMeta1.setIndexName("indexName");
+        indexMeta1.setType((short) 1);
+        indexMeta1.setIndextype(indexType);
+        indexMeta1.setAscOrDesc("A");
+        indexMeta1.setOrdinalPosition(1);
+
+        IndexType indexType2 = IndexType.PRIMARY;
+        IndexMeta indexMeta2 = new IndexMeta();
+        indexMeta2.setValues(Arrays.asList(new ColumnMeta(), new 
ColumnMeta()));
+        indexMeta2.setNonUnique(true);
+        indexMeta2.setIndexQualifier("qualifier");
+        indexMeta2.setIndexName("indexName");
+        indexMeta2.setType((short) 1);
+        indexMeta2.setIndextype(indexType2);
+        indexMeta2.setAscOrDesc("A");
+        indexMeta2.setOrdinalPosition(1);
+
+        assertTrue(indexMeta1.equals(indexMeta2), "Two objects with identical 
field values should be equal");
+    }
+
+    @Test
+    public void testEqualsDifferentObjects() {
+        IndexMeta indexMeta1 = new IndexMeta();
+        indexMeta1.setValues(Arrays.asList(new ColumnMeta(), new ColumnMeta(), 
new ColumnMeta()));
+        indexMeta1.setNonUnique(true);
+        indexMeta1.setIndexQualifier("qualifier");
+        indexMeta1.setIndexName("indexName");
+        indexMeta1.setType((short) 1);
+        indexMeta1.setIndextype(IndexType.UNIQUE);
+        indexMeta1.setAscOrDesc("A");
+        indexMeta1.setOrdinalPosition(1);
+
+        IndexMeta indexMeta2 = new IndexMeta();
+        indexMeta2.setValues(Arrays.asList(new ColumnMeta(), new ColumnMeta(), 
new ColumnMeta()));
+        indexMeta2.setNonUnique(false);
+        indexMeta2.setIndexQualifier("differentQualifier");
+        indexMeta2.setIndexName("differentIndexName");
+        indexMeta2.setType((short) 2);
+        indexMeta2.setIndextype(IndexType.FULL_TEXT);
+        indexMeta2.setAscOrDesc("D");
+        indexMeta2.setOrdinalPosition(2);
+
+        assertFalse(indexMeta1.equals(indexMeta2), "Two objects with different 
field values should not be equal");
+    }
+
+    @Test
+    public void testHashCodeConsistency() {
+        ColumnMeta columnMeta1 = new ColumnMeta();
+        columnMeta1.setTableCat("tableCat");
+        columnMeta1.setTableSchemaName("schemaName");
+        columnMeta1.setTableName("tableName");
+        columnMeta1.setColumnName("columnName");
+        columnMeta1.setDataType(1);
+        columnMeta1.setDataTypeName("dataTypeName");
+        columnMeta1.setColumnSize(100);
+        columnMeta1.setDecimalDigits(10);
+        columnMeta1.setNumPrecRadix(10);
+        columnMeta1.setNullAble(1);
+        columnMeta1.setRemarks("remarks");
+        columnMeta1.setColumnDef("columnDef");
+        columnMeta1.setSqlDataType(1);
+        columnMeta1.setSqlDatetimeSub(1);
+        columnMeta1.setCharOctetLength(100);
+        columnMeta1.setOrdinalPosition(1);
+        columnMeta1.setIsNullAble("YES");
+        columnMeta1.setIsAutoincrement("YES");
+        columnMeta1.setOnUpdate(true);
+        columnMeta1.setCaseSensitive(true);
+
+        ColumnMeta columnMeta2 = new ColumnMeta();
+        columnMeta2.setTableCat("tableCat");
+        columnMeta2.setTableSchemaName("schemaName");
+        columnMeta2.setTableName("tableName");
+        columnMeta2.setColumnName("columnName");
+        columnMeta2.setDataType(1);
+        columnMeta2.setDataTypeName("dataTypeName");
+        columnMeta2.setColumnSize(100);
+        columnMeta2.setDecimalDigits(10);
+        columnMeta2.setNumPrecRadix(10);
+        columnMeta2.setNullAble(1);
+        columnMeta2.setRemarks("remarks");
+        columnMeta2.setColumnDef("columnDef");
+        columnMeta2.setSqlDataType(1);
+        columnMeta2.setSqlDatetimeSub(1);
+        columnMeta2.setCharOctetLength(100);
+        columnMeta2.setOrdinalPosition(1);
+        columnMeta2.setIsNullAble("YES");
+        columnMeta2.setIsAutoincrement("YES");
+        columnMeta2.setOnUpdate(true);
+        columnMeta2.setCaseSensitive(true);
+
+        // Check if hash codes are consistent
+        assertEquals(columnMeta1.hashCode(), columnMeta2.hashCode(), "Hash 
codes should be the same for equal objects");
+    }
+
+    @Test
+    public void testHashCodeDifference() {
+        ColumnMeta columnMeta1 = new ColumnMeta();
+        columnMeta1.setTableCat("tableCat1");
+        columnMeta1.setTableSchemaName("schemaName1");
+        columnMeta1.setTableName("tableName1");
+        columnMeta1.setColumnName("columnName1");
+        columnMeta1.setDataType(1);
+        columnMeta1.setDataTypeName("dataTypeName1");
+        columnMeta1.setColumnSize(100);
+        columnMeta1.setDecimalDigits(10);
+        columnMeta1.setNumPrecRadix(10);
+        columnMeta1.setNullAble(1);
+        columnMeta1.setRemarks("remarks1");
+        columnMeta1.setColumnDef("columnDef1");
+        columnMeta1.setSqlDataType(1);
+        columnMeta1.setSqlDatetimeSub(1);
+        columnMeta1.setCharOctetLength(100);
+        columnMeta1.setOrdinalPosition(1);
+        columnMeta1.setIsNullAble("YES");
+        columnMeta1.setIsAutoincrement("YES");
+        columnMeta1.setOnUpdate(true);
+        columnMeta1.setCaseSensitive(true);
+
+        ColumnMeta columnMeta2 = new ColumnMeta();
+        columnMeta2.setTableCat("tableCat2");
+        columnMeta2.setTableSchemaName("schemaName2");
+        columnMeta2.setTableName("tableName2");
+        columnMeta2.setColumnName("columnName2");
+        columnMeta2.setDataType(2);
+        columnMeta2.setDataTypeName("dataTypeName2");
+        columnMeta2.setColumnSize(200);
+        columnMeta2.setDecimalDigits(20);
+        columnMeta2.setNumPrecRadix(20);
+        columnMeta2.setNullAble(0);
+        columnMeta2.setRemarks("remarks2");
+        columnMeta2.setColumnDef("columnDef2");
+        columnMeta2.setSqlDataType(2);
+        columnMeta2.setSqlDatetimeSub(2);
+        columnMeta2.setCharOctetLength(200);
+        columnMeta2.setOrdinalPosition(2);
+        columnMeta2.setIsNullAble("NO");
+        columnMeta2.setIsAutoincrement("NO");
+        columnMeta2.setOnUpdate(false);
+        columnMeta2.setCaseSensitive(false);
+
+        // Check if hash codes are different for different objects
+        assertNotEquals(columnMeta1.hashCode(), columnMeta2.hashCode(),
+                "Hash codes should be different for non-equal objects");
+    }
+
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/IndexTypeTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/IndexTypeTest.java
new file mode 100644
index 0000000000..f6b52c8411
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/IndexTypeTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.seata.sqlparser.struct;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+public class IndexTypeTest {
+
+    @Test
+    public void testValue() {
+        assertEquals(0, IndexType.PRIMARY.value(), "Value of PRIMARY index 
type should be 0");
+        assertEquals(1, IndexType.NORMAL.value(), "Value of NORMAL index type 
should be 1");
+        assertEquals(2, IndexType.UNIQUE.value(), "Value of UNIQUE index type 
should be 2");
+        assertEquals(3, IndexType.FULL_TEXT.value(), "Value of FULL_TEXT index 
type should be 3");
+    }
+
+    @Test
+    public void testValueOf() {
+        assertEquals(IndexType.PRIMARY, IndexType.valueOf(0), "IndexType of 
value 0 should be PRIMARY");
+        assertEquals(IndexType.NORMAL, IndexType.valueOf(1), "IndexType of 
value 1 should be NORMAL");
+        assertEquals(IndexType.UNIQUE, IndexType.valueOf(2), "IndexType of 
value 2 should be UNIQUE");
+        assertEquals(IndexType.FULL_TEXT, IndexType.valueOf(3), "IndexType of 
value 3 should be FULL_TEXT");
+    }
+
+    @Test
+    public void testInvalidValueOf() {
+        assertThrows(IllegalArgumentException.class, () -> 
IndexType.valueOf(4),
+                "Should throw IllegalArgumentException for invalid value 4");
+    }
+
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/NotPlaceHolderExprTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/NotPlaceHolderExprTest.java
new file mode 100644
index 0000000000..cc96257e82
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/NotPlaceHolderExprTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.seata.sqlparser.struct;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+public class NotPlaceHolderExprTest {
+
+    @Test
+    public void testGet() {
+        NotPlaceholderExpr instance = NotPlaceholderExpr.get();
+        // Check that the returned instance is not null
+        assertEquals(instance, NotPlaceholderExpr.get());
+    }
+
+    @Test
+    public void testToString() {
+        NotPlaceholderExpr instance = NotPlaceholderExpr.get();
+        // Check that the toString method returns the expected string
+        assertEquals("NOT_PLACEHOLDER", instance.toString());
+    }
+}
\ No newline at end of file
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/NullTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/NullTest.java
new file mode 100644
index 0000000000..1c0adfb1bd
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/NullTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.seata.sqlparser.struct;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+public class NullTest {
+
+    @Test
+    public void testGet() {
+        Null instance = Null.get();
+        assertEquals(instance, Null.get());
+    }
+
+    @Test
+    public void testToString() {
+        String expected = "NULL";
+        assertEquals(expected.trim(), Null.get().toString().trim());
+    }
+
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/SqlDefaultExprTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/SqlDefaultExprTest.java
new file mode 100644
index 0000000000..a308ca9b98
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/SqlDefaultExprTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.seata.sqlparser.struct;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Test;
+
+public class SqlDefaultExprTest {
+    @Test
+    public void testGet() {
+        SqlDefaultExpr instance = SqlDefaultExpr.get();
+        assertEquals(instance, SqlDefaultExpr.get());
+    }
+
+    @Test
+    public void testToString() {
+        String expected = "DEFAULT";
+        assertEquals(expected.trim(), SqlDefaultExpr.get().toString().trim());
+    }
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/SqlMethodExprTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/SqlMethodExprTest.java
new file mode 100644
index 0000000000..75a44914ca
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/SqlMethodExprTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.seata.sqlparser.struct;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+public class SqlMethodExprTest {
+    @Test
+    public void testGet() {
+        SqlMethodExpr instance = SqlMethodExpr.get();
+        assertEquals(instance, SqlMethodExpr.get());
+    }
+
+    @Test
+    public void testToString() {
+        String expected = "SQL_METHOD";
+        assertEquals(expected.trim(), SqlMethodExpr.get().toString().trim());
+    }
+
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/SqlSequenceExprTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/SqlSequenceExprTest.java
new file mode 100644
index 0000000000..617a56cf00
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/SqlSequenceExprTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.seata.sqlparser.struct;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import org.junit.jupiter.api.Test;
+
+public class SqlSequenceExprTest {
+
+    @Test
+    public void testDefaultConstructor() {
+
+        SqlSequenceExpr expr = new SqlSequenceExpr();
+
+        assertNull(expr.getSequence(), "Initial sequence should be null.");
+        assertNull(expr.getFunction(), "Initial function should be null.");
+    }
+
+    @Test
+    public void testParameterizedConstructor() {
+
+        SqlSequenceExpr expr = new SqlSequenceExpr("mySequence", "myFunction");
+
+        assertEquals("mySequence", expr.getSequence(), "Sequence should be 
'mySequence'.");
+        assertEquals("myFunction", expr.getFunction(), "Function should be 
'myFunction'.");
+    }
+
+    @Test
+    public void testSetGetSequence() {
+
+        SqlSequenceExpr expr = new SqlSequenceExpr();
+
+        expr.setSequence("newSequence");
+        assertEquals("newSequence", expr.getSequence(), "Sequence should be 
'newSequence'.");
+    }
+
+    @Test
+    public void testSetGetFunction() {
+
+        SqlSequenceExpr expr = new SqlSequenceExpr();
+
+        expr.setFunction("newFunction");
+        assertEquals("newFunction", expr.getFunction(), "Function should be 
'newFunction'.");
+    }
+
+}
diff --git 
a/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/TableMetaTest.java
 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/TableMetaTest.java
new file mode 100644
index 0000000000..53c58a1bef
--- /dev/null
+++ 
b/sqlparser/seata-sqlparser-core/src/test/java/org/apache/seata/sqlparser/struct/TableMetaTest.java
@@ -0,0 +1,229 @@
+/*
+ * 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.seata.sqlparser.struct;
+
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.seata.common.exception.NotSupportYetException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class TableMetaTest {
+    private TableMeta tableMeta;
+    private TableMeta tableMeta2;
+
+    @BeforeEach
+    public void setUp() {
+        tableMeta = new TableMeta();
+        tableMeta.setTableName("tableName");
+
+        ColumnMeta col1 = new ColumnMeta();
+        col1.setColumnName("col1");
+        col1.setOnUpdate(true);
+        tableMeta.getAllColumns().put("col1", col1);
+
+        ColumnMeta col2 = new ColumnMeta();
+        col2.setColumnName("col2");
+        tableMeta.getAllColumns().put("col2", col2);
+
+        IndexMeta primaryIndexMeta = new IndexMeta();
+        primaryIndexMeta.setIndextype(IndexType.PRIMARY);
+        primaryIndexMeta.setValues(Arrays.asList(col1, col2));
+
+        tableMeta.getAllIndexes().put("primary", primaryIndexMeta);
+
+        tableMeta2 = new TableMeta();
+        tableMeta2.setTableName("tableName");
+        tableMeta2.getAllColumns().put("col1", col1);
+        tableMeta2.getAllColumns().put("col2", col2);
+        tableMeta2.getAllIndexes().put("primary", primaryIndexMeta);
+    }
+
+    @Test
+    public void testSetGetTableName() {
+        String tableName = "tableName";
+        assertEquals(tableName, tableMeta.getTableName(), "Table name should 
match the value set");
+    }
+
+    @Test
+    public void testSetGetCaseSensitive() {
+        tableMeta.setCaseSensitive(true);
+        assertTrue(tableMeta.isCaseSensitive(), "Case sensitivity should be 
true");
+        tableMeta.setCaseSensitive(false);
+        assertFalse(tableMeta.isCaseSensitive(), "Case sensitivity should be 
false");
+    }
+
+    @Test
+    public void testGetColumnMeta() {
+        ColumnMeta columnMeta = new ColumnMeta();
+        tableMeta.getAllColumns().put("col1", columnMeta);
+
+        assertEquals(columnMeta, tableMeta.getColumnMeta("col1"), "Should 
return the correct ColumnMeta object");
+    }
+
+    @Test
+    public void testGetAllColumns() {
+        ColumnMeta columnMeta1 = new ColumnMeta();
+        ColumnMeta columnMeta2 = new ColumnMeta();
+        tableMeta.getAllColumns().put("col1", columnMeta1);
+        tableMeta.getAllColumns().put("col2", columnMeta2);
+
+        Map<String, ColumnMeta> allColumns = tableMeta.getAllColumns();
+
+        assertEquals(2, allColumns.size(), "Should return all columns added");
+        assertTrue(allColumns.containsKey("col1"), "Should contain column 
'col1'");
+        assertTrue(allColumns.containsKey("col2"), "Should contain column 
'col2'");
+    }
+
+    @Test
+    public void testGetAllIndexes() {
+
+        Map<String, IndexMeta> allIndexes = tableMeta.getAllIndexes();
+
+        assertEquals(1, allIndexes.size(), "Should return all indexes added");
+        assertTrue(allIndexes.containsKey("primary"), "Should contain index 
'primary'");
+
+    }
+
+    @Test
+    public void testGetPrimaryKeyMap() {
+        Map<String, ColumnMeta> pkCol = tableMeta.getPrimaryKeyMap();
+
+        assertEquals(2, pkCol.size());
+        assertTrue(pkCol.containsKey("col1"));
+        assertTrue(pkCol.containsKey("col2"));
+    }
+
+    @Test
+    public void testGetPrimaryKeyMapNoPrimaryKey() {
+        tableMeta.getAllIndexes().clear();
+
+        NotSupportYetException exception = assertThrows(
+                NotSupportYetException.class,
+                () -> tableMeta.getPrimaryKeyMap());
+
+        assertEquals(String.format("%s needs to contain the primary key.", 
tableMeta.getTableName()),
+                exception.getMessage());
+    }
+
+    @Test
+    public void testGetCaseInsensitivePKs() {
+        tableMeta.getColumnMeta("col2".trim()).setColumnName("CoL2");
+        Set<String> pks = tableMeta.getCaseInsensitivePKs();
+
+        assertEquals(2, pks.size());
+        assertTrue(pks.contains("col1"));
+        assertTrue(pks.contains("CoL2"));
+
+    }
+
+    @Test
+    public void testGetCaseInsensitivePKsNoPrimaryKey() {
+        tableMeta.getAllIndexes().clear(); // Remove primary key
+
+        NotSupportYetException exception = assertThrows(
+                NotSupportYetException.class,
+                () -> tableMeta.getCaseInsensitivePKs());
+
+        assertEquals(String.format("%s needs to contain the primary key.", 
tableMeta.getTableName()),
+                exception.getMessage());
+    }
+
+    @Test
+    public void testGetPrimaryKeyOnlyName() {
+        List<String> pksName = tableMeta.getPrimaryKeyOnlyName();
+
+        assertEquals(2, pksName.size());
+        assertTrue(pksName.contains("col1"));
+        assertTrue(pksName.contains("col2"));
+
+    }
+
+    @Test
+    public void testGetOnUpdateColumnsOnlyName() {
+        List<String> onUpdateColumns = tableMeta.getOnUpdateColumnsOnlyName();
+        List<String> expected = Arrays.asList("col1");
+
+        assertEquals(expected.size(), onUpdateColumns.size());
+        assertTrue(onUpdateColumns.containsAll(expected));
+    }
+
+    @Test
+    public void testGetOnUpdateColumnsOnlyNameNoUpdates() {
+        tableMeta.getAllColumns().values().forEach(col -> 
col.setOnUpdate(false));
+
+        List<String> onUpdateColumns = tableMeta.getOnUpdateColumnsOnlyName();
+        assertTrue(onUpdateColumns.isEmpty());
+    }
+
+    @Test
+    public void testContainsPKWithNullList() {
+        assertFalse(tableMeta.containsPK(null));
+    }
+
+    @Test
+    public void testContainsPKWithNoPrimaryKey() {
+        List<String> cols = Arrays.asList("col3", "col4");
+        assertFalse(tableMeta.containsPK(cols));
+    }
+
+    @Test
+    public void testContainsPKWithExactMatch() {
+        List<String> cols = Arrays.asList("col1", "col2");
+        assertTrue(tableMeta.containsPK(cols));
+    }
+
+    @Test
+    public void testContainsPKWithCaseInsensitiveMatch() {
+        List<String> cols = Arrays.asList("COL1", "COL2");
+        assertTrue(tableMeta.containsPK(cols));
+    }
+
+    @Test
+    public void testContainsPKWithNoMatch() {
+        List<String> cols = Collections.singletonList("other");
+        assertFalse(tableMeta.containsPK(cols));
+    }
+
+    @Test
+    public void testEquals() {
+        assertTrue(tableMeta.equals(tableMeta2));
+
+        tableMeta2.setTableName("different_table");
+        assertFalse(tableMeta.equals(tableMeta2));
+    }
+
+    @Test
+    public void testHashCode() {
+        assertEquals(tableMeta.hashCode(), tableMeta2.hashCode());
+
+        tableMeta2.setTableName("different_table");
+        assertNotEquals(tableMeta.hashCode(), tableMeta2.hashCode());
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to