You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by et...@apache.org on 2025/04/22 10:02:10 UTC

(iceberg) branch main updated: Core: Use assumeThat instead of assumeTrue (#12822)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 0386463529 Core: Use assumeThat instead of assumeTrue (#12822)
0386463529 is described below

commit 03864635296c7e7507919d5f1e0514594555fb61
Author: slfan1989 <55...@users.noreply.github.com>
AuthorDate: Tue Apr 22 18:02:05 2025 +0800

    Core: Use assumeThat instead of assumeTrue (#12822)
---
 .baseline/checkstyle/checkstyle.xml                |  5 ++
 .../org/apache/iceberg/catalog/CatalogTests.java   | 57 +++++++++++-----------
 .../apache/iceberg/util/TestEnvironmentUtil.java   |  5 +-
 3 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/.baseline/checkstyle/checkstyle.xml b/.baseline/checkstyle/checkstyle.xml
index 0cb18e4e09..139d26fedb 100644
--- a/.baseline/checkstyle/checkstyle.xml
+++ b/.baseline/checkstyle/checkstyle.xml
@@ -439,6 +439,11 @@
             <property name="illegalClasses" value="org.junit.rules.ExpectedException"/>
             <message key="import.illegal" value="Prefer using Assertions.assertThatThrownBy(...).isInstanceOf(...) instead."/>
         </module>
+        <module name="IllegalImport">
+            <property name="id" value="BanJUnit5AssumptionsUsage"/>
+            <property name="illegalPkgs" value="org.junit.jupiter.api.Assumptions"/>
+            <message key="import.illegal" value="Prefer using Assertions.assumeThat(...).isTrue() instead."/>
+        </module>
         <module name="IllegalImport">
             <property name="id" value="BanHamcrestUsage"/>
             <property name="illegalPkgs" value="org.hamcrest"/>
diff --git a/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java b/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
index d421f6990b..d8ca43bd27 100644
--- a/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
+++ b/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
@@ -79,7 +79,6 @@ import org.apache.iceberg.relocated.com.google.common.collect.Sets;
 import org.apache.iceberg.relocated.com.google.common.collect.Streams;
 import org.apache.iceberg.types.Types;
 import org.apache.iceberg.util.CharSequenceSet;
-import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ValueSource;
@@ -228,7 +227,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testCreateNamespaceWithProperties() {
-    Assumptions.assumeTrue(supportsNamespaceProperties());
+    assumeThat(supportsNamespaceProperties()).isTrue();
 
     C catalog = catalog();
 
@@ -264,7 +263,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testSetNamespaceProperties() {
-    Assumptions.assumeTrue(supportsNamespaceProperties());
+    assumeThat(supportsNamespaceProperties()).isTrue();
 
     C catalog = catalog();
 
@@ -281,7 +280,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testUpdateNamespaceProperties() {
-    Assumptions.assumeTrue(supportsNamespaceProperties());
+    assumeThat(supportsNamespaceProperties()).isTrue();
 
     C catalog = catalog();
 
@@ -307,7 +306,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testUpdateAndSetNamespaceProperties() {
-    Assumptions.assumeTrue(supportsNamespaceProperties());
+    assumeThat(supportsNamespaceProperties()).isTrue();
 
     C catalog = catalog();
 
@@ -334,7 +333,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testSetNamespacePropertiesNamespaceDoesNotExist() {
-    Assumptions.assumeTrue(supportsNamespaceProperties());
+    assumeThat(supportsNamespaceProperties()).isTrue();
 
     C catalog = catalog();
 
@@ -345,7 +344,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testRemoveNamespaceProperties() {
-    Assumptions.assumeTrue(supportsNamespaceProperties());
+    assumeThat(supportsNamespaceProperties()).isTrue();
 
     C catalog = catalog();
 
@@ -366,7 +365,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testRemoveNamespacePropertiesNamespaceDoesNotExist() {
-    Assumptions.assumeTrue(supportsNamespaceProperties());
+    assumeThat(supportsNamespaceProperties()).isTrue();
 
     C catalog = catalog();
 
@@ -454,8 +453,9 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testListNestedNamespaces() {
-    Assumptions.assumeTrue(
-        supportsNestedNamespaces(), "Only valid when the catalog supports nested namespaces");
+    assumeThat(supportsNestedNamespaces())
+        .as("Only valid when the catalog supports nested namespaces")
+        .isTrue();
 
     C catalog = catalog();
 
@@ -500,7 +500,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testNamespaceWithSlash() {
-    Assumptions.assumeTrue(supportsNamesWithSlashes());
+    assumeThat(supportsNamesWithSlashes()).isTrue();
 
     C catalog = catalog();
 
@@ -521,7 +521,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testNamespaceWithDot() {
-    Assumptions.assumeTrue(supportsNamesWithDot());
+    assumeThat(supportsNamesWithDot()).isTrue();
 
     C catalog = catalog();
 
@@ -568,7 +568,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testTableNameWithSlash() {
-    Assumptions.assumeTrue(supportsNamesWithSlashes());
+    assumeThat(supportsNamesWithSlashes()).isTrue();
 
     C catalog = catalog();
 
@@ -594,7 +594,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testTableNameWithDot() {
-    Assumptions.assumeTrue(supportsNamesWithDot());
+    assumeThat(supportsNamesWithDot()).isTrue();
 
     C catalog = catalog();
 
@@ -1333,9 +1333,9 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testUpdateTableSchemaServerSideRetry() {
-    Assumptions.assumeTrue(
-        supportsServerSideRetry(),
-        "Schema update recovery is only supported with server-side retry");
+    assumeThat(supportsServerSideRetry())
+        .as("Schema update recovery is only supported with server-side retry")
+        .isTrue();
     C catalog = catalog();
 
     if (requiresNamespaceCreate()) {
@@ -1471,8 +1471,9 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testUpdateTableSpecServerSideRetry() {
-    Assumptions.assumeTrue(
-        supportsServerSideRetry(), "Spec update recovery is only supported with server-side retry");
+    assumeThat(supportsServerSideRetry())
+        .as("Spec update recovery is only supported with server-side retry")
+        .isTrue();
     C catalog = catalog();
 
     if (requiresNamespaceCreate()) {
@@ -1739,9 +1740,9 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testUpdateTableSortOrderServerSideRetry() {
-    Assumptions.assumeTrue(
-        supportsServerSideRetry(),
-        "Sort order update recovery is only supported with server-side retry");
+    assumeThat(supportsServerSideRetry())
+        .as("Sort order update recovery is only supported with server-side retry")
+        .isTrue();
     C catalog = catalog();
 
     if (requiresNamespaceCreate()) {
@@ -2398,9 +2399,9 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testCreateOrReplaceTransactionConcurrentCreate() {
-    Assumptions.assumeTrue(
-        supportsServerSideRetry(),
-        "Conversion to replace transaction is not supported by REST catalog");
+    assumeThat(supportsServerSideRetry())
+        .as("Conversion to replace transaction is not supported by REST catalog")
+        .isTrue();
 
     C catalog = catalog();
 
@@ -2735,7 +2736,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testConcurrentReplaceTransactionSchemaConflict() {
-    Assumptions.assumeTrue(supportsServerSideRetry(), "Schema conflicts are detected server-side");
+    assumeThat(supportsServerSideRetry()).as("Schema conflicts are detected server-side").isTrue();
 
     C catalog = catalog();
 
@@ -2855,7 +2856,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void testConcurrentReplaceTransactionPartitionSpecConflict() {
-    Assumptions.assumeTrue(supportsServerSideRetry(), "Spec conflicts are detected server-side");
+    assumeThat(supportsServerSideRetry()).as("Spec conflicts are detected server-side").isTrue();
     C catalog = catalog();
 
     if (requiresNamespaceCreate()) {
@@ -3067,7 +3068,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
   @Test
   public void tableCreationWithoutNamespace() {
-    Assumptions.assumeTrue(requiresNamespaceCreate());
+    assumeThat(requiresNamespaceCreate()).isTrue();
 
     assertThatThrownBy(
             () ->
diff --git a/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java b/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java
index d9a573b809..0596f4b5d3 100644
--- a/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java
+++ b/core/src/test/java/org/apache/iceberg/util/TestEnvironmentUtil.java
@@ -19,19 +19,18 @@
 package org.apache.iceberg.util;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assumptions.assumeThat;
 
 import java.util.Map;
 import java.util.Optional;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
-import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.Test;
 
 class TestEnvironmentUtil {
   @Test
   public void testEnvironmentSubstitution() {
     Optional<Map.Entry<String, String>> envEntry = System.getenv().entrySet().stream().findFirst();
-    Assumptions.assumeTrue(
-        envEntry.isPresent(), "Expecting at least one env. variable to be present");
+    assumeThat(envEntry).as("Expecting at least one env. variable to be present").isPresent();
     Map<String, String> resolvedProps =
         EnvironmentUtil.resolveAll(ImmutableMap.of("env-test", "env:" + envEntry.get().getKey()));
     assertThat(resolvedProps)