You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pp...@apache.org on 2023/10/18 13:42:13 UTC

[ignite-3] branch main updated: IGNITE-20677 Sql. Improve error reporting in assertThrowsSqlException (#2707)

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

ppa pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 7953fabb2f IGNITE-20677 Sql. Improve error reporting in assertThrowsSqlException (#2707)
7953fabb2f is described below

commit 7953fabb2f529241c555e185b6db0e903371969a
Author: Max Zhuravkov <sh...@gmail.com>
AuthorDate: Wed Oct 18 16:42:06 2023 +0300

    IGNITE-20677 Sql. Improve error reporting in assertThrowsSqlException (#2707)
---
 .../apache/ignite/internal/sql/engine/util/SqlTestUtils.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/SqlTestUtils.java b/modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/SqlTestUtils.java
index 7c7f1e71a6..80ec0328c6 100644
--- a/modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/SqlTestUtils.java
+++ b/modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/SqlTestUtils.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.sql.engine.util;
 
+import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.StringContains.containsString;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -43,6 +44,8 @@ import java.util.stream.StreamSupport;
 import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.internal.sql.engine.type.UuidType;
+import org.apache.ignite.lang.ErrorGroup;
+import org.apache.ignite.lang.ErrorGroups;
 import org.apache.ignite.sql.ColumnType;
 import org.apache.ignite.sql.ResultSet;
 import org.apache.ignite.sql.Session;
@@ -87,8 +90,13 @@ public class SqlTestUtils {
             String expectedMessage,
             Executable executable) {
         T ex = assertThrows(expectedType, executable);
-        assertEquals(expectedCode, ex.code(), ex.toString());
 
+        int expectedErrorCode = ErrorGroup.extractErrorCode(expectedCode);
+        ErrorGroup expectedErrorGroup = ErrorGroups.errorGroupByCode(expectedCode);
+        String expectedError = format("{}-{}", expectedErrorGroup.name(), expectedErrorCode);
+        String actualError = format("{}-{}", ex.groupName(), ex.errorCode());
+
+        assertEquals(expectedError, actualError, "Error does not match. " + ex);
         assertThat("Error message", ex.getMessage(), containsString(expectedMessage));
 
         return ex;