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

huaxingao 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 95aac2f4b1 Core, Spark: Add custom assert class of 
RewriteTablePathResultAssert (#18932)
95aac2f4b1 is described below

commit 95aac2f4b100db7f8f37563d58d09daf01196d47
Author: Hongyue/Steve Zhang <[email protected]>
AuthorDate: Thu Nov 19 14:49:31 2026 -0800

    Core, Spark: Add custom assert class of RewriteTablePathResultAssert 
(#18932)
    
    * Spark 4.2: Add custom assert class of RewriteTablePathResultAssert
    
    Moveaway to simplfied fluent based assertion in RewriteTablePathResult to 
assert based on composition and soft assertion.
    
    Generated-by: Claude Code
    
    * Spark 4.2: Return void from hasNoOtherFiles
    
    hasNoOtherFiles fails on any kind not counted earlier in the chain, so
    a count placed after it makes the assertion fail even when that count
    is correct. Returning void makes it the last call of the chain.
    
    Generated-by: Claude Code
    
    * Core: Move RewriteTablePathResultAssert to core test artifacts
    
    Every Spark version carries an identical TestRewriteTablePathsAction, so
    the assert is shared through the iceberg-core test artifacts instead of
    being copied per version. hasNoFileList becomes hasFileListLocation: the
    N/A value for a disabled file list is a Spark implementation detail that
    core cannot reference, so the Spark test passes it in.
    
    Generated-by: Claude Code
    
    * Spark 3.5, 4.0, 4.1: Use RewriteTablePathResultAssert in rewrite path 
tests
    
    Replace checkFileNum in TestRewriteTablePathsAction with the shared
    RewriteTablePathResultAssert, so all Spark versions read the same as the
    4.2 test. The test class is identical across the four versions.
    
    Generated-by: Claude Code
---
 .../actions/RewriteTablePathResultAssert.java      | 242 ++++++++++++++
 .../spark/actions/TestRewriteTablePathsAction.java | 353 ++++++++++++---------
 .../spark/actions/TestRewriteTablePathsAction.java | 353 ++++++++++++---------
 .../spark/actions/TestRewriteTablePathsAction.java | 353 ++++++++++++---------
 .../spark/actions/TestRewriteTablePathsAction.java | 353 ++++++++++++---------
 5 files changed, 1046 insertions(+), 608 deletions(-)

diff --git 
a/core/src/test/java/org/apache/iceberg/actions/RewriteTablePathResultAssert.java
 
b/core/src/test/java/org/apache/iceberg/actions/RewriteTablePathResultAssert.java
new file mode 100644
index 0000000000..f01c348ffa
--- /dev/null
+++ 
b/core/src/test/java/org/apache/iceberg/actions/RewriteTablePathResultAssert.java
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.actions;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import org.apache.iceberg.RewriteTablePathUtil;
+import org.apache.iceberg.util.Pair;
+import org.assertj.core.api.AbstractAssert;
+
+public class RewriteTablePathResultAssert
+    extends AbstractAssert<RewriteTablePathResultAssert, 
RewriteTablePath.Result> {
+
+  private enum FileKind {
+    VERSION_FILE,
+    MANIFEST_LIST,
+    MANIFEST,
+    STATISTICS_FILE,
+    PARTITION_STATISTICS_FILE,
+    CONTENT_FILE;
+
+    // manifest name ends up with either "-m0.parquet" or "m1.avro"
+    private static final Pattern MANIFEST_NAME = 
Pattern.compile(".+-m\\d+\\..+");
+
+    private static FileKind of(String location) {
+      String name = RewriteTablePathUtil.fileName(location);
+      if (name.endsWith(".metadata.json")) {
+        return VERSION_FILE;
+      } else if (name.startsWith("snap-")) {
+        return MANIFEST_LIST;
+      } else if (name.startsWith("optimized-m-") || 
MANIFEST_NAME.matcher(name).matches()) {
+        return MANIFEST;
+      } else if (name.startsWith("partition-stats-")) {
+        return PARTITION_STATISTICS_FILE;
+      } else if (name.endsWith(".stats")) {
+        return STATISTICS_FILE;
+      }
+
+      return CONTENT_FILE;
+    }
+  }
+
+  private final Set<FileKind> checkedKinds = EnumSet.noneOf(FileKind.class);
+  private Map<FileKind, List<Pair<String, String>>> filesByKind;
+
+  public RewriteTablePathResultAssert(RewriteTablePath.Result actual) {
+    super(actual, RewriteTablePathResultAssert.class);
+  }
+
+  public static RewriteTablePathResultAssert 
assertThat(RewriteTablePath.Result actual) {
+    return new RewriteTablePathResultAssert(actual);
+  }
+
+  public RewriteTablePathResultAssert hasLatestVersion(String expected) {
+    isNotNull();
+    if (!Objects.equals(actual.latestVersion(), expected)) {
+      failWithMessage("Expected latest version %s but was %s", expected, 
actual.latestVersion());
+    }
+
+    return myself;
+  }
+
+  public RewriteTablePathResultAssert hasRewrittenDeleteFilePaths(int 
expected) {
+    isNotNull();
+    if (actual.rewrittenDeleteFilePathsCount() != expected) {
+      failWithMessage(
+          "Expected %s rewritten delete file paths but was %s",
+          expected, actual.rewrittenDeleteFilePathsCount());
+    }
+
+    return myself;
+  }
+
+  public RewriteTablePathResultAssert hasFileListLocation(String expected) {
+    isNotNull();
+    if (!Objects.equals(actual.fileListLocation(), expected)) {
+      failWithMessage(
+          "Expected file list location %s but was %s", expected, 
actual.fileListLocation());
+    }
+
+    return myself;
+  }
+
+  public RewriteTablePathResultAssert hasVersionFiles(int expected) {
+    return hasFiles(FileKind.VERSION_FILE, expected);
+  }
+
+  public RewriteTablePathResultAssert hasManifestLists(int expected) {
+    return hasFiles(FileKind.MANIFEST_LIST, expected);
+  }
+
+  public RewriteTablePathResultAssert hasManifests(int expected) {
+    return hasFiles(FileKind.MANIFEST, expected);
+  }
+
+  public RewriteTablePathResultAssert hasStatisticsFiles(int expected) {
+    return hasFiles(FileKind.STATISTICS_FILE, expected);
+  }
+
+  public RewriteTablePathResultAssert hasPartitionStatisticsFiles(int 
expected) {
+    return hasFiles(FileKind.PARTITION_STATISTICS_FILE, expected);
+  }
+
+  public RewriteTablePathResultAssert hasContentFiles(int expected) {
+    return hasFiles(FileKind.CONTENT_FILE, expected);
+  }
+
+  public void hasNoOtherFiles() {
+    isNotNull();
+    Map<FileKind, List<String>> unchecked = new EnumMap<>(FileKind.class);
+    filesByKind()
+        .forEach(
+            (kind, files) -> {
+              if (!checkedKinds.contains(kind)) {
+                unchecked.put(kind, fileNames(files));
+              }
+            });
+    if (!unchecked.isEmpty()) {
+      failWithMessage(
+          "Expected no files other than %s in %s but found:%n%s",
+          checkedKinds, actual.fileListLocation(), unchecked);
+    }
+  }
+
+  public RewriteTablePathResultAssert hasStatisticsFilesCopiedAsIs(
+      String sourcePrefix, String targetPrefix) {
+    return hasFilesCopiedAsIs(FileKind.STATISTICS_FILE, sourcePrefix, 
targetPrefix);
+  }
+
+  public RewriteTablePathResultAssert hasPartitionStatisticsFilesCopiedAsIs(
+      String sourcePrefix, String targetPrefix) {
+    return hasFilesCopiedAsIs(FileKind.PARTITION_STATISTICS_FILE, 
sourcePrefix, targetPrefix);
+  }
+
+  private RewriteTablePathResultAssert hasFiles(FileKind kind, int expected) {
+    isNotNull();
+    checkedKinds.add(kind);
+    List<Pair<String, String>> files = filesByKind().getOrDefault(kind, 
List.of());
+    if (files.size() != expected) {
+      failWithMessage(
+          "Expected %s %s in %s but found %s, counts by kind: %s%n%s: %s",
+          expected,
+          kind,
+          actual.fileListLocation(),
+          files.size(),
+          countsByKind(),
+          kind,
+          fileNames(files));
+    }
+
+    return myself;
+  }
+
+  private Map<FileKind, Integer> countsByKind() {
+    Map<FileKind, Integer> counts = new EnumMap<>(FileKind.class);
+    filesByKind().forEach((kind, files) -> counts.put(kind, files.size()));
+    return counts;
+  }
+
+  private static List<String> fileNames(List<Pair<String, String>> files) {
+    return files.stream()
+        .map(file -> RewriteTablePathUtil.fileName(file.second()))
+        .collect(Collectors.toList());
+  }
+
+  private RewriteTablePathResultAssert hasFilesCopiedAsIs(
+      FileKind kind, String sourcePrefix, String targetPrefix) {
+    isNotNull();
+    List<Pair<String, String>> files = filesByKind().getOrDefault(kind, 
List.of());
+    if (files.isEmpty()) {
+      failWithMessage("Expected %s in %s but found none", kind, 
actual.fileListLocation());
+    }
+
+    List<Pair<String, String>> notCopiedAsIs =
+        files.stream()
+            .filter(
+                file ->
+                    !file.first().startsWith(sourcePrefix)
+                        || !RewriteTablePathUtil.newPath(file.first(), 
sourcePrefix, targetPrefix)
+                            .equals(file.second()))
+            .collect(Collectors.toList());
+    if (!notCopiedAsIs.isEmpty()) {
+      failWithMessage(
+          "Expected every %s to be copied from %s to the same relative path 
under %s"
+              + " but found (source, target):%n%s",
+          kind, sourcePrefix, targetPrefix, notCopiedAsIs);
+    }
+
+    return myself;
+  }
+
+  private Map<FileKind, List<Pair<String, String>>> filesByKind() {
+    if (filesByKind == null) {
+      try {
+        this.filesByKind =
+            
Files.readAllLines(Paths.get(URI.create(actual.fileListLocation()))).stream()
+                .map(RewriteTablePathResultAssert::parseLine)
+                .collect(
+                    Collectors.groupingBy(
+                        file -> FileKind.of(file.second()),
+                        () -> new EnumMap<>(FileKind.class),
+                        Collectors.toList()));
+      } catch (IOException e) {
+        throw new UncheckedIOException(e);
+      }
+    }
+
+    return filesByKind;
+  }
+
+  private static Pair<String, String> parseLine(String line) {
+    int separator = line.lastIndexOf(',');
+    return Pair.of(line.substring(0, separator), line.substring(separator + 
1));
+  }
+}
diff --git 
a/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
 
b/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
index ef246c7a61..97203da89b 100644
--- 
a/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
+++ 
b/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iceberg.spark.actions;
 
+import static 
org.apache.iceberg.actions.RewriteTablePathResultAssert.assertThat;
 import static 
org.apache.iceberg.spark.actions.RewriteTablePathSparkAction.NOT_APPLICABLE;
 import static org.apache.iceberg.types.Types.NestedField.optional;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +34,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
@@ -259,9 +259,13 @@ public class TestRewriteTablePathsAction extends TestBase {
             .endVersion("v3.metadata.json")
             .execute();
 
-    assertThat(result.latestVersion()).isEqualTo("v3.metadata.json");
-
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasLatestVersion("v3.metadata.json")
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -308,7 +312,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v2.metadata.json")
             .execute();
 
-    checkFileNum(1, 1, 1, 4, result);
+    assertThat(result)
+        .hasVersionFiles(1)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     List<Tuple2<String, String>> paths = 
readPathPairList(result.fileListLocation());
 
@@ -382,7 +391,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v2.metadata.json")
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // start from the first version
     RewriteTablePath.Result result1 =
@@ -392,7 +406,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v1.metadata.json")
             .execute();
 
-    checkFileNum(3, 3, 3, 12, result1);
+    assertThat(result1)
+        .hasVersionFiles(3)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -403,7 +422,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(tableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -414,7 +438,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(table.location(), targetTableLocation())
             .stagingLocation(stagingLocation())
             .execute();
-    checkFileNum(3, 2, 2, 9, initialResult);
+    assertThat(initialResult)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // rewrite manifest without change data files
     RewriteManifests.Result rewriteManifestResult = 
actions().rewriteManifests(table).execute();
@@ -430,7 +459,11 @@ public class TestRewriteTablePathsAction extends TestBase {
             .execute();
 
     // no data files need to move
-    checkFileNum(1, 1, addedManifest, 3, postReweiteResult);
+    assertThat(postReweiteResult)
+        .hasVersionFiles(1)
+        .hasManifestLists(1)
+        .hasManifests(addedManifest)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -453,7 +486,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .stagingLocation(stagingLocation())
             .execute();
 
-    checkFileNum(4, 3, 3, 12, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -525,7 +563,12 @@ public class TestRewriteTablePathsAction extends TestBase {
 
     // We have one more snapshot, an additional manifest list, and a new 
(delete) manifest,
     // and an additional position delete
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -577,7 +620,12 @@ public class TestRewriteTablePathsAction extends TestBase {
 
     // We have one more snapshot, an additional manifest list, and a new 
(delete) manifest,
     // and an additional position delete
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -648,9 +696,9 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(tableWithPosDeletes.location(), 
targetTableLocation())
             .execute();
 
-    assertThat(result.rewrittenDeleteFilePathsCount())
+    assertThat(result)
         .as("Should have rewritten exactly 1 delete file after deduplication")
-        .isEqualTo(1);
+        .hasRewrittenDeleteFilePaths(1);
   }
 
   // Regression test: when the same position delete file is referenced from 
manifests in different
@@ -900,9 +948,9 @@ public class TestRewriteTablePathsAction extends TestBase {
             .stagingLocation(stagingLocation())
             .rewriteLocationPrefix(tableWithDVs.location(), 
targetTableLocation())
             .execute();
-    assertThat(result.rewrittenDeleteFilePathsCount())
+    assertThat(result)
         .as("Two DVs are two delete files with rewritten paths")
-        .isEqualTo(2);
+        .hasRewrittenDeleteFilePaths(2);
     copyTableFiles(result);
 
     Table targetTable = TABLES.load(targetTableLocation());
@@ -986,7 +1034,12 @@ public class TestRewriteTablePathsAction extends TestBase 
{
     // We have four metadata files: for the table creation, for the initial 
snapshot, for the
     // second append here, and for commit with equality deletes. Thus, we have 
three manifest lists.
     // We have a data file for each snapshot (two with data, one with equality 
deletes)
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -1035,12 +1088,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(location, targetTableLocation())
             .execute();
 
-    checkFileNum(
-        totalIteration - missingVersionFile,
-        totalIteration - expiredManifestListCount,
-        totalIteration,
-        totalIteration * 4 - missingVersionFile - expiredManifestListCount - 
missingDataFile,
-        result);
+    assertThat(result)
+        .hasVersionFiles(totalIteration - missingVersionFile)
+        .hasManifestLists(totalIteration - expiredManifestListCount)
+        .hasManifests(totalIteration)
+        .hasContentFiles(totalIteration - missingDataFile)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1053,7 +1106,7 @@ public class TestRewriteTablePathsAction extends TestBase 
{
             .execute();
 
     // the only rebuilt file is v1.metadata.json since it contains no snapshot
-    checkFileNum(1, 0, 0, 1, result);
+    assertThat(result).hasVersionFiles(1).hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1068,7 +1121,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(table.location(), targetTableLocation())
             .execute();
 
-    checkFileNum(4, 1, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(1)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1110,7 +1168,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
     // 5 version files include 1 table creation 3 overwrite and 1 snapshot 
expiration
     // 3 overwrites generate 3 manifest list and 5 manifests with 3 data files
     // snapshot expiration removed 1 of each
-    checkFileNum(5, 2, 4, 13, result);
+    assertThat(result)
+        .hasVersionFiles(5)
+        .hasManifestLists(2)
+        .hasManifests(4)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -1156,7 +1219,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // 2 metadata.json, 1 manifest list file, 1 manifest files
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1174,7 +1242,7 @@ public class TestRewriteTablePathsAction extends TestBase 
{
             .execute();
 
     // only v4.metadata.json needs to move
-    checkFileNum(1, 0, 0, 1, result);
+    assertThat(result).hasVersionFiles(1).hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1220,7 +1288,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(table.location(), newTableLocation())
             .stagingLocation(stagingLocation())
             .execute();
-    checkFileNum(6, 3, 3, 15, result);
+    assertThat(result)
+        .hasVersionFiles(6)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1245,7 +1318,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // There are 3 snapshots in total, although the current snapshot is the 
second one.
-    checkFileNum(5, 3, 3, 14, result);
+    assertThat(result)
+        .hasVersionFiles(5)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1262,7 +1340,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // check the result
-    checkFileNum(4, 2, 2, 10, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1280,7 +1363,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1297,7 +1385,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion("v2.gz.metadata.json")
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     result =
         actions()
@@ -1306,7 +1399,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion("v1.gz.metadata.json")
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1367,11 +1465,14 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteTablePath(sourceTable)
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
             .execute();
-    checkFileNum(
-        iterations * 2 + 1, iterations, iterations, 0, iterations, iterations 
* 6 + 1, result);
-
-    findAndAssertFileInFileList(
-        result, "partition-stats", sourceTableLocation, targetTableLocation);
+    assertThat(result)
+        .hasVersionFiles(iterations * 2 + 1)
+        .hasManifestLists(iterations)
+        .hasManifests(iterations)
+        .hasPartitionStatisticsFiles(iterations)
+        .hasContentFiles(iterations)
+        .hasPartitionStatisticsFilesCopiedAsIs(sourceTableLocation, 
targetTableLocation)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1399,8 +1500,13 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(
-        iterations * 2 + 1, iterations, iterations, iterations, iterations * 6 
+ 1, result);
+    assertThat(result)
+        .hasVersionFiles(iterations * 2 + 1)
+        .hasManifestLists(iterations)
+        .hasManifests(iterations)
+        .hasStatisticsFiles(iterations)
+        .hasContentFiles(iterations)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1426,9 +1532,14 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
             .execute();
 
-    checkFileNum(3, 1, 1, 1, 7, result);
-
-    findAndAssertFileInFileList(result, ".stats", sourceTableLocation, 
targetTableLocation);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasStatisticsFiles(1)
+        .hasContentFiles(1)
+        .hasStatisticsFilesCopiedAsIs(sourceTableLocation, targetTableLocation)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1454,7 +1565,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion(endVersion)
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     // set the first version as the lastCopiedVersion
     String firstVersion = 
fileName(currentMetadata.previousFiles().get(0).file());
@@ -1465,7 +1581,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion(firstVersion)
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   // Metastore table tests
@@ -1492,7 +1613,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(newTableLocation(), targetTableLocation())
             .execute();
 
-    checkFileNum(4, 2, 2, 10, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // pick up a version from the old metadata dir as the end version
     RewriteTablePath.Result result1 =
@@ -1502,7 +1628,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion(fileName(metadataFilePath))
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result1);
+    assertThat(result1)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     // pick up a version from the old metadata dir as the last copied version
     RewriteTablePath.Result result2 =
@@ -1512,7 +1643,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion(fileName(metadataFilePath))
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result2);
+    assertThat(result2)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1564,7 +1700,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(newTableLocation(), targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
     // one data and one metadata file
     copyTableFiles(result);
 
@@ -1694,11 +1835,10 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .createFileList(false) // Disable file list creation
             .execute();
 
-    assertThat(result.latestVersion()).isEqualTo("v3.metadata.json");
-
-    assertThat(result.fileListLocation())
+    assertThat(result)
+        .hasLatestVersion("v3.metadata.json")
         .as("File list location should not be set when createFileList is 
false")
-        .isEqualTo(NOT_APPLICABLE);
+        .hasFileListLocation(NOT_APPLICABLE);
   }
 
   @TestTemplate
@@ -1717,76 +1857,17 @@ public class TestRewriteTablePathsAction extends 
TestBase {
               .executeWith(service)
               .execute();
 
-      checkFileNum(50, 50, 50, 200, result);
+      assertThat(result)
+          .hasVersionFiles(50)
+          .hasManifestLists(50)
+          .hasManifests(50)
+          .hasContentFiles(50)
+          .hasNoOtherFiles();
     } finally {
       service.shutdown();
     }
   }
 
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    checkFileNum(versionFileCount, manifestListCount, manifestFileCount, 0, 0, 
totalCount, result);
-  }
-
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int statisticsFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    checkFileNum(
-        versionFileCount,
-        manifestListCount,
-        manifestFileCount,
-        statisticsFileCount,
-        0,
-        totalCount,
-        result);
-  }
-
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int statisticsFileCount,
-      int partitionFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    List<String> filesToMove =
-        spark
-            .read()
-            .format("text")
-            .load(result.fileListLocation())
-            .as(Encoders.STRING())
-            .collectAsList();
-    Predicate<String> isManifest =
-        f -> f.contains("optimized-m-") || f.contains("-m0.") || 
f.contains("-m1.");
-    Predicate<String> isManifestList = f -> f.contains("snap-") && 
f.endsWith(".avro");
-    Predicate<String> isMetadataJSON = f -> f.endsWith(".metadata.json");
-
-    assertThat(filesToMove.stream().filter(isMetadataJSON))
-        .as("Wrong rebuilt version file count")
-        .hasSize(versionFileCount);
-    assertThat(filesToMove.stream().filter(isManifestList))
-        .as("Wrong rebuilt Manifest list file count")
-        .hasSize(manifestListCount);
-    assertThat(filesToMove.stream().filter(isManifest))
-        .as("Wrong rebuilt Manifest file file count")
-        .hasSize(manifestFileCount);
-    assertThat(filesToMove.stream().filter(f -> f.endsWith(".stats")))
-        .as("Wrong rebuilt Statistic file count")
-        .hasSize(statisticsFileCount);
-    assertThat(filesToMove.stream().filter(f -> f.contains("partition-stats")))
-        .as("Wrong rebuilt Partition Statistic file count")
-        .hasSize(partitionFileCount);
-    assertThat(filesToMove).as("Wrong total file count").hasSize(totalCount);
-  }
-
   protected String newTableLocation() throws IOException {
     return toAbsolute(newTableDir);
   }
@@ -1957,36 +2038,4 @@ public class TestRewriteTablePathsAction extends 
TestBase {
     blockInfoManager.removeBlock(blockId);
     blockManager.memoryStore().remove(blockId);
   }
-
-  private void findAndAssertFileInFileList(
-      RewriteTablePath.Result result,
-      String fileIdentifier,
-      String sourceTableLocation,
-      String targetTableLocation) {
-
-    List<Tuple2<String, String>> filesToMove = 
readPathPairList(result.fileListLocation());
-
-    // Find the file path pair that contains the specified file identifier
-    Tuple2<String, String> filePathPair =
-        filesToMove.stream()
-            .filter(pair -> pair._1().contains(fileIdentifier))
-            .findFirst()
-            .orElse(null);
-
-    // Assert that the file was found in the list
-    assertThat(filePathPair).as("Should find " + fileIdentifier + " file in 
file list").isNotNull();
-
-    // Validate source path: should point to source table location, contain 
metadata, and not
-    // staging
-    assertThat(filePathPair._1())
-        .as(fileIdentifier + " source should point to source table location 
and NOT staging")
-        .startsWith(sourceTableLocation)
-        .contains("/metadata/")
-        .doesNotContain("staging");
-
-    // Validate target path: should point to target table location
-    assertThat(filePathPair._2())
-        .as(fileIdentifier + " target should point to target table location")
-        .startsWith(targetTableLocation);
-  }
 }
diff --git 
a/spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
 
b/spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
index ef246c7a61..97203da89b 100644
--- 
a/spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
+++ 
b/spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iceberg.spark.actions;
 
+import static 
org.apache.iceberg.actions.RewriteTablePathResultAssert.assertThat;
 import static 
org.apache.iceberg.spark.actions.RewriteTablePathSparkAction.NOT_APPLICABLE;
 import static org.apache.iceberg.types.Types.NestedField.optional;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +34,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
@@ -259,9 +259,13 @@ public class TestRewriteTablePathsAction extends TestBase {
             .endVersion("v3.metadata.json")
             .execute();
 
-    assertThat(result.latestVersion()).isEqualTo("v3.metadata.json");
-
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasLatestVersion("v3.metadata.json")
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -308,7 +312,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v2.metadata.json")
             .execute();
 
-    checkFileNum(1, 1, 1, 4, result);
+    assertThat(result)
+        .hasVersionFiles(1)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     List<Tuple2<String, String>> paths = 
readPathPairList(result.fileListLocation());
 
@@ -382,7 +391,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v2.metadata.json")
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // start from the first version
     RewriteTablePath.Result result1 =
@@ -392,7 +406,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v1.metadata.json")
             .execute();
 
-    checkFileNum(3, 3, 3, 12, result1);
+    assertThat(result1)
+        .hasVersionFiles(3)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -403,7 +422,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(tableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -414,7 +438,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(table.location(), targetTableLocation())
             .stagingLocation(stagingLocation())
             .execute();
-    checkFileNum(3, 2, 2, 9, initialResult);
+    assertThat(initialResult)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // rewrite manifest without change data files
     RewriteManifests.Result rewriteManifestResult = 
actions().rewriteManifests(table).execute();
@@ -430,7 +459,11 @@ public class TestRewriteTablePathsAction extends TestBase {
             .execute();
 
     // no data files need to move
-    checkFileNum(1, 1, addedManifest, 3, postReweiteResult);
+    assertThat(postReweiteResult)
+        .hasVersionFiles(1)
+        .hasManifestLists(1)
+        .hasManifests(addedManifest)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -453,7 +486,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .stagingLocation(stagingLocation())
             .execute();
 
-    checkFileNum(4, 3, 3, 12, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -525,7 +563,12 @@ public class TestRewriteTablePathsAction extends TestBase {
 
     // We have one more snapshot, an additional manifest list, and a new 
(delete) manifest,
     // and an additional position delete
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -577,7 +620,12 @@ public class TestRewriteTablePathsAction extends TestBase {
 
     // We have one more snapshot, an additional manifest list, and a new 
(delete) manifest,
     // and an additional position delete
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -648,9 +696,9 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(tableWithPosDeletes.location(), 
targetTableLocation())
             .execute();
 
-    assertThat(result.rewrittenDeleteFilePathsCount())
+    assertThat(result)
         .as("Should have rewritten exactly 1 delete file after deduplication")
-        .isEqualTo(1);
+        .hasRewrittenDeleteFilePaths(1);
   }
 
   // Regression test: when the same position delete file is referenced from 
manifests in different
@@ -900,9 +948,9 @@ public class TestRewriteTablePathsAction extends TestBase {
             .stagingLocation(stagingLocation())
             .rewriteLocationPrefix(tableWithDVs.location(), 
targetTableLocation())
             .execute();
-    assertThat(result.rewrittenDeleteFilePathsCount())
+    assertThat(result)
         .as("Two DVs are two delete files with rewritten paths")
-        .isEqualTo(2);
+        .hasRewrittenDeleteFilePaths(2);
     copyTableFiles(result);
 
     Table targetTable = TABLES.load(targetTableLocation());
@@ -986,7 +1034,12 @@ public class TestRewriteTablePathsAction extends TestBase 
{
     // We have four metadata files: for the table creation, for the initial 
snapshot, for the
     // second append here, and for commit with equality deletes. Thus, we have 
three manifest lists.
     // We have a data file for each snapshot (two with data, one with equality 
deletes)
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -1035,12 +1088,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(location, targetTableLocation())
             .execute();
 
-    checkFileNum(
-        totalIteration - missingVersionFile,
-        totalIteration - expiredManifestListCount,
-        totalIteration,
-        totalIteration * 4 - missingVersionFile - expiredManifestListCount - 
missingDataFile,
-        result);
+    assertThat(result)
+        .hasVersionFiles(totalIteration - missingVersionFile)
+        .hasManifestLists(totalIteration - expiredManifestListCount)
+        .hasManifests(totalIteration)
+        .hasContentFiles(totalIteration - missingDataFile)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1053,7 +1106,7 @@ public class TestRewriteTablePathsAction extends TestBase 
{
             .execute();
 
     // the only rebuilt file is v1.metadata.json since it contains no snapshot
-    checkFileNum(1, 0, 0, 1, result);
+    assertThat(result).hasVersionFiles(1).hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1068,7 +1121,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(table.location(), targetTableLocation())
             .execute();
 
-    checkFileNum(4, 1, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(1)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1110,7 +1168,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
     // 5 version files include 1 table creation 3 overwrite and 1 snapshot 
expiration
     // 3 overwrites generate 3 manifest list and 5 manifests with 3 data files
     // snapshot expiration removed 1 of each
-    checkFileNum(5, 2, 4, 13, result);
+    assertThat(result)
+        .hasVersionFiles(5)
+        .hasManifestLists(2)
+        .hasManifests(4)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -1156,7 +1219,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // 2 metadata.json, 1 manifest list file, 1 manifest files
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1174,7 +1242,7 @@ public class TestRewriteTablePathsAction extends TestBase 
{
             .execute();
 
     // only v4.metadata.json needs to move
-    checkFileNum(1, 0, 0, 1, result);
+    assertThat(result).hasVersionFiles(1).hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1220,7 +1288,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(table.location(), newTableLocation())
             .stagingLocation(stagingLocation())
             .execute();
-    checkFileNum(6, 3, 3, 15, result);
+    assertThat(result)
+        .hasVersionFiles(6)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1245,7 +1318,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // There are 3 snapshots in total, although the current snapshot is the 
second one.
-    checkFileNum(5, 3, 3, 14, result);
+    assertThat(result)
+        .hasVersionFiles(5)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1262,7 +1340,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // check the result
-    checkFileNum(4, 2, 2, 10, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1280,7 +1363,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1297,7 +1385,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion("v2.gz.metadata.json")
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     result =
         actions()
@@ -1306,7 +1399,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion("v1.gz.metadata.json")
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1367,11 +1465,14 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteTablePath(sourceTable)
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
             .execute();
-    checkFileNum(
-        iterations * 2 + 1, iterations, iterations, 0, iterations, iterations 
* 6 + 1, result);
-
-    findAndAssertFileInFileList(
-        result, "partition-stats", sourceTableLocation, targetTableLocation);
+    assertThat(result)
+        .hasVersionFiles(iterations * 2 + 1)
+        .hasManifestLists(iterations)
+        .hasManifests(iterations)
+        .hasPartitionStatisticsFiles(iterations)
+        .hasContentFiles(iterations)
+        .hasPartitionStatisticsFilesCopiedAsIs(sourceTableLocation, 
targetTableLocation)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1399,8 +1500,13 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(
-        iterations * 2 + 1, iterations, iterations, iterations, iterations * 6 
+ 1, result);
+    assertThat(result)
+        .hasVersionFiles(iterations * 2 + 1)
+        .hasManifestLists(iterations)
+        .hasManifests(iterations)
+        .hasStatisticsFiles(iterations)
+        .hasContentFiles(iterations)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1426,9 +1532,14 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
             .execute();
 
-    checkFileNum(3, 1, 1, 1, 7, result);
-
-    findAndAssertFileInFileList(result, ".stats", sourceTableLocation, 
targetTableLocation);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasStatisticsFiles(1)
+        .hasContentFiles(1)
+        .hasStatisticsFilesCopiedAsIs(sourceTableLocation, targetTableLocation)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1454,7 +1565,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion(endVersion)
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     // set the first version as the lastCopiedVersion
     String firstVersion = 
fileName(currentMetadata.previousFiles().get(0).file());
@@ -1465,7 +1581,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion(firstVersion)
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   // Metastore table tests
@@ -1492,7 +1613,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(newTableLocation(), targetTableLocation())
             .execute();
 
-    checkFileNum(4, 2, 2, 10, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // pick up a version from the old metadata dir as the end version
     RewriteTablePath.Result result1 =
@@ -1502,7 +1628,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion(fileName(metadataFilePath))
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result1);
+    assertThat(result1)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     // pick up a version from the old metadata dir as the last copied version
     RewriteTablePath.Result result2 =
@@ -1512,7 +1643,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion(fileName(metadataFilePath))
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result2);
+    assertThat(result2)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1564,7 +1700,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(newTableLocation(), targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
     // one data and one metadata file
     copyTableFiles(result);
 
@@ -1694,11 +1835,10 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .createFileList(false) // Disable file list creation
             .execute();
 
-    assertThat(result.latestVersion()).isEqualTo("v3.metadata.json");
-
-    assertThat(result.fileListLocation())
+    assertThat(result)
+        .hasLatestVersion("v3.metadata.json")
         .as("File list location should not be set when createFileList is 
false")
-        .isEqualTo(NOT_APPLICABLE);
+        .hasFileListLocation(NOT_APPLICABLE);
   }
 
   @TestTemplate
@@ -1717,76 +1857,17 @@ public class TestRewriteTablePathsAction extends 
TestBase {
               .executeWith(service)
               .execute();
 
-      checkFileNum(50, 50, 50, 200, result);
+      assertThat(result)
+          .hasVersionFiles(50)
+          .hasManifestLists(50)
+          .hasManifests(50)
+          .hasContentFiles(50)
+          .hasNoOtherFiles();
     } finally {
       service.shutdown();
     }
   }
 
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    checkFileNum(versionFileCount, manifestListCount, manifestFileCount, 0, 0, 
totalCount, result);
-  }
-
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int statisticsFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    checkFileNum(
-        versionFileCount,
-        manifestListCount,
-        manifestFileCount,
-        statisticsFileCount,
-        0,
-        totalCount,
-        result);
-  }
-
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int statisticsFileCount,
-      int partitionFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    List<String> filesToMove =
-        spark
-            .read()
-            .format("text")
-            .load(result.fileListLocation())
-            .as(Encoders.STRING())
-            .collectAsList();
-    Predicate<String> isManifest =
-        f -> f.contains("optimized-m-") || f.contains("-m0.") || 
f.contains("-m1.");
-    Predicate<String> isManifestList = f -> f.contains("snap-") && 
f.endsWith(".avro");
-    Predicate<String> isMetadataJSON = f -> f.endsWith(".metadata.json");
-
-    assertThat(filesToMove.stream().filter(isMetadataJSON))
-        .as("Wrong rebuilt version file count")
-        .hasSize(versionFileCount);
-    assertThat(filesToMove.stream().filter(isManifestList))
-        .as("Wrong rebuilt Manifest list file count")
-        .hasSize(manifestListCount);
-    assertThat(filesToMove.stream().filter(isManifest))
-        .as("Wrong rebuilt Manifest file file count")
-        .hasSize(manifestFileCount);
-    assertThat(filesToMove.stream().filter(f -> f.endsWith(".stats")))
-        .as("Wrong rebuilt Statistic file count")
-        .hasSize(statisticsFileCount);
-    assertThat(filesToMove.stream().filter(f -> f.contains("partition-stats")))
-        .as("Wrong rebuilt Partition Statistic file count")
-        .hasSize(partitionFileCount);
-    assertThat(filesToMove).as("Wrong total file count").hasSize(totalCount);
-  }
-
   protected String newTableLocation() throws IOException {
     return toAbsolute(newTableDir);
   }
@@ -1957,36 +2038,4 @@ public class TestRewriteTablePathsAction extends 
TestBase {
     blockInfoManager.removeBlock(blockId);
     blockManager.memoryStore().remove(blockId);
   }
-
-  private void findAndAssertFileInFileList(
-      RewriteTablePath.Result result,
-      String fileIdentifier,
-      String sourceTableLocation,
-      String targetTableLocation) {
-
-    List<Tuple2<String, String>> filesToMove = 
readPathPairList(result.fileListLocation());
-
-    // Find the file path pair that contains the specified file identifier
-    Tuple2<String, String> filePathPair =
-        filesToMove.stream()
-            .filter(pair -> pair._1().contains(fileIdentifier))
-            .findFirst()
-            .orElse(null);
-
-    // Assert that the file was found in the list
-    assertThat(filePathPair).as("Should find " + fileIdentifier + " file in 
file list").isNotNull();
-
-    // Validate source path: should point to source table location, contain 
metadata, and not
-    // staging
-    assertThat(filePathPair._1())
-        .as(fileIdentifier + " source should point to source table location 
and NOT staging")
-        .startsWith(sourceTableLocation)
-        .contains("/metadata/")
-        .doesNotContain("staging");
-
-    // Validate target path: should point to target table location
-    assertThat(filePathPair._2())
-        .as(fileIdentifier + " target should point to target table location")
-        .startsWith(targetTableLocation);
-  }
 }
diff --git 
a/spark/v4.1/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
 
b/spark/v4.1/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
index ef246c7a61..97203da89b 100644
--- 
a/spark/v4.1/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
+++ 
b/spark/v4.1/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iceberg.spark.actions;
 
+import static 
org.apache.iceberg.actions.RewriteTablePathResultAssert.assertThat;
 import static 
org.apache.iceberg.spark.actions.RewriteTablePathSparkAction.NOT_APPLICABLE;
 import static org.apache.iceberg.types.Types.NestedField.optional;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +34,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
@@ -259,9 +259,13 @@ public class TestRewriteTablePathsAction extends TestBase {
             .endVersion("v3.metadata.json")
             .execute();
 
-    assertThat(result.latestVersion()).isEqualTo("v3.metadata.json");
-
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasLatestVersion("v3.metadata.json")
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -308,7 +312,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v2.metadata.json")
             .execute();
 
-    checkFileNum(1, 1, 1, 4, result);
+    assertThat(result)
+        .hasVersionFiles(1)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     List<Tuple2<String, String>> paths = 
readPathPairList(result.fileListLocation());
 
@@ -382,7 +391,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v2.metadata.json")
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // start from the first version
     RewriteTablePath.Result result1 =
@@ -392,7 +406,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v1.metadata.json")
             .execute();
 
-    checkFileNum(3, 3, 3, 12, result1);
+    assertThat(result1)
+        .hasVersionFiles(3)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -403,7 +422,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(tableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -414,7 +438,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(table.location(), targetTableLocation())
             .stagingLocation(stagingLocation())
             .execute();
-    checkFileNum(3, 2, 2, 9, initialResult);
+    assertThat(initialResult)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // rewrite manifest without change data files
     RewriteManifests.Result rewriteManifestResult = 
actions().rewriteManifests(table).execute();
@@ -430,7 +459,11 @@ public class TestRewriteTablePathsAction extends TestBase {
             .execute();
 
     // no data files need to move
-    checkFileNum(1, 1, addedManifest, 3, postReweiteResult);
+    assertThat(postReweiteResult)
+        .hasVersionFiles(1)
+        .hasManifestLists(1)
+        .hasManifests(addedManifest)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -453,7 +486,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .stagingLocation(stagingLocation())
             .execute();
 
-    checkFileNum(4, 3, 3, 12, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -525,7 +563,12 @@ public class TestRewriteTablePathsAction extends TestBase {
 
     // We have one more snapshot, an additional manifest list, and a new 
(delete) manifest,
     // and an additional position delete
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -577,7 +620,12 @@ public class TestRewriteTablePathsAction extends TestBase {
 
     // We have one more snapshot, an additional manifest list, and a new 
(delete) manifest,
     // and an additional position delete
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -648,9 +696,9 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(tableWithPosDeletes.location(), 
targetTableLocation())
             .execute();
 
-    assertThat(result.rewrittenDeleteFilePathsCount())
+    assertThat(result)
         .as("Should have rewritten exactly 1 delete file after deduplication")
-        .isEqualTo(1);
+        .hasRewrittenDeleteFilePaths(1);
   }
 
   // Regression test: when the same position delete file is referenced from 
manifests in different
@@ -900,9 +948,9 @@ public class TestRewriteTablePathsAction extends TestBase {
             .stagingLocation(stagingLocation())
             .rewriteLocationPrefix(tableWithDVs.location(), 
targetTableLocation())
             .execute();
-    assertThat(result.rewrittenDeleteFilePathsCount())
+    assertThat(result)
         .as("Two DVs are two delete files with rewritten paths")
-        .isEqualTo(2);
+        .hasRewrittenDeleteFilePaths(2);
     copyTableFiles(result);
 
     Table targetTable = TABLES.load(targetTableLocation());
@@ -986,7 +1034,12 @@ public class TestRewriteTablePathsAction extends TestBase 
{
     // We have four metadata files: for the table creation, for the initial 
snapshot, for the
     // second append here, and for commit with equality deletes. Thus, we have 
three manifest lists.
     // We have a data file for each snapshot (two with data, one with equality 
deletes)
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -1035,12 +1088,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(location, targetTableLocation())
             .execute();
 
-    checkFileNum(
-        totalIteration - missingVersionFile,
-        totalIteration - expiredManifestListCount,
-        totalIteration,
-        totalIteration * 4 - missingVersionFile - expiredManifestListCount - 
missingDataFile,
-        result);
+    assertThat(result)
+        .hasVersionFiles(totalIteration - missingVersionFile)
+        .hasManifestLists(totalIteration - expiredManifestListCount)
+        .hasManifests(totalIteration)
+        .hasContentFiles(totalIteration - missingDataFile)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1053,7 +1106,7 @@ public class TestRewriteTablePathsAction extends TestBase 
{
             .execute();
 
     // the only rebuilt file is v1.metadata.json since it contains no snapshot
-    checkFileNum(1, 0, 0, 1, result);
+    assertThat(result).hasVersionFiles(1).hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1068,7 +1121,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(table.location(), targetTableLocation())
             .execute();
 
-    checkFileNum(4, 1, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(1)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1110,7 +1168,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
     // 5 version files include 1 table creation 3 overwrite and 1 snapshot 
expiration
     // 3 overwrites generate 3 manifest list and 5 manifests with 3 data files
     // snapshot expiration removed 1 of each
-    checkFileNum(5, 2, 4, 13, result);
+    assertThat(result)
+        .hasVersionFiles(5)
+        .hasManifestLists(2)
+        .hasManifests(4)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -1156,7 +1219,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // 2 metadata.json, 1 manifest list file, 1 manifest files
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1174,7 +1242,7 @@ public class TestRewriteTablePathsAction extends TestBase 
{
             .execute();
 
     // only v4.metadata.json needs to move
-    checkFileNum(1, 0, 0, 1, result);
+    assertThat(result).hasVersionFiles(1).hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1220,7 +1288,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(table.location(), newTableLocation())
             .stagingLocation(stagingLocation())
             .execute();
-    checkFileNum(6, 3, 3, 15, result);
+    assertThat(result)
+        .hasVersionFiles(6)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1245,7 +1318,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // There are 3 snapshots in total, although the current snapshot is the 
second one.
-    checkFileNum(5, 3, 3, 14, result);
+    assertThat(result)
+        .hasVersionFiles(5)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1262,7 +1340,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // check the result
-    checkFileNum(4, 2, 2, 10, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1280,7 +1363,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1297,7 +1385,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion("v2.gz.metadata.json")
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     result =
         actions()
@@ -1306,7 +1399,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion("v1.gz.metadata.json")
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1367,11 +1465,14 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteTablePath(sourceTable)
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
             .execute();
-    checkFileNum(
-        iterations * 2 + 1, iterations, iterations, 0, iterations, iterations 
* 6 + 1, result);
-
-    findAndAssertFileInFileList(
-        result, "partition-stats", sourceTableLocation, targetTableLocation);
+    assertThat(result)
+        .hasVersionFiles(iterations * 2 + 1)
+        .hasManifestLists(iterations)
+        .hasManifests(iterations)
+        .hasPartitionStatisticsFiles(iterations)
+        .hasContentFiles(iterations)
+        .hasPartitionStatisticsFilesCopiedAsIs(sourceTableLocation, 
targetTableLocation)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1399,8 +1500,13 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(
-        iterations * 2 + 1, iterations, iterations, iterations, iterations * 6 
+ 1, result);
+    assertThat(result)
+        .hasVersionFiles(iterations * 2 + 1)
+        .hasManifestLists(iterations)
+        .hasManifests(iterations)
+        .hasStatisticsFiles(iterations)
+        .hasContentFiles(iterations)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1426,9 +1532,14 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
             .execute();
 
-    checkFileNum(3, 1, 1, 1, 7, result);
-
-    findAndAssertFileInFileList(result, ".stats", sourceTableLocation, 
targetTableLocation);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasStatisticsFiles(1)
+        .hasContentFiles(1)
+        .hasStatisticsFilesCopiedAsIs(sourceTableLocation, targetTableLocation)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1454,7 +1565,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion(endVersion)
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     // set the first version as the lastCopiedVersion
     String firstVersion = 
fileName(currentMetadata.previousFiles().get(0).file());
@@ -1465,7 +1581,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion(firstVersion)
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   // Metastore table tests
@@ -1492,7 +1613,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(newTableLocation(), targetTableLocation())
             .execute();
 
-    checkFileNum(4, 2, 2, 10, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // pick up a version from the old metadata dir as the end version
     RewriteTablePath.Result result1 =
@@ -1502,7 +1628,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion(fileName(metadataFilePath))
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result1);
+    assertThat(result1)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     // pick up a version from the old metadata dir as the last copied version
     RewriteTablePath.Result result2 =
@@ -1512,7 +1643,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion(fileName(metadataFilePath))
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result2);
+    assertThat(result2)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1564,7 +1700,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(newTableLocation(), targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
     // one data and one metadata file
     copyTableFiles(result);
 
@@ -1694,11 +1835,10 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .createFileList(false) // Disable file list creation
             .execute();
 
-    assertThat(result.latestVersion()).isEqualTo("v3.metadata.json");
-
-    assertThat(result.fileListLocation())
+    assertThat(result)
+        .hasLatestVersion("v3.metadata.json")
         .as("File list location should not be set when createFileList is 
false")
-        .isEqualTo(NOT_APPLICABLE);
+        .hasFileListLocation(NOT_APPLICABLE);
   }
 
   @TestTemplate
@@ -1717,76 +1857,17 @@ public class TestRewriteTablePathsAction extends 
TestBase {
               .executeWith(service)
               .execute();
 
-      checkFileNum(50, 50, 50, 200, result);
+      assertThat(result)
+          .hasVersionFiles(50)
+          .hasManifestLists(50)
+          .hasManifests(50)
+          .hasContentFiles(50)
+          .hasNoOtherFiles();
     } finally {
       service.shutdown();
     }
   }
 
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    checkFileNum(versionFileCount, manifestListCount, manifestFileCount, 0, 0, 
totalCount, result);
-  }
-
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int statisticsFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    checkFileNum(
-        versionFileCount,
-        manifestListCount,
-        manifestFileCount,
-        statisticsFileCount,
-        0,
-        totalCount,
-        result);
-  }
-
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int statisticsFileCount,
-      int partitionFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    List<String> filesToMove =
-        spark
-            .read()
-            .format("text")
-            .load(result.fileListLocation())
-            .as(Encoders.STRING())
-            .collectAsList();
-    Predicate<String> isManifest =
-        f -> f.contains("optimized-m-") || f.contains("-m0.") || 
f.contains("-m1.");
-    Predicate<String> isManifestList = f -> f.contains("snap-") && 
f.endsWith(".avro");
-    Predicate<String> isMetadataJSON = f -> f.endsWith(".metadata.json");
-
-    assertThat(filesToMove.stream().filter(isMetadataJSON))
-        .as("Wrong rebuilt version file count")
-        .hasSize(versionFileCount);
-    assertThat(filesToMove.stream().filter(isManifestList))
-        .as("Wrong rebuilt Manifest list file count")
-        .hasSize(manifestListCount);
-    assertThat(filesToMove.stream().filter(isManifest))
-        .as("Wrong rebuilt Manifest file file count")
-        .hasSize(manifestFileCount);
-    assertThat(filesToMove.stream().filter(f -> f.endsWith(".stats")))
-        .as("Wrong rebuilt Statistic file count")
-        .hasSize(statisticsFileCount);
-    assertThat(filesToMove.stream().filter(f -> f.contains("partition-stats")))
-        .as("Wrong rebuilt Partition Statistic file count")
-        .hasSize(partitionFileCount);
-    assertThat(filesToMove).as("Wrong total file count").hasSize(totalCount);
-  }
-
   protected String newTableLocation() throws IOException {
     return toAbsolute(newTableDir);
   }
@@ -1957,36 +2038,4 @@ public class TestRewriteTablePathsAction extends 
TestBase {
     blockInfoManager.removeBlock(blockId);
     blockManager.memoryStore().remove(blockId);
   }
-
-  private void findAndAssertFileInFileList(
-      RewriteTablePath.Result result,
-      String fileIdentifier,
-      String sourceTableLocation,
-      String targetTableLocation) {
-
-    List<Tuple2<String, String>> filesToMove = 
readPathPairList(result.fileListLocation());
-
-    // Find the file path pair that contains the specified file identifier
-    Tuple2<String, String> filePathPair =
-        filesToMove.stream()
-            .filter(pair -> pair._1().contains(fileIdentifier))
-            .findFirst()
-            .orElse(null);
-
-    // Assert that the file was found in the list
-    assertThat(filePathPair).as("Should find " + fileIdentifier + " file in 
file list").isNotNull();
-
-    // Validate source path: should point to source table location, contain 
metadata, and not
-    // staging
-    assertThat(filePathPair._1())
-        .as(fileIdentifier + " source should point to source table location 
and NOT staging")
-        .startsWith(sourceTableLocation)
-        .contains("/metadata/")
-        .doesNotContain("staging");
-
-    // Validate target path: should point to target table location
-    assertThat(filePathPair._2())
-        .as(fileIdentifier + " target should point to target table location")
-        .startsWith(targetTableLocation);
-  }
 }
diff --git 
a/spark/v4.2/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
 
b/spark/v4.2/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
index ef246c7a61..97203da89b 100644
--- 
a/spark/v4.2/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
+++ 
b/spark/v4.2/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iceberg.spark.actions;
 
+import static 
org.apache.iceberg.actions.RewriteTablePathResultAssert.assertThat;
 import static 
org.apache.iceberg.spark.actions.RewriteTablePathSparkAction.NOT_APPLICABLE;
 import static org.apache.iceberg.types.Types.NestedField.optional;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -33,7 +34,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
@@ -259,9 +259,13 @@ public class TestRewriteTablePathsAction extends TestBase {
             .endVersion("v3.metadata.json")
             .execute();
 
-    assertThat(result.latestVersion()).isEqualTo("v3.metadata.json");
-
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasLatestVersion("v3.metadata.json")
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -308,7 +312,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v2.metadata.json")
             .execute();
 
-    checkFileNum(1, 1, 1, 4, result);
+    assertThat(result)
+        .hasVersionFiles(1)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     List<Tuple2<String, String>> paths = 
readPathPairList(result.fileListLocation());
 
@@ -382,7 +391,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v2.metadata.json")
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // start from the first version
     RewriteTablePath.Result result1 =
@@ -392,7 +406,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .startVersion("v1.metadata.json")
             .execute();
 
-    checkFileNum(3, 3, 3, 12, result1);
+    assertThat(result1)
+        .hasVersionFiles(3)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -403,7 +422,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(tableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -414,7 +438,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(table.location(), targetTableLocation())
             .stagingLocation(stagingLocation())
             .execute();
-    checkFileNum(3, 2, 2, 9, initialResult);
+    assertThat(initialResult)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // rewrite manifest without change data files
     RewriteManifests.Result rewriteManifestResult = 
actions().rewriteManifests(table).execute();
@@ -430,7 +459,11 @@ public class TestRewriteTablePathsAction extends TestBase {
             .execute();
 
     // no data files need to move
-    checkFileNum(1, 1, addedManifest, 3, postReweiteResult);
+    assertThat(postReweiteResult)
+        .hasVersionFiles(1)
+        .hasManifestLists(1)
+        .hasManifests(addedManifest)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -453,7 +486,12 @@ public class TestRewriteTablePathsAction extends TestBase {
             .stagingLocation(stagingLocation())
             .execute();
 
-    checkFileNum(4, 3, 3, 12, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -525,7 +563,12 @@ public class TestRewriteTablePathsAction extends TestBase {
 
     // We have one more snapshot, an additional manifest list, and a new 
(delete) manifest,
     // and an additional position delete
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -577,7 +620,12 @@ public class TestRewriteTablePathsAction extends TestBase {
 
     // We have one more snapshot, an additional manifest list, and a new 
(delete) manifest,
     // and an additional position delete
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -648,9 +696,9 @@ public class TestRewriteTablePathsAction extends TestBase {
             .rewriteLocationPrefix(tableWithPosDeletes.location(), 
targetTableLocation())
             .execute();
 
-    assertThat(result.rewrittenDeleteFilePathsCount())
+    assertThat(result)
         .as("Should have rewritten exactly 1 delete file after deduplication")
-        .isEqualTo(1);
+        .hasRewrittenDeleteFilePaths(1);
   }
 
   // Regression test: when the same position delete file is referenced from 
manifests in different
@@ -900,9 +948,9 @@ public class TestRewriteTablePathsAction extends TestBase {
             .stagingLocation(stagingLocation())
             .rewriteLocationPrefix(tableWithDVs.location(), 
targetTableLocation())
             .execute();
-    assertThat(result.rewrittenDeleteFilePathsCount())
+    assertThat(result)
         .as("Two DVs are two delete files with rewritten paths")
-        .isEqualTo(2);
+        .hasRewrittenDeleteFilePaths(2);
     copyTableFiles(result);
 
     Table targetTable = TABLES.load(targetTableLocation());
@@ -986,7 +1034,12 @@ public class TestRewriteTablePathsAction extends TestBase 
{
     // We have four metadata files: for the table creation, for the initial 
snapshot, for the
     // second append here, and for commit with equality deletes. Thus, we have 
three manifest lists.
     // We have a data file for each snapshot (two with data, one with equality 
deletes)
-    checkFileNum(4, 3, 3, 13, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -1035,12 +1088,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(location, targetTableLocation())
             .execute();
 
-    checkFileNum(
-        totalIteration - missingVersionFile,
-        totalIteration - expiredManifestListCount,
-        totalIteration,
-        totalIteration * 4 - missingVersionFile - expiredManifestListCount - 
missingDataFile,
-        result);
+    assertThat(result)
+        .hasVersionFiles(totalIteration - missingVersionFile)
+        .hasManifestLists(totalIteration - expiredManifestListCount)
+        .hasManifests(totalIteration)
+        .hasContentFiles(totalIteration - missingDataFile)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1053,7 +1106,7 @@ public class TestRewriteTablePathsAction extends TestBase 
{
             .execute();
 
     // the only rebuilt file is v1.metadata.json since it contains no snapshot
-    checkFileNum(1, 0, 0, 1, result);
+    assertThat(result).hasVersionFiles(1).hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1068,7 +1121,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(table.location(), targetTableLocation())
             .execute();
 
-    checkFileNum(4, 1, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(1)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1110,7 +1168,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
     // 5 version files include 1 table creation 3 overwrite and 1 snapshot 
expiration
     // 3 overwrites generate 3 manifest list and 5 manifests with 3 data files
     // snapshot expiration removed 1 of each
-    checkFileNum(5, 2, 4, 13, result);
+    assertThat(result)
+        .hasVersionFiles(5)
+        .hasManifestLists(2)
+        .hasManifests(4)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // copy the metadata files and data files
     copyTableFiles(result);
@@ -1156,7 +1219,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // 2 metadata.json, 1 manifest list file, 1 manifest files
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1174,7 +1242,7 @@ public class TestRewriteTablePathsAction extends TestBase 
{
             .execute();
 
     // only v4.metadata.json needs to move
-    checkFileNum(1, 0, 0, 1, result);
+    assertThat(result).hasVersionFiles(1).hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1220,7 +1288,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(table.location(), newTableLocation())
             .stagingLocation(stagingLocation())
             .execute();
-    checkFileNum(6, 3, 3, 15, result);
+    assertThat(result)
+        .hasVersionFiles(6)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1245,7 +1318,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // There are 3 snapshots in total, although the current snapshot is the 
second one.
-    checkFileNum(5, 3, 3, 14, result);
+    assertThat(result)
+        .hasVersionFiles(5)
+        .hasManifestLists(3)
+        .hasManifests(3)
+        .hasContentFiles(3)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1262,7 +1340,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .execute();
 
     // check the result
-    checkFileNum(4, 2, 2, 10, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1280,7 +1363,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1297,7 +1385,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion("v2.gz.metadata.json")
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     result =
         actions()
@@ -1306,7 +1399,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion("v1.gz.metadata.json")
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1367,11 +1465,14 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteTablePath(sourceTable)
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
             .execute();
-    checkFileNum(
-        iterations * 2 + 1, iterations, iterations, 0, iterations, iterations 
* 6 + 1, result);
-
-    findAndAssertFileInFileList(
-        result, "partition-stats", sourceTableLocation, targetTableLocation);
+    assertThat(result)
+        .hasVersionFiles(iterations * 2 + 1)
+        .hasManifestLists(iterations)
+        .hasManifests(iterations)
+        .hasPartitionStatisticsFiles(iterations)
+        .hasContentFiles(iterations)
+        .hasPartitionStatisticsFilesCopiedAsIs(sourceTableLocation, 
targetTableLocation)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1399,8 +1500,13 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation())
             .execute();
 
-    checkFileNum(
-        iterations * 2 + 1, iterations, iterations, iterations, iterations * 6 
+ 1, result);
+    assertThat(result)
+        .hasVersionFiles(iterations * 2 + 1)
+        .hasManifestLists(iterations)
+        .hasManifests(iterations)
+        .hasStatisticsFiles(iterations)
+        .hasContentFiles(iterations)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1426,9 +1532,14 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
             .execute();
 
-    checkFileNum(3, 1, 1, 1, 7, result);
-
-    findAndAssertFileInFileList(result, ".stats", sourceTableLocation, 
targetTableLocation);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasStatisticsFiles(1)
+        .hasContentFiles(1)
+        .hasStatisticsFilesCopiedAsIs(sourceTableLocation, targetTableLocation)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1454,7 +1565,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion(endVersion)
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     // set the first version as the lastCopiedVersion
     String firstVersion = 
fileName(currentMetadata.previousFiles().get(0).file());
@@ -1465,7 +1581,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion(firstVersion)
             .execute();
 
-    checkFileNum(2, 2, 2, 8, result);
+    assertThat(result)
+        .hasVersionFiles(2)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
   }
 
   // Metastore table tests
@@ -1492,7 +1613,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(newTableLocation(), targetTableLocation())
             .execute();
 
-    checkFileNum(4, 2, 2, 10, result);
+    assertThat(result)
+        .hasVersionFiles(4)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
 
     // pick up a version from the old metadata dir as the end version
     RewriteTablePath.Result result1 =
@@ -1502,7 +1628,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .endVersion(fileName(metadataFilePath))
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result1);
+    assertThat(result1)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
 
     // pick up a version from the old metadata dir as the last copied version
     RewriteTablePath.Result result2 =
@@ -1512,7 +1643,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .startVersion(fileName(metadataFilePath))
             .execute();
 
-    checkFileNum(2, 1, 1, 5, result2);
+    assertThat(result2)
+        .hasVersionFiles(2)
+        .hasManifestLists(1)
+        .hasManifests(1)
+        .hasContentFiles(1)
+        .hasNoOtherFiles();
   }
 
   @TestTemplate
@@ -1564,7 +1700,12 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .rewriteLocationPrefix(newTableLocation(), targetTableLocation())
             .execute();
 
-    checkFileNum(3, 2, 2, 9, result);
+    assertThat(result)
+        .hasVersionFiles(3)
+        .hasManifestLists(2)
+        .hasManifests(2)
+        .hasContentFiles(2)
+        .hasNoOtherFiles();
     // one data and one metadata file
     copyTableFiles(result);
 
@@ -1694,11 +1835,10 @@ public class TestRewriteTablePathsAction extends 
TestBase {
             .createFileList(false) // Disable file list creation
             .execute();
 
-    assertThat(result.latestVersion()).isEqualTo("v3.metadata.json");
-
-    assertThat(result.fileListLocation())
+    assertThat(result)
+        .hasLatestVersion("v3.metadata.json")
         .as("File list location should not be set when createFileList is 
false")
-        .isEqualTo(NOT_APPLICABLE);
+        .hasFileListLocation(NOT_APPLICABLE);
   }
 
   @TestTemplate
@@ -1717,76 +1857,17 @@ public class TestRewriteTablePathsAction extends 
TestBase {
               .executeWith(service)
               .execute();
 
-      checkFileNum(50, 50, 50, 200, result);
+      assertThat(result)
+          .hasVersionFiles(50)
+          .hasManifestLists(50)
+          .hasManifests(50)
+          .hasContentFiles(50)
+          .hasNoOtherFiles();
     } finally {
       service.shutdown();
     }
   }
 
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    checkFileNum(versionFileCount, manifestListCount, manifestFileCount, 0, 0, 
totalCount, result);
-  }
-
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int statisticsFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    checkFileNum(
-        versionFileCount,
-        manifestListCount,
-        manifestFileCount,
-        statisticsFileCount,
-        0,
-        totalCount,
-        result);
-  }
-
-  protected void checkFileNum(
-      int versionFileCount,
-      int manifestListCount,
-      int manifestFileCount,
-      int statisticsFileCount,
-      int partitionFileCount,
-      int totalCount,
-      RewriteTablePath.Result result) {
-    List<String> filesToMove =
-        spark
-            .read()
-            .format("text")
-            .load(result.fileListLocation())
-            .as(Encoders.STRING())
-            .collectAsList();
-    Predicate<String> isManifest =
-        f -> f.contains("optimized-m-") || f.contains("-m0.") || 
f.contains("-m1.");
-    Predicate<String> isManifestList = f -> f.contains("snap-") && 
f.endsWith(".avro");
-    Predicate<String> isMetadataJSON = f -> f.endsWith(".metadata.json");
-
-    assertThat(filesToMove.stream().filter(isMetadataJSON))
-        .as("Wrong rebuilt version file count")
-        .hasSize(versionFileCount);
-    assertThat(filesToMove.stream().filter(isManifestList))
-        .as("Wrong rebuilt Manifest list file count")
-        .hasSize(manifestListCount);
-    assertThat(filesToMove.stream().filter(isManifest))
-        .as("Wrong rebuilt Manifest file file count")
-        .hasSize(manifestFileCount);
-    assertThat(filesToMove.stream().filter(f -> f.endsWith(".stats")))
-        .as("Wrong rebuilt Statistic file count")
-        .hasSize(statisticsFileCount);
-    assertThat(filesToMove.stream().filter(f -> f.contains("partition-stats")))
-        .as("Wrong rebuilt Partition Statistic file count")
-        .hasSize(partitionFileCount);
-    assertThat(filesToMove).as("Wrong total file count").hasSize(totalCount);
-  }
-
   protected String newTableLocation() throws IOException {
     return toAbsolute(newTableDir);
   }
@@ -1957,36 +2038,4 @@ public class TestRewriteTablePathsAction extends 
TestBase {
     blockInfoManager.removeBlock(blockId);
     blockManager.memoryStore().remove(blockId);
   }
-
-  private void findAndAssertFileInFileList(
-      RewriteTablePath.Result result,
-      String fileIdentifier,
-      String sourceTableLocation,
-      String targetTableLocation) {
-
-    List<Tuple2<String, String>> filesToMove = 
readPathPairList(result.fileListLocation());
-
-    // Find the file path pair that contains the specified file identifier
-    Tuple2<String, String> filePathPair =
-        filesToMove.stream()
-            .filter(pair -> pair._1().contains(fileIdentifier))
-            .findFirst()
-            .orElse(null);
-
-    // Assert that the file was found in the list
-    assertThat(filePathPair).as("Should find " + fileIdentifier + " file in 
file list").isNotNull();
-
-    // Validate source path: should point to source table location, contain 
metadata, and not
-    // staging
-    assertThat(filePathPair._1())
-        .as(fileIdentifier + " source should point to source table location 
and NOT staging")
-        .startsWith(sourceTableLocation)
-        .contains("/metadata/")
-        .doesNotContain("staging");
-
-    // Validate target path: should point to target table location
-    assertThat(filePathPair._2())
-        .as(fileIdentifier + " target should point to target table location")
-        .startsWith(targetTableLocation);
-  }
 }

Reply via email to