Skip to content

GH-3615: Use assertThat checks in parquet-variant tests#3617

Open
nastra wants to merge 2 commits into
apache:masterfrom
nastra:assertj-parquet-variant
Open

GH-3615: Use assertThat checks in parquet-variant tests#3617
nastra wants to merge 2 commits into
apache:masterfrom
nastra:assertj-parquet-variant

Conversation

@nastra

@nastra nastra commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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 assertThat checks to make test code more readable

Are these changes tested?

yes, existing tests

Are there any user-facing changes?

no

}
// An object header
Variant value = new Variant(ByteBuffer.wrap(new byte[] {0b1000010}), VariantTestUtil.EMPTY_METADATA);
assertThatThrownBy(value::numArrayElements)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

"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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

.hasMessageContaining("was expecting double-quote to start field name");
}

@Test(expected = IOException.class)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're also more explicit here in terms of testing failure conditions

@nastra nastra force-pushed the assertj-parquet-variant branch from e65071b to 7215ca4 Compare June 19, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant