Core: Use mocks in TrackedFile tests#17133
Conversation
|
|
||
| /** Mutable {@link StructLike} implementation of {@link TrackedFile}. */ | ||
| class TrackedFileStruct extends SupportsIndexProjection implements TrackedFile, Serializable { | ||
| private static final Types.StructType EMPTY_STRUCT_TYPE = Types.StructType.of(); |
There was a problem hiding this comment.
This struct is still used in the BASE_TYPE just below.
0f2d8c1 to
83d6309
Compare
| assertThat(copy.partition()).isSameAs(PARTITION_COPY); | ||
|
|
||
| // mutable fields are deep-copied, not shared with the original | ||
| assertThat(copy.tracking()).isNotSameAs(file.tracking()); |
There was a problem hiding this comment.
nit: it might make more sense to keep the two isSameAs assertions here to check they are deep copied and not shared with the original object, as the comment above described.
There was a problem hiding this comment.
My rationale is that isSameAs(x) implies isNotSameAs(y) if x is not the same as y because the relation is transitive. By verifying isSameAs, this is already ensuring it is the result of copy.
We could go further and use this as a validation that copy produces a different object (it does not always) but that is the responsibility of the tests for TrackingStruct, not TrackedFileStruct.
| .withFieldStats(BaseFieldStats.builder().fieldId(1).build()) | ||
| .withFieldStats(BaseFieldStats.builder().fieldId(2).build()) | ||
| .build(); | ||
| private static final ContentStats CONTENT_STATS = Mockito.mock(ContentStats.class); |
There was a problem hiding this comment.
Note this conflicts with #17159 (https://github.com/apache/iceberg/pull/17159/changes#diff-2e1fd2a7ed0bab2997b0ccc363eb220bc17cbe6e8db8ba6a199826091d8b4b09L75-R82). I'll rebase and fix this depending on which one makes it in first.
|
Merged. Thanks for reviewing, @stevenzwu, @gaborkaszab, @anoopj, and @amogh-jahagirdar! |
This updates
TestTrackedFileStructto use mock objects for plumbing tests rather than creating instances ofTrackingStructandPartitionData.