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

mihaibudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 6f318fd737 Modernize exception assertions with assertThrows in 
PrimitiveTest
6f318fd737 is described below

commit 6f318fd73762bddfc628665bc50206bc4b3cb9c3
Author: siddiqueirshad <[email protected]>
AuthorDate: Tue Nov 3 16:36:53 2026 +0530

    Modernize exception assertions with assertThrows in PrimitiveTest
    
    Signed-off-by: siddiqueirshad <[email protected]>
---
 .../apache/calcite/linq4j/test/PrimitiveTest.java  | 27 +++++++---------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git 
a/linq4j/src/test/java/org/apache/calcite/linq4j/test/PrimitiveTest.java 
b/linq4j/src/test/java/org/apache/calcite/linq4j/test/PrimitiveTest.java
index 1e4898f02d..7c4cafdccb 100644
--- a/linq4j/src/test/java/org/apache/calcite/linq4j/test/PrimitiveTest.java
+++ b/linq4j/src/test/java/org/apache/calcite/linq4j/test/PrimitiveTest.java
@@ -33,7 +33,6 @@
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Unit test for {@link Primitive}.
@@ -120,28 +119,18 @@ class PrimitiveTest {
     assertThat(number, instanceOf(Float.class));
     assertThat(number.doubleValue(), is(2.0d));
 
-    try {
-      number = Primitive.INT.number(null);
-      fail("expected exception, got " + number);
-    } catch (NullPointerException e) {
-      // ok
-    }
+    assertThrows(NullPointerException.class, () ->
+        Primitive.INT.number(null));
 
     // not a number
-    try {
-      number = Primitive.CHAR.number(3);
-      fail("expected exception, got " + number);
-    } catch (AssertionError e) {
-      assertThat(e.getMessage(), is("CHAR: 3"));
-    }
+    Throwable e = assertThrows(AssertionError.class, () ->
+        Primitive.CHAR.number(3));
+    assertThat(e.getMessage(), is("CHAR: 3"));
 
     // not a number
-    try {
-      number = Primitive.BOOLEAN.number(null);
-      fail("expected exception, got " + number);
-    } catch (AssertionError e) {
-      assertThat(e.getMessage(), is("BOOLEAN: null"));
-    }
+    e = assertThrows(AssertionError.class, () ->
+        Primitive.BOOLEAN.number(null));
+    assertThat(e.getMessage(), is("BOOLEAN: null"));
   }
 
   /** Test for

Reply via email to