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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5c64100752 Core: Remove usage of AssertHelpers (#7868)
5c64100752 is described below

commit 5c641007527e23311aef08a9f75aaa0b317430f8
Author: Liu Xiao <[email protected]>
AuthorDate: Wed Jun 21 14:53:46 2023 +0800

    Core: Remove usage of AssertHelpers (#7868)
---
 .../test/java/org/apache/iceberg/ScanTestBase.java | 17 ++---
 .../iceberg/TestBaseIncrementalAppendScan.java     | 27 ++++----
 .../iceberg/TestBaseIncrementalChangelogScan.java  |  9 ++-
 .../java/org/apache/iceberg/TestCatalogUtil.java   | 77 +++++++++++-----------
 .../org/apache/iceberg/TestCreateTransaction.java  | 25 +++----
 .../java/org/apache/iceberg/TestDataTableScan.java | 45 ++++++-------
 .../java/org/apache/iceberg/TestDeleteFiles.java   | 46 +++++++------
 .../java/org/apache/iceberg/TestFastAppend.java    | 39 +++++------
 .../org/apache/iceberg/TestFormatVersions.java     | 25 ++++---
 .../iceberg/TestIncrementalDataTableScan.java      | 34 ++++------
 .../org/apache/iceberg/TestLocationProvider.java   | 44 +++++++------
 .../apache/iceberg/TestManifestListVersions.java   | 29 ++++----
 .../org/apache/iceberg/TestManifestReader.java     |  9 ++-
 .../apache/iceberg/TestManifestReaderStats.java    |  5 +-
 .../apache/iceberg/TestManifestWriterVersions.java |  9 ++-
 .../apache/iceberg/TestMetadataUpdateParser.java   | 16 ++---
 16 files changed, 214 insertions(+), 242 deletions(-)

diff --git a/core/src/test/java/org/apache/iceberg/ScanTestBase.java 
b/core/src/test/java/org/apache/iceberg/ScanTestBase.java
index f33893d816..70b4475bde 100644
--- a/core/src/test/java/org/apache/iceberg/ScanTestBase.java
+++ b/core/src/test/java/org/apache/iceberg/ScanTestBase.java
@@ -31,6 +31,7 @@ import org.apache.iceberg.expressions.Expressions;
 import org.apache.iceberg.io.CloseableIterable;
 import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.types.Types;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Test;
@@ -67,14 +68,14 @@ public abstract class ScanTestBase<
 
   @Test
   public void testTableBothProjectAndSelect() {
-    AssertHelpers.assertThrows(
-        "Cannot set projection schema when columns are selected",
-        IllegalStateException.class,
-        () -> 
newScan().select(Arrays.asList("id")).project(SCHEMA.select("data")));
-    AssertHelpers.assertThrows(
-        "Cannot select columns when projection schema is set",
-        IllegalStateException.class,
-        () -> 
newScan().project(SCHEMA.select("data")).select(Arrays.asList("id")));
+    Assertions.assertThatThrownBy(
+            () -> 
newScan().select(Arrays.asList("id")).project(SCHEMA.select("data")))
+        .isInstanceOf(IllegalStateException.class)
+        .hasMessage("Cannot set projection schema when columns are selected");
+    Assertions.assertThatThrownBy(
+            () -> 
newScan().project(SCHEMA.select("data")).select(Arrays.asList("id")))
+        .isInstanceOf(IllegalStateException.class)
+        .hasMessage("Cannot select columns when projection schema is set");
   }
 
   @Test
diff --git 
a/core/src/test/java/org/apache/iceberg/TestBaseIncrementalAppendScan.java 
b/core/src/test/java/org/apache/iceberg/TestBaseIncrementalAppendScan.java
index 00feaf80ab..5836555593 100644
--- a/core/src/test/java/org/apache/iceberg/TestBaseIncrementalAppendScan.java
+++ b/core/src/test/java/org/apache/iceberg/TestBaseIncrementalAppendScan.java
@@ -19,6 +19,7 @@
 package org.apache.iceberg;
 
 import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -127,23 +128,21 @@ public class TestBaseIncrementalAppendScan
     // scan should fail because snapshot B is not an ancestor of snapshot D
     IncrementalAppendScan scanShouldFail =
         newScan().fromSnapshotExclusive(snapshotBId).toSnapshot(snapshotDId);
-    AssertHelpers.assertThrows(
-        "Should throw exception",
-        IllegalArgumentException.class,
-        String.format(
-            "Starting snapshot (exclusive) %d is not a parent ancestor of end 
snapshot %d",
-            snapshotBId, snapshotDId),
-        () -> Iterables.size(scanShouldFail.planFiles()));
+    Assertions.assertThatThrownBy(() -> 
Iterables.size(scanShouldFail.planFiles()))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage(
+            String.format(
+                "Starting snapshot (exclusive) %d is not a parent ancestor of 
end snapshot %d",
+                snapshotBId, snapshotDId));
 
     // scan should fail because snapshot B is not an ancestor of snapshot D
     IncrementalAppendScan scanShouldFailInclusive =
         newScan().fromSnapshotInclusive(snapshotBId).toSnapshot(snapshotDId);
-    AssertHelpers.assertThrows(
-        "Should throw exception",
-        IllegalArgumentException.class,
-        String.format(
-            "Starting snapshot (inclusive) %d is not an ancestor of end 
snapshot %d",
-            snapshotBId, snapshotDId),
-        () -> Iterables.size(scanShouldFailInclusive.planFiles()));
+    Assertions.assertThatThrownBy(() -> 
Iterables.size(scanShouldFailInclusive.planFiles()))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage(
+            String.format(
+                "Starting snapshot (inclusive) %d is not an ancestor of end 
snapshot %d",
+                snapshotBId, snapshotDId));
   }
 }
diff --git 
a/core/src/test/java/org/apache/iceberg/TestBaseIncrementalChangelogScan.java 
b/core/src/test/java/org/apache/iceberg/TestBaseIncrementalChangelogScan.java
index 1a1844345b..dcda2f354a 100644
--- 
a/core/src/test/java/org/apache/iceberg/TestBaseIncrementalChangelogScan.java
+++ 
b/core/src/test/java/org/apache/iceberg/TestBaseIncrementalChangelogScan.java
@@ -31,6 +31,7 @@ import 
org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableSet;
 import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Test;
@@ -256,11 +257,9 @@ public class TestBaseIncrementalChangelogScan
 
     table.newRowDelta().addDeletes(FILE_A2_DELETES).commit();
 
-    AssertHelpers.assertThrows(
-        "Should complain about delete files",
-        UnsupportedOperationException.class,
-        "Delete files are currently not supported",
-        () -> plan(newScan()));
+    Assertions.assertThatThrownBy(() -> plan(newScan()))
+        .isInstanceOf(UnsupportedOperationException.class)
+        .hasMessage("Delete files are currently not supported in changelog 
scans");
   }
 
   // plans tasks and reorders them to have deterministic order
diff --git a/core/src/test/java/org/apache/iceberg/TestCatalogUtil.java 
b/core/src/test/java/org/apache/iceberg/TestCatalogUtil.java
index 75c27c7fc8..421514c6b8 100644
--- a/core/src/test/java/org/apache/iceberg/TestCatalogUtil.java
+++ b/core/src/test/java/org/apache/iceberg/TestCatalogUtil.java
@@ -73,13 +73,14 @@ public class TestCatalogUtil {
     options.put("key", "val");
     Configuration hadoopConf = new Configuration();
     String name = "custom";
-    AssertHelpers.assertThrows(
-        "must have no-arg constructor",
-        IllegalArgumentException.class,
-        "NoSuchMethodException: 
org.apache.iceberg.TestCatalogUtil$TestCatalogBadConstructor.<init>()",
-        () ->
-            CatalogUtil.loadCatalog(
-                TestCatalogBadConstructor.class.getName(), name, options, 
hadoopConf));
+    Assertions.assertThatThrownBy(
+            () ->
+                CatalogUtil.loadCatalog(
+                    TestCatalogBadConstructor.class.getName(), name, options, 
hadoopConf))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith("Cannot initialize Catalog implementation")
+        .hasMessageContaining(
+            "NoSuchMethodException: 
org.apache.iceberg.TestCatalogUtil$TestCatalogBadConstructor.<init>()");
   }
 
   @Test
@@ -89,13 +90,13 @@ public class TestCatalogUtil {
     Configuration hadoopConf = new Configuration();
     String name = "custom";
 
-    AssertHelpers.assertThrows(
-        "must implement catalog",
-        IllegalArgumentException.class,
-        "does not implement Catalog",
-        () ->
-            CatalogUtil.loadCatalog(
-                TestCatalogNoInterface.class.getName(), name, options, 
hadoopConf));
+    Assertions.assertThatThrownBy(
+            () ->
+                CatalogUtil.loadCatalog(
+                    TestCatalogNoInterface.class.getName(), name, options, 
hadoopConf))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith("Cannot initialize Catalog")
+        .hasMessageContaining("does not implement Catalog");
   }
 
   @Test
@@ -106,11 +107,10 @@ public class TestCatalogUtil {
     String name = "custom";
 
     String impl = TestCatalogErrorConstructor.class.getName();
-    AssertHelpers.assertThrows(
-        "must be able to initialize catalog",
-        IllegalArgumentException.class,
-        "NoClassDefFoundError: Error while initializing class",
-        () -> CatalogUtil.loadCatalog(impl, name, options, hadoopConf));
+    Assertions.assertThatThrownBy(() -> CatalogUtil.loadCatalog(impl, name, 
options, hadoopConf))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith("Cannot initialize Catalog implementation")
+        .hasMessageContaining("NoClassDefFoundError: Error while initializing 
class");
   }
 
   @Test
@@ -120,11 +120,10 @@ public class TestCatalogUtil {
     Configuration hadoopConf = new Configuration();
     String name = "custom";
     String impl = "CatalogDoesNotExist";
-    AssertHelpers.assertThrows(
-        "catalog must exist",
-        IllegalArgumentException.class,
-        "java.lang.ClassNotFoundException: CatalogDoesNotExist",
-        () -> CatalogUtil.loadCatalog(impl, name, options, hadoopConf));
+    Assertions.assertThatThrownBy(() -> CatalogUtil.loadCatalog(impl, name, 
options, hadoopConf))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith("Cannot initialize Catalog implementation")
+        .hasMessageContaining("java.lang.ClassNotFoundException: 
CatalogDoesNotExist");
   }
 
   @Test
@@ -159,20 +158,20 @@ public class TestCatalogUtil {
 
   @Test
   public void loadCustomFileIO_badArg() {
-    AssertHelpers.assertThrows(
-        "cannot find constructor",
-        IllegalArgumentException.class,
-        "missing no-arg constructor",
-        () -> CatalogUtil.loadFileIO(TestFileIOBadArg.class.getName(), 
Maps.newHashMap(), null));
+    Assertions.assertThatThrownBy(
+            () -> CatalogUtil.loadFileIO(TestFileIOBadArg.class.getName(), 
Maps.newHashMap(), null))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith("Cannot initialize FileIO, missing no-arg 
constructor");
   }
 
   @Test
   public void loadCustomFileIO_badClass() {
-    AssertHelpers.assertThrows(
-        "cannot cast",
-        IllegalArgumentException.class,
-        "does not implement FileIO",
-        () -> CatalogUtil.loadFileIO(TestFileIONotImpl.class.getName(), 
Maps.newHashMap(), null));
+    Assertions.assertThatThrownBy(
+            () ->
+                CatalogUtil.loadFileIO(TestFileIONotImpl.class.getName(), 
Maps.newHashMap(), null))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith("Cannot initialize FileIO")
+        .hasMessageContaining("does not implement FileIO");
   }
 
   @Test
@@ -182,12 +181,10 @@ public class TestCatalogUtil {
     options.put(CatalogUtil.ICEBERG_CATALOG_TYPE, "hive");
     Configuration hadoopConf = new Configuration();
     String name = "custom";
-
-    AssertHelpers.assertThrows(
-        "Should complain about both configs being set",
-        IllegalArgumentException.class,
-        "both type and catalog-impl are set",
-        () -> CatalogUtil.buildIcebergCatalog(name, options, hadoopConf));
+    Assertions.assertThatThrownBy(() -> CatalogUtil.buildIcebergCatalog(name, 
options, hadoopConf))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage(
+            "Cannot create catalog custom, both type and catalog-impl are set: 
type=hive, catalog-impl=CustomCatalog");
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/TestCreateTransaction.java 
b/core/src/test/java/org/apache/iceberg/TestCreateTransaction.java
index 157e123323..4240184e91 100644
--- a/core/src/test/java/org/apache/iceberg/TestCreateTransaction.java
+++ b/core/src/test/java/org/apache/iceberg/TestCreateTransaction.java
@@ -28,6 +28,7 @@ import 
org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.iceberg.relocated.com.google.common.collect.Sets;
 import org.apache.iceberg.types.TypeUtil;
 import org.apache.iceberg.types.Types;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -300,11 +301,9 @@ public class TestCreateTransaction extends TableTestBase {
 
     txn.updateProperties().set("test-property", "test-value"); // not committed
 
-    AssertHelpers.assertThrows(
-        "Should reject commit when last operation has not committed",
-        IllegalStateException.class,
-        "Cannot create new DeleteFiles: last operation has not committed",
-        txn::newDelete);
+    Assertions.assertThatThrownBy(txn::newDelete)
+        .isInstanceOf(IllegalStateException.class)
+        .hasMessage("Cannot create new DeleteFiles: last operation has not 
committed");
   }
 
   @Test
@@ -323,11 +322,9 @@ public class TestCreateTransaction extends TableTestBase {
 
     txn.updateProperties().set("test-property", "test-value"); // not committed
 
-    AssertHelpers.assertThrows(
-        "Should reject commit when last operation has not committed",
-        IllegalStateException.class,
-        "Cannot commit transaction: last operation has not committed",
-        txn::commitTransaction);
+    Assertions.assertThatThrownBy(txn::commitTransaction)
+        .isInstanceOf(IllegalStateException.class)
+        .hasMessage("Cannot commit transaction: last operation has not 
committed");
   }
 
   @Test
@@ -360,11 +357,9 @@ public class TestCreateTransaction extends TableTestBase {
     Assert.assertFalse(
         "Table should not have any snapshots", 
conflict.snapshots().iterator().hasNext());
 
-    AssertHelpers.assertThrows(
-        "Transaction commit should fail",
-        CommitFailedException.class,
-        "Commit failed: table was updated",
-        txn::commitTransaction);
+    Assertions.assertThatThrownBy(txn::commitTransaction)
+        .isInstanceOf(CommitFailedException.class)
+        .hasMessageStartingWith("Commit failed: table was updated");
 
     Assert.assertEquals(
         "Should clean up metadata",
diff --git a/core/src/test/java/org/apache/iceberg/TestDataTableScan.java 
b/core/src/test/java/org/apache/iceberg/TestDataTableScan.java
index e221310a01..8541a96c8d 100644
--- a/core/src/test/java/org/apache/iceberg/TestDataTableScan.java
+++ b/core/src/test/java/org/apache/iceberg/TestDataTableScan.java
@@ -25,6 +25,7 @@ import org.apache.iceberg.io.CloseableIterable;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
 import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Test;
@@ -124,11 +125,10 @@ public class TestDataTableScan extends 
ScanTestBase<TableScan, FileScanTask, Com
     table.newFastAppend().appendFile(FILE_A).appendFile(FILE_B).commit();
     table.manageSnapshots().createTag("tagB", 
table.currentSnapshot().snapshotId()).commit();
 
-    AssertHelpers.assertThrows(
-        "Should throw when attempting to use a ref for scanning when a 
snapshot is set",
-        IllegalArgumentException.class,
-        "Cannot override ref, already set snapshot id=1",
-        () -> 
table.newScan().useSnapshot(table.currentSnapshot().snapshotId()).useRef("tagB"));
+    Assertions.assertThatThrownBy(
+            () -> 
table.newScan().useSnapshot(table.currentSnapshot().snapshotId()).useRef("tagB"))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot override ref, already set snapshot id=1");
   }
 
   @Test
@@ -138,11 +138,10 @@ public class TestDataTableScan extends 
ScanTestBase<TableScan, FileScanTask, Com
     table.newFastAppend().appendFile(FILE_B).commit();
     table.manageSnapshots().createTag("tagB", 
table.currentSnapshot().snapshotId()).commit();
 
-    AssertHelpers.assertThrows(
-        "Should throw when attempting to use a snapshot for scanning when a 
ref is set",
-        IllegalArgumentException.class,
-        "Cannot override snapshot, already set snapshot id=2",
-        () -> 
table.newScan().useRef("tagB").useSnapshot(snapshotA.snapshotId()));
+    Assertions.assertThatThrownBy(
+            () -> 
table.newScan().useRef("tagB").useSnapshot(snapshotA.snapshotId()))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot override snapshot, already set snapshot id=2");
   }
 
   @Test
@@ -152,11 +151,11 @@ public class TestDataTableScan extends 
ScanTestBase<TableScan, FileScanTask, Com
         .manageSnapshots()
         .createBranch("testBranch", table.currentSnapshot().snapshotId())
         .commit();
-    AssertHelpers.assertThrows(
-        "Should throw when attempting to use a snapshot for scanning when a 
ref is set",
-        IllegalArgumentException.class,
-        "Cannot override snapshot, already set snapshot id=1",
-        () -> 
table.newScan().useRef("testBranch").asOfTime(System.currentTimeMillis()));
+
+    Assertions.assertThatThrownBy(
+            () -> 
table.newScan().useRef("testBranch").asOfTime(System.currentTimeMillis()))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot override snapshot, already set snapshot id=1");
   }
 
   @Test
@@ -166,20 +165,16 @@ public class TestDataTableScan extends 
ScanTestBase<TableScan, FileScanTask, Com
     table.newFastAppend().appendFile(FILE_B).commit();
     table.manageSnapshots().createTag("tagB", 
table.currentSnapshot().snapshotId()).commit();
 
-    AssertHelpers.assertThrows(
-        "Should throw when attempting to use multiple refs",
-        IllegalArgumentException.class,
-        "Cannot override ref, already set snapshot id=2",
-        () -> table.newScan().useRef("tagB").useRef("tagA"));
+    Assertions.assertThatThrownBy(() -> 
table.newScan().useRef("tagB").useRef("tagA"))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot override ref, already set snapshot id=2");
   }
 
   @Test
   public void testSettingInvalidRefFails() {
-    AssertHelpers.assertThrows(
-        "Should throw when attempting to use an invalid ref for scanning",
-        IllegalArgumentException.class,
-        "Cannot find ref nonexisting",
-        () -> table.newScan().useRef("nonexisting"));
+    Assertions.assertThatThrownBy(() -> table.newScan().useRef("nonexisting"))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot find ref nonexisting");
   }
 
   private void validateExpectedFileScanTasks(
diff --git a/core/src/test/java/org/apache/iceberg/TestDeleteFiles.java 
b/core/src/test/java/org/apache/iceberg/TestDeleteFiles.java
index f5370d1aa8..4e4565306c 100644
--- a/core/src/test/java/org/apache/iceberg/TestDeleteFiles.java
+++ b/core/src/test/java/org/apache/iceberg/TestDeleteFiles.java
@@ -34,6 +34,7 @@ import 
org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.iceberg.types.Types;
 import org.apache.iceberg.util.StructLikeWrapper;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Test;
@@ -284,15 +285,14 @@ public class TestDeleteFiles extends TableTestBase {
 
     commit(table, table.newFastAppend().appendFile(dataFile), branch);
 
-    AssertHelpers.assertThrows(
-        "Should reject as not all rows match filter",
-        ValidationException.class,
-        "Cannot delete file where some, but not all, rows match filter",
-        () ->
-            commit(
-                table,
-                
table.newDelete().deleteFromRowFilter(Expressions.equal("data", "aa")),
-                branch));
+    Assertions.assertThatThrownBy(
+            () ->
+                commit(
+                    table,
+                    
table.newDelete().deleteFromRowFilter(Expressions.equal("data", "aa")),
+                    branch))
+        .isInstanceOf(ValidationException.class)
+        .hasMessageStartingWith("Cannot delete file where some, but not all, 
rows match filter");
   }
 
   @Test
@@ -301,21 +301,19 @@ public class TestDeleteFiles extends TableTestBase {
 
     Expression rowFilter = Expressions.lessThan("iD", 5);
 
-    AssertHelpers.assertThrows(
-        "Should use case sensitive binding by default",
-        ValidationException.class,
-        "Cannot find field 'iD'",
-        () -> commit(table, table.newDelete().deleteFromRowFilter(rowFilter), 
branch));
-
-    AssertHelpers.assertThrows(
-        "Should fail with case sensitive binding",
-        ValidationException.class,
-        "Cannot find field 'iD'",
-        () ->
-            commit(
-                table,
-                
table.newDelete().deleteFromRowFilter(rowFilter).caseSensitive(true),
-                branch));
+    Assertions.assertThatThrownBy(
+            () -> commit(table, 
table.newDelete().deleteFromRowFilter(rowFilter), branch))
+        .isInstanceOf(ValidationException.class)
+        .hasMessageStartingWith("Cannot find field 'iD'");
+
+    Assertions.assertThatThrownBy(
+            () ->
+                commit(
+                    table,
+                    
table.newDelete().deleteFromRowFilter(rowFilter).caseSensitive(true),
+                    branch))
+        .isInstanceOf(ValidationException.class)
+        .hasMessageStartingWith("Cannot find field 'iD'");
 
     Snapshot deleteSnapshot =
         commit(
diff --git a/core/src/test/java/org/apache/iceberg/TestFastAppend.java 
b/core/src/test/java/org/apache/iceberg/TestFastAppend.java
index 13445d8e33..6ed52fd5ad 100644
--- a/core/src/test/java/org/apache/iceberg/TestFastAppend.java
+++ b/core/src/test/java/org/apache/iceberg/TestFastAppend.java
@@ -239,11 +239,9 @@ public class TestFastAppend extends TableTestBase {
     ManifestFile newManifest = pending.allManifests(FILE_IO).get(0);
     Assert.assertTrue("Should create new manifest", new 
File(newManifest.path()).exists());
 
-    AssertHelpers.assertThrows(
-        "Should retry 4 times and throw last failure",
-        CommitFailedException.class,
-        "Injected failure",
-        append::commit);
+    Assertions.assertThatThrownBy(append::commit)
+        .isInstanceOf(CommitFailedException.class)
+        .hasMessage("Injected failure");
 
     Assert.assertFalse("Should clean up new manifest", new 
File(newManifest.path()).exists());
   }
@@ -260,11 +258,9 @@ public class TestFastAppend extends TableTestBase {
     ManifestFile newManifest = pending.allManifests(FILE_IO).get(0);
     Assert.assertTrue("Should create new manifest", new 
File(newManifest.path()).exists());
 
-    AssertHelpers.assertThrows(
-        "Should retry 4 times and throw last failure",
-        CommitFailedException.class,
-        "Injected failure",
-        append::commit);
+    Assertions.assertThatThrownBy(append::commit)
+        .isInstanceOf(CommitFailedException.class)
+        .hasMessage("Injected failure");
 
     Assert.assertFalse("Should clean up new manifest", new 
File(newManifest.path()).exists());
   }
@@ -376,8 +372,9 @@ public class TestFastAppend extends TableTestBase {
     AppendFiles append = table.newAppend();
     append.appendManifest(manifest);
 
-    AssertHelpers.assertThrows(
-        "Should reject commit", CommitFailedException.class, "Injected 
failure", append::commit);
+    Assertions.assertThatThrownBy(append::commit)
+        .isInstanceOf(CommitFailedException.class)
+        .hasMessage("Injected failure");
 
     Assert.assertTrue("Append manifest should not be deleted", new 
File(manifest.path()).exists());
   }
@@ -391,19 +388,17 @@ public class TestFastAppend extends TableTestBase {
 
     ManifestFile manifestWithExistingFiles =
         writeManifest("manifest-file-1.avro", manifestEntry(Status.EXISTING, 
null, FILE_A));
-    AssertHelpers.assertThrows(
-        "Should reject commit",
-        IllegalArgumentException.class,
-        "Cannot append manifest with existing files",
-        () -> 
table.newFastAppend().appendManifest(manifestWithExistingFiles).commit());
+    Assertions.assertThatThrownBy(
+            () -> 
table.newFastAppend().appendManifest(manifestWithExistingFiles).commit())
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot append manifest with existing files");
 
     ManifestFile manifestWithDeletedFiles =
         writeManifest("manifest-file-2.avro", manifestEntry(Status.DELETED, 
null, FILE_A));
-    AssertHelpers.assertThrows(
-        "Should reject commit",
-        IllegalArgumentException.class,
-        "Cannot append manifest with deleted files",
-        () -> 
table.newFastAppend().appendManifest(manifestWithDeletedFiles).commit());
+    Assertions.assertThatThrownBy(
+            () -> 
table.newFastAppend().appendManifest(manifestWithDeletedFiles).commit())
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot append manifest with deleted files");
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/TestFormatVersions.java 
b/core/src/test/java/org/apache/iceberg/TestFormatVersions.java
index f3d31e4db3..b4f80088d2 100644
--- a/core/src/test/java/org/apache/iceberg/TestFormatVersions.java
+++ b/core/src/test/java/org/apache/iceberg/TestFormatVersions.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iceberg;
 
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -48,11 +49,9 @@ public class TestFormatVersions extends TableTestBase {
 
     Assert.assertEquals("Should report v2", 2, ops.current().formatVersion());
 
-    AssertHelpers.assertThrows(
-        "Should reject a version downgrade",
-        IllegalArgumentException.class,
-        "Cannot downgrade",
-        () -> ops.current().upgradeToFormatVersion(1));
+    Assertions.assertThatThrownBy(() -> 
ops.current().upgradeToFormatVersion(1))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot downgrade v2 table to v1");
 
     Assert.assertEquals("Should report v2", 2, ops.current().formatVersion());
   }
@@ -61,14 +60,14 @@ public class TestFormatVersions extends TableTestBase {
   public void testFormatVersionUpgradeNotSupported() {
     TableOperations ops = table.ops();
     TableMetadata base = ops.current();
-    AssertHelpers.assertThrows(
-        "Should reject an unsupported version upgrade",
-        IllegalArgumentException.class,
-        "Cannot upgrade table to unsupported format version",
-        () ->
-            ops.commit(
-                base,
-                
base.upgradeToFormatVersion(TableMetadata.SUPPORTED_TABLE_FORMAT_VERSION + 1)));
+
+    Assertions.assertThatThrownBy(
+            () ->
+                ops.commit(
+                    base,
+                    
base.upgradeToFormatVersion(TableMetadata.SUPPORTED_TABLE_FORMAT_VERSION + 1)))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot upgrade table to unsupported format version: v3 
(supported: v2)");
 
     Assert.assertEquals("Should report v1", 1, ops.current().formatVersion());
   }
diff --git 
a/core/src/test/java/org/apache/iceberg/TestIncrementalDataTableScan.java 
b/core/src/test/java/org/apache/iceberg/TestIncrementalDataTableScan.java
index 1e6678fc33..63f0ed6dd7 100644
--- a/core/src/test/java/org/apache/iceberg/TestIncrementalDataTableScan.java
+++ b/core/src/test/java/org/apache/iceberg/TestIncrementalDataTableScan.java
@@ -31,6 +31,7 @@ import org.apache.iceberg.io.CloseableIterable;
 import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -56,26 +57,20 @@ public class TestIncrementalDataTableScan extends 
TableTestBase {
   @Test
   public void testInvalidScans() {
     add(table.newAppend(), files("A"));
-    AssertHelpers.assertThrows(
-        "from and to snapshots cannot be the same, since from snapshot is 
exclusive and not part of the scan",
-        IllegalArgumentException.class,
-        "from and to snapshot ids cannot be the same",
-        () -> appendsBetweenScan(1, 1));
+    Assertions.assertThatThrownBy(() -> appendsBetweenScan(1, 1))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("from and to snapshot ids cannot be the same");
 
     add(table.newAppend(), files("B"));
     add(table.newAppend(), files("C"));
     add(table.newAppend(), files("D"));
     add(table.newAppend(), files("E"));
-    AssertHelpers.assertThrows(
-        "Check refinement api",
-        IllegalArgumentException.class,
-        "from snapshot id 1 not in existing snapshot ids range (2, 4]",
-        () -> table.newScan().appendsBetween(2, 5).appendsBetween(1, 4));
-    AssertHelpers.assertThrows(
-        "Check refinement api",
-        IllegalArgumentException.class,
-        "to snapshot id 3 not in existing snapshot ids range (1, 2]",
-        () -> table.newScan().appendsBetween(1, 2).appendsBetween(1, 3));
+    Assertions.assertThatThrownBy(() -> table.newScan().appendsBetween(2, 
5).appendsBetween(1, 4))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("from snapshot id 1 not in existing snapshot ids range (2, 
4]");
+    Assertions.assertThatThrownBy(() -> table.newScan().appendsBetween(1, 
2).appendsBetween(1, 3))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("to snapshot id 3 not in existing snapshot ids range (1, 
2]");
   }
 
   @Test
@@ -140,11 +135,10 @@ public class TestIncrementalDataTableScan extends 
TableTestBase {
     filesMatch(Lists.newArrayList("I"), appendsBetweenScan(7, 8));
 
     overwrite(table.newOverwrite(), files("H"), files("E")); // 9
-    AssertHelpers.assertThrows(
-        "Overwrites are not supported for Incremental scan",
-        UnsupportedOperationException.class,
-        "Found overwrite operation, cannot support incremental data in 
snapshots (8, 9]",
-        () -> appendsBetweenScan(8, 9));
+    Assertions.assertThatThrownBy(() -> appendsBetweenScan(8, 9))
+        .isInstanceOf(UnsupportedOperationException.class)
+        .hasMessage(
+            "Found overwrite operation, cannot support incremental data in 
snapshots (8, 9]");
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/TestLocationProvider.java 
b/core/src/test/java/org/apache/iceberg/TestLocationProvider.java
index 2b9cc47e93..6afc7f0fe7 100644
--- a/core/src/test/java/org/apache/iceberg/TestLocationProvider.java
+++ b/core/src/test/java/org/apache/iceberg/TestLocationProvider.java
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Map;
 import org.apache.iceberg.io.LocationProvider;
 import org.apache.iceberg.relocated.com.google.common.base.Splitter;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -172,13 +173,16 @@ public class TestLocationProvider extends TableTestBase {
         .set(TableProperties.WRITE_LOCATION_PROVIDER_IMPL, nonExistentImpl)
         .commit();
 
-    AssertHelpers.assertThrows(
-        "Non-existent implementation should fail on finding constructor",
-        IllegalArgumentException.class,
-        String.format(
-            "Unable to find a constructor for implementation %s of %s. ",
-            nonExistentImpl, LocationProvider.class),
-        () -> table.locationProvider());
+    Assertions.assertThatThrownBy(() -> table.locationProvider())
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith(
+            String.format(
+                "Unable to find a constructor for implementation %s of %s. ",
+                nonExistentImpl, LocationProvider.class))
+        .hasMessageEndingWith(
+            "Make sure the implementation is in classpath, and that it either "
+                + "has a public no-arg constructor or a two-arg constructor "
+                + "taking in the string base table location and its property 
string map.");
   }
 
   @Test
@@ -193,13 +197,12 @@ public class TestLocationProvider extends TableTestBase {
         .set(TableProperties.WRITE_LOCATION_PROVIDER_IMPL, invalidImpl)
         .commit();
 
-    AssertHelpers.assertThrows(
-        "Class with missing interface implementation should fail on 
instantiation.",
-        IllegalArgumentException.class,
-        String.format(
-            "Provided implementation for dynamic instantiation should 
implement %s",
-            LocationProvider.class),
-        () -> table.locationProvider());
+    Assertions.assertThatThrownBy(() -> table.locationProvider())
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage(
+            String.format(
+                "Provided implementation for dynamic instantiation should 
implement %s.",
+                LocationProvider.class));
   }
 
   @Test
@@ -214,13 +217,12 @@ public class TestLocationProvider extends TableTestBase {
         .set(TableProperties.WRITE_LOCATION_PROVIDER_IMPL, invalidImpl)
         .commit();
 
-    AssertHelpers.assertThrows(
-        "Implementation with invalid arg types should fail on finding 
constructor",
-        IllegalArgumentException.class,
-        String.format(
-            "Unable to find a constructor for implementation %s of %s. ",
-            invalidImpl, LocationProvider.class),
-        () -> table.locationProvider());
+    Assertions.assertThatThrownBy(() -> table.locationProvider())
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith(
+            String.format(
+                "Unable to find a constructor for implementation %s of %s. ",
+                invalidImpl, LocationProvider.class));
   }
 
   @Test
diff --git 
a/core/src/test/java/org/apache/iceberg/TestManifestListVersions.java 
b/core/src/test/java/org/apache/iceberg/TestManifestListVersions.java
index eab3d31094..a95379e4ca 100644
--- a/core/src/test/java/org/apache/iceberg/TestManifestListVersions.java
+++ b/core/src/test/java/org/apache/iceberg/TestManifestListVersions.java
@@ -23,7 +23,9 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
+import org.apache.avro.AvroRuntimeException;
 import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
 import org.apache.avro.generic.GenericRecordBuilder;
 import org.apache.iceberg.avro.Avro;
 import org.apache.iceberg.avro.AvroSchemaUtil;
@@ -37,6 +39,7 @@ import 
org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.iceberg.types.Conversions;
 import org.apache.iceberg.types.Types;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
@@ -99,11 +102,9 @@ public class TestManifestListVersions {
 
   @Test
   public void testV1WriteDeleteManifest() {
-    AssertHelpers.assertThrows(
-        "Should fail to write a DELETE manifest to v1",
-        IllegalArgumentException.class,
-        "Cannot store delete manifests in a v1 table",
-        () -> writeManifestList(TEST_DELETE_MANIFEST, 1));
+    Assertions.assertThatThrownBy(() -> 
writeManifestList(TEST_DELETE_MANIFEST, 1))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot store delete manifests in a v1 table");
   }
 
   @Test
@@ -173,9 +174,9 @@ public class TestManifestListVersions {
         "Existing rows count", EXISTING_ROWS, (long) 
generic.get("existing_rows_count"));
     Assert.assertEquals(
         "Deleted rows count", DELETED_ROWS, (long) 
generic.get("deleted_rows_count"));
-    AssertHelpers.assertEmptyAvroField(generic, 
ManifestFile.MANIFEST_CONTENT.name());
-    AssertHelpers.assertEmptyAvroField(generic, 
ManifestFile.SEQUENCE_NUMBER.name());
-    AssertHelpers.assertEmptyAvroField(generic, 
ManifestFile.MIN_SEQUENCE_NUMBER.name());
+    assertEmptyAvroField(generic, ManifestFile.MANIFEST_CONTENT.name());
+    assertEmptyAvroField(generic, ManifestFile.SEQUENCE_NUMBER.name());
+    assertEmptyAvroField(generic, ManifestFile.MIN_SEQUENCE_NUMBER.name());
   }
 
   @Test
@@ -201,9 +202,9 @@ public class TestManifestListVersions {
         "Existing rows count", EXISTING_ROWS, (long) 
generic.get("existing_rows_count"));
     Assert.assertEquals(
         "Deleted rows count", DELETED_ROWS, (long) 
generic.get("deleted_rows_count"));
-    AssertHelpers.assertEmptyAvroField(generic, 
ManifestFile.MANIFEST_CONTENT.name());
-    AssertHelpers.assertEmptyAvroField(generic, 
ManifestFile.SEQUENCE_NUMBER.name());
-    AssertHelpers.assertEmptyAvroField(generic, 
ManifestFile.MIN_SEQUENCE_NUMBER.name());
+    assertEmptyAvroField(generic, ManifestFile.MANIFEST_CONTENT.name());
+    assertEmptyAvroField(generic, ManifestFile.SEQUENCE_NUMBER.name());
+    assertEmptyAvroField(generic, ManifestFile.MIN_SEQUENCE_NUMBER.name());
   }
 
   @Test
@@ -360,4 +361,10 @@ public class TestManifestListVersions {
     Assert.assertEquals("Should contain one manifest", 1, manifests.size());
     return manifests.get(0);
   }
+
+  private void assertEmptyAvroField(GenericRecord record, String field) {
+    Assertions.assertThatThrownBy(() -> record.get(field))
+        .isInstanceOf(AvroRuntimeException.class)
+        .hasMessage("Not a valid schema field: " + field);
+  }
 }
diff --git a/core/src/test/java/org/apache/iceberg/TestManifestReader.java 
b/core/src/test/java/org/apache/iceberg/TestManifestReader.java
index dfc84200fd..09ed1e4485 100644
--- a/core/src/test/java/org/apache/iceberg/TestManifestReader.java
+++ b/core/src/test/java/org/apache/iceberg/TestManifestReader.java
@@ -27,6 +27,7 @@ import 
org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.iceberg.relocated.com.google.common.collect.Streams;
 import org.apache.iceberg.types.Types;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Test;
@@ -76,11 +77,9 @@ public class TestManifestReader extends TableTestBase {
   @Test
   public void testInvalidUsage() throws IOException {
     ManifestFile manifest = writeManifest(FILE_A, FILE_B);
-    AssertHelpers.assertThrows(
-        "Should not be possible to read manifest without explicit snapshot ids 
and inheritable metadata",
-        IllegalArgumentException.class,
-        "Cannot read from ManifestFile with null (unassigned) snapshot ID",
-        () -> ManifestFiles.read(manifest, FILE_IO));
+    Assertions.assertThatThrownBy(() -> ManifestFiles.read(manifest, FILE_IO))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot read from ManifestFile with null (unassigned) 
snapshot ID");
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/TestManifestReaderStats.java 
b/core/src/test/java/org/apache/iceberg/TestManifestReaderStats.java
index e794539d6d..082800238a 100644
--- a/core/src/test/java/org/apache/iceberg/TestManifestReaderStats.java
+++ b/core/src/test/java/org/apache/iceberg/TestManifestReaderStats.java
@@ -275,9 +275,6 @@ public class TestManifestReaderStats extends TableTestBase {
 
   private void assertNullRecordCount(DataFile dataFile) {
     // record count is a primitive type, accessing null record count will 
throw NPE
-    AssertHelpers.assertThrows(
-        "Should throw NPE when accessing non-populated record count field",
-        NullPointerException.class,
-        dataFile::recordCount);
+    
Assertions.assertThatThrownBy(dataFile::recordCount).isInstanceOf(NullPointerException.class);
   }
 }
diff --git 
a/core/src/test/java/org/apache/iceberg/TestManifestWriterVersions.java 
b/core/src/test/java/org/apache/iceberg/TestManifestWriterVersions.java
index 7184b4969c..740791b255 100644
--- a/core/src/test/java/org/apache/iceberg/TestManifestWriterVersions.java
+++ b/core/src/test/java/org/apache/iceberg/TestManifestWriterVersions.java
@@ -33,6 +33,7 @@ import 
org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.iceberg.types.Conversions;
 import org.apache.iceberg.types.Types;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
@@ -111,11 +112,9 @@ public class TestManifestWriterVersions {
 
   @Test
   public void testV1WriteDelete() {
-    AssertHelpers.assertThrows(
-        "Should fail to write a delete manifest for v1",
-        IllegalArgumentException.class,
-        "Cannot write delete files in a v1 table",
-        () -> writeDeleteManifest(1));
+    Assertions.assertThatThrownBy(() -> writeDeleteManifest(1))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot write delete files in a v1 table");
   }
 
   @Test
diff --git 
a/core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java 
b/core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java
index aa7c120aeb..09259aaa37 100644
--- a/core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java
+++ b/core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java
@@ -56,11 +56,9 @@ public class TestMetadataUpdateParser {
         ImmutableList.of("{\"action\":null,\"format-version\":2}", 
"{\"format-version\":2}");
 
     for (String json : invalidJson) {
-      AssertHelpers.assertThrows(
-          "MetadataUpdate without a recognized action should fail to 
deserialize",
-          IllegalArgumentException.class,
-          "Cannot parse metadata update. Missing field: action",
-          () -> MetadataUpdateParser.fromJson(json));
+      Assertions.assertThatThrownBy(() -> MetadataUpdateParser.fromJson(json))
+          .isInstanceOf(IllegalArgumentException.class)
+          .hasMessage("Cannot parse metadata update. Missing field: action");
     }
   }
 
@@ -702,11 +700,9 @@ public class TestMetadataUpdateParser {
     props.put("prop2", null);
     String propsMap = "{\"prop1\":\"val1\",\"prop2\":null}";
     String json = String.format("{\"action\":\"%s\",\"updated\":%s}", action, 
propsMap);
-    AssertHelpers.assertThrows(
-        "Parsing updates from SetProperties with a property set to null should 
throw",
-        IllegalArgumentException.class,
-        "Cannot parse to a string value: prop2: null",
-        () -> MetadataUpdateParser.fromJson(json));
+    Assertions.assertThatThrownBy(() -> MetadataUpdateParser.fromJson(json))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot parse to a string value: prop2: null");
   }
 
   @Test


Reply via email to