You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/22 05:31:13 UTC

[GitHub] [shardingsphere] tristaZero commented on a change in pull request #7872: add table UT

tristaZero commented on a change in pull request #7872:
URL: https://github.com/apache/shardingsphere/pull/7872#discussion_r509826082



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/segment/table/TableAssert.java
##########
@@ -54,28 +57,24 @@
      * @param actual actual tables
      * @param expected expected tables
      */
-    public static void assertIs(final SQLCaseAssertContext assertContext, final Collection<TableSegment> actual, final ExpectedTables expected) {
-        assertThat(assertContext.getText("Tables size assertion error: "), actual.size(), is(expected.getSimpleTables().size() + expected.getSubqueryTables().size()));
-        assertSimpleTableSegment(assertContext, actual, expected);
-        assertSubqueryTableSegment(assertContext, actual, expected);
-    }
-    
-    /**
-     * Assert actual table segments is correct with expected tables.
-     * 
-     * @param assertContext assert context
-     * @param actual actual tables
-     * @param expected expected tables
-     */
-    public static void assertIs(final SQLCaseAssertContext assertContext, final Collection<SimpleTableSegment> actual, final List<ExpectedSimpleTable> expected) {
-        assertThat(assertContext.getText("Tables size assertion error: "), actual.size(), is(expected.size()));
-        int count = 0;
-        for (SimpleTableSegment each : actual) {
-            assertIs(assertContext, each, expected.get(count));
-            count++;
+    public static void assertIs(final SQLCaseAssertContext assertContext, final TableSegment actual, final ExpectedTable expected) {
+        if (actual instanceof JoinTableSegment) {
+            assertIs(assertContext, (JoinTableSegment) actual, expected.getJoinTable());
+
+        } else if (actual instanceof SimpleTableSegment) {
+            assertIs(assertContext, (SimpleTableSegment) actual, expected.getSimpleTable());
+
+        } else if (actual instanceof SubqueryTableSegment) {
+            assertIs(assertContext, (SubqueryTableSegment) actual, expected.getSubqueryTable());
+
+        } else if (actual instanceof DeleteMultiTableSegment) {
+            return;

Review comment:
       redundant blank line

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/segment/table/TableAssert.java
##########
@@ -54,28 +57,24 @@
      * @param actual actual tables
      * @param expected expected tables
      */
-    public static void assertIs(final SQLCaseAssertContext assertContext, final Collection<TableSegment> actual, final ExpectedTables expected) {
-        assertThat(assertContext.getText("Tables size assertion error: "), actual.size(), is(expected.getSimpleTables().size() + expected.getSubqueryTables().size()));
-        assertSimpleTableSegment(assertContext, actual, expected);
-        assertSubqueryTableSegment(assertContext, actual, expected);
-    }
-    
-    /**
-     * Assert actual table segments is correct with expected tables.
-     * 
-     * @param assertContext assert context
-     * @param actual actual tables
-     * @param expected expected tables
-     */
-    public static void assertIs(final SQLCaseAssertContext assertContext, final Collection<SimpleTableSegment> actual, final List<ExpectedSimpleTable> expected) {
-        assertThat(assertContext.getText("Tables size assertion error: "), actual.size(), is(expected.size()));
-        int count = 0;
-        for (SimpleTableSegment each : actual) {
-            assertIs(assertContext, each, expected.get(count));
-            count++;
+    public static void assertIs(final SQLCaseAssertContext assertContext, final TableSegment actual, final ExpectedTable expected) {
+        if (actual instanceof JoinTableSegment) {
+            assertIs(assertContext, (JoinTableSegment) actual, expected.getJoinTable());
+
+        } else if (actual instanceof SimpleTableSegment) {
+            assertIs(assertContext, (SimpleTableSegment) actual, expected.getSimpleTable());
+

Review comment:
       redundant blank line




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org