From b378f1fe9d2cebffee0991411c0d2735757d726d Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Thu, 17 Sep 2020 11:25:16 +0200 Subject: [PATCH] Use AssertJ for better exception message TestNG's `assertEquals` does not cite collection contents when actual and expected have different size. --- .../java/io/prestosql/testing/datatype/DataTypeTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/presto-testing/src/main/java/io/prestosql/testing/datatype/DataTypeTest.java b/presto-testing/src/main/java/io/prestosql/testing/datatype/DataTypeTest.java index c858c6318533..f72b377efbdf 100644 --- a/presto-testing/src/main/java/io/prestosql/testing/datatype/DataTypeTest.java +++ b/presto-testing/src/main/java/io/prestosql/testing/datatype/DataTypeTest.java @@ -23,11 +23,13 @@ import java.util.ArrayList; import java.util.List; +import static com.google.common.base.Verify.verify; import static com.google.common.collect.Iterables.getOnlyElement; import static java.lang.String.format; import static java.lang.String.join; import static java.util.Collections.unmodifiableList; import static java.util.stream.Collectors.toList; +import static org.assertj.core.api.Assertions.assertThat; import static org.testng.Assert.assertEquals; public class DataTypeTest @@ -122,9 +124,9 @@ private String buildPrestoQueryWithWhereClauses(TestTable testTable) private void checkResults(List expectedTypes, List expectedResults, MaterializedResult materializedRows) { - assertEquals(materializedRows.getTypes(), expectedTypes); + assertThat(materializedRows.getTypes()).isEqualTo(expectedTypes); List actualResults = getOnlyElement(materializedRows).getFields(); - assertEquals(actualResults.size(), expectedResults.size(), "lists don't have the same size"); + verify(actualResults.size() == expectedResults.size(), "lists don't have the same size"); for (int i = 0; i < expectedResults.size(); i++) { assertEquals(actualResults.get(i), expectedResults.get(i), "Element " + i); }