GH-3615: Use assertThat checks in parquet-variant tests#3617
Open
nastra wants to merge 2 commits into
Open
Conversation
nastra
commented
Jun 19, 2026
| } | ||
| // An object header | ||
| Variant value = new Variant(ByteBuffer.wrap(new byte[] {0b1000010}), VariantTestUtil.EMPTY_METADATA); | ||
| assertThatThrownBy(value::numArrayElements) |
Contributor
Author
There was a problem hiding this comment.
Previously with Assert.fail we would have a larger block where it wasn't clear code line of code would actually throw the exception and what error msg would be returned. We're more explicit now in terms of testing error conditions, because we check the underlying exception and the error msg.
nastra
commented
Jun 19, 2026
| "Expected decimal type, got " + type, | ||
| type == Variant.Type.DECIMAL4 || type == Variant.Type.DECIMAL8 || type == Variant.Type.DECIMAL16); | ||
| Assert.assertEquals(0, new BigDecimal("3.14").compareTo(v.getDecimal())); | ||
| assertThat(type).isIn(Variant.Type.DECIMAL4, Variant.Type.DECIMAL8, Variant.Type.DECIMAL16); |
Contributor
Author
There was a problem hiding this comment.
if this check ever fails, then it will me much clearer what the issue is, because previously it would only say false is not true. I've modified the check to show how such an error msg would look:
Expecting actual:
DECIMAL16
to be in:
[DECIMAL4, DECIMAL8]
nastra
commented
Jun 19, 2026
| .hasMessageContaining("was expecting double-quote to start field name"); | ||
| } | ||
|
|
||
| @Test(expected = IOException.class) |
Contributor
Author
There was a problem hiding this comment.
we're also more explicit here in terms of testing failure conditions
e65071b to
7215ca4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
This introduces AssertJ for testing, which enables more fluent assertion checks, easier debugging and overall easier testing. Additional details about the motivation can be found in #3615
What changes are included in this PR?
added the assertj library to the test scope. Also updated parquet-variant to use the new
assertThatchecks to make test code more readableAre these changes tested?
yes, existing tests
Are there any user-facing changes?
no