18
18
*/
19
19
package org .apache .iceberg ;
20
20
21
+ import static org .assertj .core .api .Assertions .assertThat ;
22
+
21
23
import java .util .Comparator ;
22
24
import java .util .List ;
23
25
import java .util .stream .Collectors ;
24
- import org .junit .Assert ;
25
26
26
27
public final class TaskCheckHelper {
27
28
private TaskCheckHelper () {}
@@ -31,8 +32,9 @@ public static void assertEquals(
31
32
List <FileScanTask > expectedTasks = getFileScanTasksInFilePathOrder (expected );
32
33
List <FileScanTask > actualTasks = getFileScanTasksInFilePathOrder (actual );
33
34
34
- Assert .assertEquals (
35
- "The number of file scan tasks should match" , expectedTasks .size (), actualTasks .size ());
35
+ assertThat (actualTasks )
36
+ .as ("The number of file scan tasks should match" )
37
+ .hasSameSizeAs (expectedTasks );
36
38
37
39
for (int i = 0 ; i < expectedTasks .size (); i ++) {
38
40
FileScanTask expectedTask = expectedTasks .get (i );
@@ -45,61 +47,55 @@ public static void assertEquals(FileScanTask expected, FileScanTask actual) {
45
47
assertEquals (expected .file (), actual .file ());
46
48
47
49
// PartitionSpec implements its own equals method
48
- Assert . assertEquals ( "PartitionSpec doesn't match" , expected . spec (), actual .spec ());
50
+ assertThat ( actual . spec ()). as ( "PartitionSpec doesn't match" ). isEqualTo ( expected .spec ());
49
51
50
- Assert . assertEquals ( "starting position doesn't match" , expected . start (), actual .start ());
52
+ assertThat ( actual . start ()). as ( "starting position doesn't match" ). isEqualTo ( expected .start ());
51
53
52
- Assert .assertEquals (
53
- "the number of bytes to scan doesn't match" , expected .start (), actual .start ());
54
+ assertThat (actual .start ())
55
+ .as ("the number of bytes to scan doesn't match" )
56
+ .isEqualTo (expected .start ());
54
57
55
58
// simplify comparison on residual expression via comparing toString
56
- Assert . assertEquals (
57
- "Residual expression doesn't match" ,
58
- expected . residual (). toString (),
59
- actual .residual ().toString ());
59
+ assertThat ( actual . residual ())
60
+ . asString ()
61
+ . as ( "Residual expression doesn't match" )
62
+ . isEqualTo ( expected .residual ().toString ());
60
63
}
61
64
62
65
public static void assertEquals (DataFile expected , DataFile actual ) {
63
- Assert .assertEquals (
64
- "Should match the serialized record path" , expected .location (), actual .location ());
65
- Assert .assertEquals (
66
- "Should match the serialized record format" , expected .format (), actual .format ());
67
- Assert .assertEquals (
68
- "Should match the serialized record partition" ,
69
- expected .partition ().get (0 , Object .class ),
70
- actual .partition ().get (0 , Object .class ));
71
- Assert .assertEquals (
72
- "Should match the serialized record count" , expected .recordCount (), actual .recordCount ());
73
- Assert .assertEquals (
74
- "Should match the serialized record size" ,
75
- expected .fileSizeInBytes (),
76
- actual .fileSizeInBytes ());
77
- Assert .assertEquals (
78
- "Should match the serialized record value counts" ,
79
- expected .valueCounts (),
80
- actual .valueCounts ());
81
- Assert .assertEquals (
82
- "Should match the serialized record null value counts" ,
83
- expected .nullValueCounts (),
84
- actual .nullValueCounts ());
85
- Assert .assertEquals (
86
- "Should match the serialized record lower bounds" ,
87
- expected .lowerBounds (),
88
- actual .lowerBounds ());
89
- Assert .assertEquals (
90
- "Should match the serialized record upper bounds" ,
91
- expected .upperBounds (),
92
- actual .upperBounds ());
93
- Assert .assertEquals (
94
- "Should match the serialized record key metadata" ,
95
- expected .keyMetadata (),
96
- actual .keyMetadata ());
97
- Assert .assertEquals (
98
- "Should match the serialized record offsets" ,
99
- expected .splitOffsets (),
100
- actual .splitOffsets ());
101
- Assert .assertEquals (
102
- "Should match the serialized record offsets" , expected .keyMetadata (), actual .keyMetadata ());
66
+ assertThat (actual .location ())
67
+ .as ("Should match the serialized record path" )
68
+ .isEqualTo (expected .location ());
69
+ assertThat (actual .format ())
70
+ .as ("Should match the serialized record format" )
71
+ .isEqualTo (expected .format ());
72
+ assertThat (actual .partition ().get (0 , Object .class ))
73
+ .as ("Should match the serialized record partition" )
74
+ .isEqualTo (expected .partition ().get (0 , Object .class ));
75
+ assertThat (actual .recordCount ())
76
+ .as ("Should match the serialized record count" )
77
+ .isEqualTo (expected .recordCount ());
78
+ assertThat (actual .fileSizeInBytes ())
79
+ .as ("Should match the serialized record size" )
80
+ .isEqualTo (expected .fileSizeInBytes ());
81
+ assertThat (actual .valueCounts ())
82
+ .as ("Should match the serialized record value counts" )
83
+ .isEqualTo (expected .valueCounts ());
84
+ assertThat (actual .nullValueCounts ())
85
+ .as ("Should match the serialized record null value counts" )
86
+ .isEqualTo (expected .nullValueCounts ());
87
+ assertThat (actual .lowerBounds ())
88
+ .as ("Should match the serialized record lower bounds" )
89
+ .isEqualTo (expected .lowerBounds ());
90
+ assertThat (actual .upperBounds ())
91
+ .as ("Should match the serialized record upper bounds" )
92
+ .isEqualTo (expected .upperBounds ());
93
+ assertThat (actual .keyMetadata ())
94
+ .as ("Should match the serialized record key metadata" )
95
+ .isEqualTo (expected .keyMetadata ());
96
+ assertThat (actual .splitOffsets ())
97
+ .as ("Should match the serialized record offsets" )
98
+ .isEqualTo (expected .splitOffsets ());
103
99
}
104
100
105
101
private static List <FileScanTask > getFileScanTasksInFilePathOrder (
0 commit comments