diff --git a/client/trino-cli/pom.xml b/client/trino-cli/pom.xml index 992bd6d8b3a4..7d9505ff0ed2 100644 --- a/client/trino-cli/pom.xml +++ b/client/trino-cli/pom.xml @@ -157,24 +157,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - org.apache.maven.plugins maven-shade-plugin diff --git a/lib/trino-hdfs/src/test/java/io/trino/hdfs/rubix/TestRubixCaching.java b/lib/trino-hdfs/src/test/java/io/trino/hdfs/rubix/TestRubixCaching.java index 870acf1adf5c..8acfa153871c 100644 --- a/lib/trino-hdfs/src/test/java/io/trino/hdfs/rubix/TestRubixCaching.java +++ b/lib/trino-hdfs/src/test/java/io/trino/hdfs/rubix/TestRubixCaching.java @@ -49,11 +49,13 @@ import org.apache.hadoop.fs.FilterFileSystem; import org.apache.hadoop.fs.Path; import org.gaul.modernizer_maven_annotations.SuppressModernizer; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; import javax.management.MBeanServer; import javax.management.ObjectName; @@ -91,9 +93,12 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; import static org.testng.Assert.assertEquals; -@Test(singleThreaded = true) +@TestInstance(PER_CLASS) +@Execution(SAME_THREAD) public class TestRubixCaching { private static final DataSize SMALL_FILE_SIZE = DataSize.of(1, MEGABYTE); @@ -109,7 +114,7 @@ public class TestRubixCaching private FileSystem nonCachingFileSystem; private FileSystem cachingFileSystem; - @BeforeClass + @BeforeAll public void setup() throws IOException { @@ -121,8 +126,8 @@ public void setup() nonCachingFileSystem = getNonCachingFileSystem(); } - @AfterMethod(alwaysRun = true) - @BeforeMethod + @AfterEach + @BeforeEach public void deinitializeRubix() { // revert static rubix initialization done by other tests @@ -223,7 +228,7 @@ private FileSystem getCachingFileSystem(HdfsContext context, Path path) return environment.getFileSystem(context, path); } - @AfterClass(alwaysRun = true) + @AfterAll public void tearDown() throws IOException { @@ -232,7 +237,7 @@ public void tearDown() mBeanServer = null; } - @AfterMethod(alwaysRun = true) + @AfterEach public void closeRubix() throws IOException { diff --git a/lib/trino-matching/pom.xml b/lib/trino-matching/pom.xml index b72955e2a4db..1eb145ae2dce 100644 --- a/lib/trino-matching/pom.xml +++ b/lib/trino-matching/pom.xml @@ -46,26 +46,4 @@ test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/lib/trino-memory-context/pom.xml b/lib/trino-memory-context/pom.xml index 96dd54a2f224..699c27c1dbfe 100644 --- a/lib/trino-memory-context/pom.xml +++ b/lib/trino-memory-context/pom.xml @@ -63,33 +63,5 @@ junit-jupiter-engine test - - - org.testng - testng - test - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/lib/trino-memory-context/src/test/java/io/trino/memory/context/TestMemoryContexts.java b/lib/trino-memory-context/src/test/java/io/trino/memory/context/TestMemoryContexts.java index df080eecbe5e..97ae0f0af20f 100644 --- a/lib/trino-memory-context/src/test/java/io/trino/memory/context/TestMemoryContexts.java +++ b/lib/trino-memory-context/src/test/java/io/trino/memory/context/TestMemoryContexts.java @@ -22,11 +22,8 @@ import static io.airlift.units.DataSize.Unit.MEGABYTE; import static io.trino.memory.context.AggregatedMemoryContext.newRootAggregatedMemoryContext; import static io.trino.memory.context.AggregatedMemoryContext.newSimpleAggregatedMemoryContext; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; public class TestMemoryContexts { @@ -41,14 +38,14 @@ public void testLocalMemoryContextClose() LocalMemoryContext localContext = aggregateContext.newLocalMemoryContext("test"); localContext.setBytes(100); - assertEquals(localContext.getBytes(), 100); - assertEquals(aggregateContext.getBytes(), 100); - assertEquals(reservationHandler.getReservation(), 100); + assertThat(localContext.getBytes()).isEqualTo(100); + assertThat(aggregateContext.getBytes()).isEqualTo(100); + assertThat(reservationHandler.getReservation()).isEqualTo(100); localContext.close(); - assertEquals(localContext.getBytes(), 0); - assertEquals(aggregateContext.getBytes(), 0); - assertEquals(reservationHandler.getReservation(), 0); + assertThat(localContext.getBytes()).isEqualTo(0); + assertThat(aggregateContext.getBytes()).isEqualTo(0); + assertThat(reservationHandler.getReservation()).isEqualTo(0); } @Test @@ -58,22 +55,22 @@ public void testMemoryContexts() AggregatedMemoryContext aggregateContext = newRootAggregatedMemoryContext(reservationHandler, GUARANTEED_MEMORY); LocalMemoryContext localContext = aggregateContext.newLocalMemoryContext("test"); - assertEquals(localContext.setBytes(10), NOT_BLOCKED); - assertEquals(localContext.getBytes(), 10); - assertEquals(aggregateContext.getBytes(), 10); - assertEquals(reservationHandler.getReservation(), aggregateContext.getBytes()); + assertThat(localContext.setBytes(10)).isEqualTo(NOT_BLOCKED); + assertThat(localContext.getBytes()).isEqualTo(10); + assertThat(aggregateContext.getBytes()).isEqualTo(10); + assertThat(reservationHandler.getReservation()).isEqualTo(aggregateContext.getBytes()); LocalMemoryContext secondLocalContext = aggregateContext.newLocalMemoryContext("test"); - assertEquals(secondLocalContext.setBytes(20), NOT_BLOCKED); - assertEquals(secondLocalContext.getBytes(), 20); - assertEquals(aggregateContext.getBytes(), 30); - assertEquals(localContext.getBytes(), 10); - assertEquals(reservationHandler.getReservation(), aggregateContext.getBytes()); + assertThat(secondLocalContext.setBytes(20)).isEqualTo(NOT_BLOCKED); + assertThat(secondLocalContext.getBytes()).isEqualTo(20); + assertThat(aggregateContext.getBytes()).isEqualTo(30); + assertThat(localContext.getBytes()).isEqualTo(10); + assertThat(reservationHandler.getReservation()).isEqualTo(aggregateContext.getBytes()); aggregateContext.close(); - assertEquals(aggregateContext.getBytes(), 0); - assertEquals(reservationHandler.getReservation(), 0); + assertThat(aggregateContext.getBytes()).isEqualTo(0); + assertThat(reservationHandler.getReservation()).isEqualTo(0); } @Test @@ -85,19 +82,19 @@ public void testTryReserve() AggregatedMemoryContext aggregateContext2 = parentContext.newAggregatedMemoryContext(); LocalMemoryContext childContext1 = aggregateContext1.newLocalMemoryContext("test"); - assertTrue(childContext1.trySetBytes(500)); - assertTrue(childContext1.trySetBytes(1_000)); - assertFalse(childContext1.trySetBytes(1_001)); - assertEquals(reservationHandler.getReservation(), parentContext.getBytes()); + assertThat(childContext1.trySetBytes(500)).isTrue(); + assertThat(childContext1.trySetBytes(1_000)).isTrue(); + assertThat(childContext1.trySetBytes(1_001)).isFalse(); + assertThat(reservationHandler.getReservation()).isEqualTo(parentContext.getBytes()); aggregateContext1.close(); aggregateContext2.close(); parentContext.close(); - assertEquals(aggregateContext1.getBytes(), 0); - assertEquals(aggregateContext2.getBytes(), 0); - assertEquals(parentContext.getBytes(), 0); - assertEquals(reservationHandler.getReservation(), 0); + assertThat(aggregateContext1.getBytes()).isEqualTo(0); + assertThat(aggregateContext2.getBytes()).isEqualTo(0); + assertThat(parentContext.getBytes()).isEqualTo(0); + assertThat(reservationHandler.getReservation()).isEqualTo(0); } @Test @@ -110,13 +107,13 @@ public void testHierarchicalMemoryContexts() LocalMemoryContext childContext1 = aggregateContext1.newLocalMemoryContext("test"); LocalMemoryContext childContext2 = aggregateContext2.newLocalMemoryContext("test"); - assertEquals(childContext1.setBytes(1), NOT_BLOCKED); - assertEquals(childContext2.setBytes(1), NOT_BLOCKED); + assertThat(childContext1.setBytes(1)).isEqualTo(NOT_BLOCKED); + assertThat(childContext2.setBytes(1)).isEqualTo(NOT_BLOCKED); - assertEquals(aggregateContext1.getBytes(), 1); - assertEquals(aggregateContext2.getBytes(), 1); - assertEquals(parentContext.getBytes(), aggregateContext1.getBytes() + aggregateContext2.getBytes()); - assertEquals(reservationHandler.getReservation(), parentContext.getBytes()); + assertThat(aggregateContext1.getBytes()).isEqualTo(1); + assertThat(aggregateContext2.getBytes()).isEqualTo(1); + assertThat(parentContext.getBytes()).isEqualTo(aggregateContext1.getBytes() + aggregateContext2.getBytes()); + assertThat(reservationHandler.getReservation()).isEqualTo(parentContext.getBytes()); } @Test @@ -129,22 +126,23 @@ public void testGuaranteedMemoryDoesntBlock() // exhaust the max memory available reservationHandler.exhaustMemory(); - assertEquals(reservationHandler.getReservation(), maxMemory); + assertThat(reservationHandler.getReservation()).isEqualTo(maxMemory); // even if the pool is exhausted we never block queries using a trivial amount of memory - assertEquals(childContext.setBytes(1_000), NOT_BLOCKED); - assertNotEquals(childContext.setBytes(GUARANTEED_MEMORY + 1), NOT_BLOCKED); + assertThat(childContext.setBytes(1_000)).isEqualTo(NOT_BLOCKED); + assertThat(childContext.setBytes(GUARANTEED_MEMORY + 1)) + .isNotEqualTo(NOT_BLOCKED); // at this point the memory contexts have reserved GUARANTEED_MEMORY + 1 bytes childContext.close(); parentContext.close(); - assertEquals(childContext.getBytes(), 0); - assertEquals(parentContext.getBytes(), 0); + assertThat(childContext.getBytes()).isEqualTo(0); + assertThat(parentContext.getBytes()).isEqualTo(0); // since we have exhausted the memory above after the memory contexts are closed // the pool must still be exhausted - assertEquals(reservationHandler.getReservation(), maxMemory); + assertThat(reservationHandler.getReservation()).isEqualTo(maxMemory); } @Test diff --git a/lib/trino-plugin-toolkit/pom.xml b/lib/trino-plugin-toolkit/pom.xml index 67ab71419396..cbdc83dd8351 100644 --- a/lib/trino-plugin-toolkit/pom.xml +++ b/lib/trino-plugin-toolkit/pom.xml @@ -213,24 +213,5 @@ - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - diff --git a/lib/trino-record-decoder/pom.xml b/lib/trino-record-decoder/pom.xml index 73e0fd62a3f8..96d06eb4caa6 100644 --- a/lib/trino-record-decoder/pom.xml +++ b/lib/trino-record-decoder/pom.xml @@ -195,24 +195,6 @@ - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - diff --git a/plugin/trino-accumulo/pom.xml b/plugin/trino-accumulo/pom.xml index 1d96733b1626..8d4b56b7952c 100644 --- a/plugin/trino-accumulo/pom.xml +++ b/plugin/trino-accumulo/pom.xml @@ -324,24 +324,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - org.apache.maven.plugins maven-dependency-plugin diff --git a/plugin/trino-base-jdbc/pom.xml b/plugin/trino-base-jdbc/pom.xml index 724676bc88c9..6210dac719e1 100644 --- a/plugin/trino-base-jdbc/pom.xml +++ b/plugin/trino-base-jdbc/pom.xml @@ -285,24 +285,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - org.antlr antlr4-maven-plugin diff --git a/plugin/trino-bigquery/pom.xml b/plugin/trino-bigquery/pom.xml index a8f6083349a8..c0495fdf8d51 100644 --- a/plugin/trino-bigquery/pom.xml +++ b/plugin/trino-bigquery/pom.xml @@ -489,23 +489,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - org.basepom.maven duplicate-finder-maven-plugin diff --git a/plugin/trino-cassandra/pom.xml b/plugin/trino-cassandra/pom.xml index 22c7d426e5f3..e125d36ecf2b 100644 --- a/plugin/trino-cassandra/pom.xml +++ b/plugin/trino-cassandra/pom.xml @@ -255,23 +255,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - org.basepom.maven duplicate-finder-maven-plugin diff --git a/plugin/trino-clickhouse/pom.xml b/plugin/trino-clickhouse/pom.xml index 562f2bfb0cdd..d2b332a954fc 100644 --- a/plugin/trino-clickhouse/pom.xml +++ b/plugin/trino-clickhouse/pom.xml @@ -206,26 +206,4 @@ test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java index 3a9f9b6ac94a..56f3ddde2ecf 100644 --- a/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java +++ b/plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java @@ -50,10 +50,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assumptions.abort; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; public class TestClickHouseConnectorTest extends BaseJdbcConnectorTest @@ -135,7 +131,7 @@ public void testAddColumnWithCommentSpecialCharacter(String comment) // Override because default storage engine doesn't support renaming columns try (TestTable table = new TestTable(getQueryRunner()::execute, "test_add_column_", "(a_varchar varchar NOT NULL) WITH (engine = 'mergetree', order_by = ARRAY['a_varchar'])")) { assertUpdate("ALTER TABLE " + table.getName() + " ADD COLUMN b_varchar varchar COMMENT " + varcharLiteral(comment)); - assertEquals(getColumnComment(table.getName(), "b_varchar"), comment); + assertThat(getColumnComment(table.getName(), "b_varchar")).isEqualTo(comment); } } @@ -195,10 +191,10 @@ public void testDropColumn() assertUpdate("DROP TABLE " + tableName); - assertFalse(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); assertUpdate("ALTER TABLE IF EXISTS " + tableName + " DROP COLUMN notExistColumn"); assertUpdate("ALTER TABLE IF EXISTS " + tableName + " DROP COLUMN IF EXISTS notExistColumn"); - assertFalse(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); } @Override @@ -221,7 +217,7 @@ public void testAddNotNullColumnToEmptyTable() String tableName = table.getName(); assertUpdate("ALTER TABLE " + tableName + " ADD COLUMN b_varchar varchar NOT NULL"); - assertFalse(columnIsNullable(tableName, "b_varchar")); + assertThat(columnIsNullable(tableName, "b_varchar")).isFalse(); assertUpdate("INSERT INTO " + tableName + " VALUES ('a', 'b')", 1); assertThat(query("TABLE " + tableName)) .skippingTypesCheck() @@ -237,13 +233,13 @@ public void testAddNotNullColumn() String tableName = table.getName(); assertUpdate("ALTER TABLE " + tableName + " ADD COLUMN b_varchar varchar NOT NULL"); - assertFalse(columnIsNullable(tableName, "b_varchar")); + assertThat(columnIsNullable(tableName, "b_varchar")).isFalse(); assertUpdate("INSERT INTO " + tableName + " VALUES ('a', 'b')", 1); // ClickHouse set an empty character as the default value assertUpdate("ALTER TABLE " + tableName + " ADD COLUMN c_varchar varchar NOT NULL"); - assertFalse(columnIsNullable(tableName, "c_varchar")); + assertThat(columnIsNullable(tableName, "c_varchar")).isFalse(); assertQuery("SELECT c_varchar FROM " + tableName, "VALUES ''"); } } @@ -260,7 +256,7 @@ public void testAddColumnWithComment() assertThat(getColumnComment(tableName, "b_varchar")).isEqualTo("test new column comment"); assertUpdate("ALTER TABLE " + tableName + " ADD COLUMN empty_comment varchar COMMENT ''"); - assertNull(getColumnComment(tableName, "empty_comment")); + assertThat(getColumnComment(tableName, "empty_comment")).isNull(); } } @@ -349,10 +345,10 @@ public void testDifferentEngine() String tableName = "test_add_column_" + randomNameSuffix(); // MergeTree assertUpdate("CREATE TABLE " + tableName + " (id int NOT NULL, x VARCHAR) WITH (engine = 'MergeTree', order_by = ARRAY['id'])"); - assertTrue(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isTrue(); assertUpdate("DROP TABLE " + tableName); assertUpdate("CREATE TABLE " + tableName + " (id int NOT NULL, x VARCHAR) WITH (engine = 'mergetree', order_by = ARRAY['id'])"); - assertTrue(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isTrue(); assertUpdate("DROP TABLE " + tableName); // MergeTree without order by assertQueryFails("CREATE TABLE " + tableName + " (id int NOT NULL, x VARCHAR) WITH (engine = 'MergeTree')", "The property of order_by is required for table engine MergeTree\\(\\)"); @@ -360,7 +356,7 @@ public void testDifferentEngine() // MergeTree with optional assertUpdate("CREATE TABLE " + tableName + " (id int NOT NULL, x VARCHAR, logdate DATE NOT NULL) WITH " + "(engine = 'MergeTree', order_by = ARRAY['id'], partition_by = ARRAY['logdate'])"); - assertTrue(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isTrue(); assertUpdate("DROP TABLE " + tableName); //Log families @@ -382,7 +378,7 @@ public void testTableProperty() String tableName = "test_add_column_" + randomNameSuffix(); // no table property, it should create a table with default Log engine table assertUpdate("CREATE TABLE " + tableName + " (id int NOT NULL, x VARCHAR)"); - assertTrue(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isTrue(); assertUpdate("DROP TABLE " + tableName); // one required property @@ -713,7 +709,7 @@ public void testCreateTableWithLongTableName() String validTableName = baseTableName + "z".repeat(maxTableNameLength().orElseThrow() - baseTableName.length()); assertUpdate("CREATE TABLE " + validTableName + " (a bigint)"); - assertTrue(getQueryRunner().tableExists(getSession(), validTableName)); + assertThat(getQueryRunner().tableExists(getSession(), validTableName)).isTrue(); assertThatThrownBy(() -> assertUpdate("DROP TABLE " + validTableName)) .hasMessageMatching("(?s).*(Bad path syntax|File name too long).*"); @@ -721,7 +717,7 @@ public void testCreateTableWithLongTableName() assertThatThrownBy(() -> query("CREATE TABLE " + invalidTableName + " (a bigint)")) .hasMessageMatching("(?s).*(Cannot open file|File name too long).*"); // ClickHouse lefts a table even if the above statement failed - assertTrue(getQueryRunner().tableExists(getSession(), validTableName)); + assertThat(getQueryRunner().tableExists(getSession(), validTableName)).isTrue(); } @Test @@ -775,7 +771,7 @@ public void testRenameTableToLongTableName() String validTargetTableName = baseTableName + "z".repeat(255 - ".sql".length() - baseTableName.length()); assertUpdate("ALTER TABLE " + sourceTableName + " RENAME TO " + validTargetTableName); - assertTrue(getQueryRunner().tableExists(getSession(), validTargetTableName)); + assertThat(getQueryRunner().tableExists(getSession(), validTargetTableName)).isTrue(); assertQuery("SELECT x FROM " + validTargetTableName, "VALUES 123"); assertThatThrownBy(() -> assertUpdate("DROP TABLE " + validTargetTableName)) .hasMessageMatching("(?s).*(Bad path syntax|File name too long).*"); @@ -784,7 +780,7 @@ public void testRenameTableToLongTableName() String invalidTargetTableName = validTargetTableName + "z"; assertThatThrownBy(() -> assertUpdate("ALTER TABLE " + sourceTableName + " RENAME TO " + invalidTargetTableName)) .hasMessageMatching("(?s).*(Cannot rename|File name too long).*"); - assertFalse(getQueryRunner().tableExists(getSession(), invalidTargetTableName)); + assertThat(getQueryRunner().tableExists(getSession(), invalidTargetTableName)).isFalse(); } @Test diff --git a/plugin/trino-delta-lake/pom.xml b/plugin/trino-delta-lake/pom.xml index 932f6a96b39e..3e6d398acbdb 100644 --- a/plugin/trino-delta-lake/pom.xml +++ b/plugin/trino-delta-lake/pom.xml @@ -15,15 +15,6 @@ ${project.parent.basedir} - - - instances @@ -449,33 +440,10 @@ testcontainers test - - - org.testng - testng - test - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - org.apache.maven.plugins maven-dependency-plugin diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeConnectorSmokeTest.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeConnectorSmokeTest.java index ff7601c9b5a5..07a0eb065be3 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeConnectorSmokeTest.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeConnectorSmokeTest.java @@ -43,7 +43,6 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import org.testng.SkipException; import java.util.List; import java.util.Map; @@ -84,10 +83,8 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assumptions.abort; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; @TestInstance(PER_CLASS) public abstract class BaseDeltaLakeConnectorSmokeTest @@ -457,9 +454,9 @@ public void testInputDataSize() getLocationForTable(bucketName, "foo"))); MaterializedResultWithQueryId deltaResult = queryRunner.executeWithQueryId(broadcastJoinDistribution(true), "SELECT * FROM foo"); - assertEquals(deltaResult.getResult().getRowCount(), 2); + assertThat(deltaResult.getResult().getRowCount()).isEqualTo(2); MaterializedResultWithQueryId hiveResult = queryRunner.executeWithQueryId(broadcastJoinDistribution(true), format("SELECT * FROM %s.%s.%s", "hive", SCHEMA, hiveTableName)); - assertEquals(hiveResult.getResult().getRowCount(), 2); + assertThat(hiveResult.getResult().getRowCount()).isEqualTo(2); QueryManager queryManager = queryRunner.getCoordinator().getQueryManager(); assertThat(queryManager.getFullQueryInfo(deltaResult.getQueryId()).getQueryStats().getProcessedInputDataSize()).as("delta processed input data size") @@ -485,7 +482,7 @@ public void testHiveViewsCannotBeAccessed() String viewName = "dummy_view"; hiveHadoop.runOnHive("CREATE DATABASE " + schemaName); hiveHadoop.runOnHive(format("CREATE VIEW %s.%s AS SELECT * FROM %s.customer", schemaName, viewName, SCHEMA)); - assertEquals(computeScalar(format("SHOW TABLES FROM %s LIKE '%s'", schemaName, viewName)), viewName); + assertThat(computeScalar(format("SHOW TABLES FROM %s LIKE '%s'", schemaName, viewName))).isEqualTo(viewName); assertThatThrownBy(() -> computeActual("DESCRIBE " + schemaName + "." + viewName)).hasMessageContaining(format("%s.%s is not a Delta Lake table", schemaName, viewName)); hiveHadoop.runOnHive("DROP DATABASE " + schemaName + " CASCADE"); } @@ -497,7 +494,7 @@ public void testNonDeltaTablesCannotBeAccessed() String tableName = "hive_table"; hiveHadoop.runOnHive("CREATE DATABASE " + schemaName); hiveHadoop.runOnHive(format("CREATE TABLE %s.%s (id BIGINT)", schemaName, tableName)); - assertEquals(computeScalar(format("SHOW TABLES FROM %s LIKE '%s'", schemaName, tableName)), tableName); + assertThat(computeScalar(format("SHOW TABLES FROM %s LIKE '%s'", schemaName, tableName))).isEqualTo(tableName); assertThatThrownBy(() -> computeActual("DESCRIBE " + schemaName + "." + tableName)).hasMessageContaining(tableName + " is not a Delta Lake table"); hiveHadoop.runOnHive("DROP DATABASE " + schemaName + " CASCADE"); } @@ -521,9 +518,9 @@ public void testDropOssDataLakeTable() private void testDropTable(String tableName, String resourcePath) { registerTableFromResources(tableName, resourcePath, getQueryRunner()); - assertTrue(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isTrue(); assertUpdate("DROP TABLE " + tableName); - assertFalse(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); assertThat(getTableFiles(tableName)).hasSizeGreaterThan(1); // the data should not be deleted } @@ -856,7 +853,7 @@ public void testExternalTableFilesRetainedOnDrop() "SELECT count(*) FROM nation"); int fileCount = getTableFiles(tableName).size(); assertUpdate(format("DROP TABLE %s.%s", schemaName, tableName)); - assertEquals(getTableFiles(tableName).size(), fileCount); + assertThat(getTableFiles(tableName).size()).isEqualTo(fileCount); } @Test @@ -1919,7 +1916,7 @@ private void invalidateMetadataCache(String tableName) private void testCountQuery(@Language("SQL") String sql, long expectedRowCount, long expectedSplitCount) { MaterializedResultWithQueryId result = getDistributedQueryRunner().executeWithQueryId(getSession(), sql); - assertEquals(result.getResult().getOnlyColumnAsSet(), ImmutableSet.of(expectedRowCount)); + assertThat(result.getResult().getOnlyColumnAsSet()).isEqualTo(ImmutableSet.of(expectedRowCount)); verifySplitCount(result.getQueryId(), expectedSplitCount); } @@ -1945,7 +1942,7 @@ private OperatorStats getOperatorStats(QueryId queryId) public void testDelete() { if (!hasBehavior(SUPPORTS_DELETE)) { - throw new SkipException("testDelete requires DELETE support"); + abort("testDelete requires DELETE support"); } String tableName = "test_delete_" + randomNameSuffix(); diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeRegisterTableProcedureTest.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeRegisterTableProcedureTest.java index 94cbf68ea9cd..8de5cbe0da43 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeRegisterTableProcedureTest.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeRegisterTableProcedureTest.java @@ -46,7 +46,6 @@ import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.Assert.assertFalse; @TestInstance(PER_CLASS) public abstract class BaseDeltaLakeRegisterTableProcedureTest @@ -110,7 +109,7 @@ public void testRegisterTable() // Drop table from metastore and use the table content to register a table metastore.dropTable(SCHEMA, tableName, false); // Verify that dropTableFromMetastore actually works - assertFalse(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); assertQuerySucceeds(format("CALL system.register_table('%s', '%s', '%s')", SCHEMA, tableName, tableLocation)); String showCreateTableNew = (String) computeScalar("SHOW CREATE TABLE " + tableName); diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeSharedMetastoreWithTableRedirectionsTest.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeSharedMetastoreWithTableRedirectionsTest.java index 69545aa2a536..1bc9f0cddcc5 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeSharedMetastoreWithTableRedirectionsTest.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeSharedMetastoreWithTableRedirectionsTest.java @@ -20,7 +20,6 @@ import static io.trino.testing.TestingNames.randomNameSuffix; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.Assert.assertEquals; @TestInstance(PER_CLASS) public abstract class BaseDeltaLakeSharedMetastoreWithTableRedirectionsTest @@ -85,13 +84,9 @@ public void testShowSchemas() .containsAll("VALUES '" + schema + "'"); String showCreateHiveWithRedirectionsSchema = (String) computeActual("SHOW CREATE SCHEMA hive_with_redirections." + schema).getOnlyValue(); - assertEquals( - showCreateHiveWithRedirectionsSchema, - getExpectedHiveCreateSchema("hive_with_redirections")); + assertThat(showCreateHiveWithRedirectionsSchema).isEqualTo(getExpectedHiveCreateSchema("hive_with_redirections")); String showCreateDeltaLakeWithRedirectionsSchema = (String) computeActual("SHOW CREATE SCHEMA delta_with_redirections." + schema).getOnlyValue(); - assertEquals( - showCreateDeltaLakeWithRedirectionsSchema, - getExpectedDeltaLakeCreateSchema("delta_with_redirections")); + assertThat(showCreateDeltaLakeWithRedirectionsSchema).isEqualTo(getExpectedDeltaLakeCreateSchema("delta_with_redirections")); } @Test diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeTableWithCustomLocation.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeTableWithCustomLocation.java index 025decd4a7bd..8c5f0130ad56 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeTableWithCustomLocation.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/BaseDeltaLakeTableWithCustomLocation.java @@ -31,9 +31,6 @@ import static io.trino.testing.TestingNames.randomNameSuffix; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; public abstract class BaseDeltaLakeTableWithCustomLocation extends AbstractTestQueryFramework @@ -49,7 +46,9 @@ public void testTableHasUuidSuffixInLocation() String tableName = "table_with_uuid" + randomNameSuffix(); assertQuerySucceeds(format("CREATE TABLE %s AS SELECT 1 as val", tableName)); Optional table = metastore.getTable(SCHEMA, tableName); - assertTrue(table.isPresent(), "Table should exists"); + assertThat(table.isPresent()) + .describedAs("Table should exists") + .isTrue(); String location = table.get().getStorage().getLocation(); assertThat(location).matches(format(".*%s-[0-9a-f]{32}", tableName)); } @@ -65,14 +64,24 @@ public void testCreateAndDrop() Location tableLocation = Location.of(table.getStorage().getLocation()); TrinoFileSystem fileSystem = HDFS_FILE_SYSTEM_FACTORY.create(getSession().toConnectorSession()); - assertTrue(fileSystem.listFiles(tableLocation).hasNext(), "The directory corresponding to the table storage location should exist"); + assertThat(fileSystem.listFiles(tableLocation).hasNext()) + .describedAs("The directory corresponding to the table storage location should exist") + .isTrue(); List materializedRows = computeActual("SELECT \"$path\" FROM " + tableName).getMaterializedRows(); - assertEquals(materializedRows.size(), 1); + assertThat(materializedRows.size()).isEqualTo(1); Location filePath = Location.of((String) materializedRows.get(0).getField(0)); - assertTrue(fileSystem.listFiles(filePath).hasNext(), "The data file should exist"); + assertThat(fileSystem.listFiles(filePath).hasNext()) + .describedAs("The data file should exist") + .isTrue(); assertQuerySucceeds(format("DROP TABLE %s", tableName)); - assertFalse(metastore.getTable(SCHEMA, tableName).isPresent(), "Table should be dropped"); - assertFalse(fileSystem.listFiles(filePath).hasNext(), "The data file should have been removed"); - assertFalse(fileSystem.listFiles(tableLocation).hasNext(), "The directory corresponding to the dropped Delta Lake table should be removed"); + assertThat(metastore.getTable(SCHEMA, tableName).isPresent()) + .describedAs("Table should be dropped") + .isFalse(); + assertThat(fileSystem.listFiles(filePath).hasNext()) + .describedAs("The data file should have been removed") + .isFalse(); + assertThat(fileSystem.listFiles(tableLocation).hasNext()) + .describedAs("The directory corresponding to the dropped Delta Lake table should be removed") + .isFalse(); } } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/DeltaLakeQueryRunner.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/DeltaLakeQueryRunner.java index bcc59f61ac1f..552b30658d62 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/DeltaLakeQueryRunner.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/DeltaLakeQueryRunner.java @@ -44,7 +44,7 @@ import static io.trino.testing.containers.Minio.MINIO_SECRET_KEY; import static java.lang.String.format; import static java.util.Objects.requireNonNull; -import static org.testng.util.Strings.isNullOrEmpty; +import static org.assertj.core.util.Strings.isNullOrEmpty; public final class DeltaLakeQueryRunner { diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeBasic.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeBasic.java index 6ce5295fd046..283721d845b4 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeBasic.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeBasic.java @@ -82,7 +82,6 @@ import static org.assertj.core.api.Assertions.entry; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; -import static org.testng.Assert.assertFalse; @TestInstance(PER_CLASS) @Execution(SAME_THREAD) @@ -980,7 +979,7 @@ private void testCorruptedTableLocation(String tableName, Path tableLocation, bo // DROP TABLE should succeed so that users can remove their corrupted table getQueryRunner().execute("DROP TABLE " + tableName); - assertFalse(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); if (isManaged) { assertThat(tableLocation.toFile()).doesNotExist().as("Table location should not exist"); } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeConnectorTest.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeConnectorTest.java index c11a54b0fec6..5a18909846b4 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeConnectorTest.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeConnectorTest.java @@ -79,9 +79,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assumptions.abort; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; public class TestDeltaLakeConnectorTest extends BaseConnectorTest @@ -476,10 +473,10 @@ private void testDeltaRenameColumnWithComment(ColumnMappingMode mode) "column_mapping_mode = '" + mode + "')"); assertUpdate("ALTER TABLE " + tableName + " RENAME COLUMN col TO new_col"); - assertEquals(getColumnComment(tableName, "new_col"), "test column comment"); + assertThat(getColumnComment(tableName, "new_col")).isEqualTo("test column comment"); assertUpdate("ALTER TABLE " + tableName + " RENAME COLUMN part TO new_part"); - assertEquals(getColumnComment(tableName, "new_part"), "test partition comment"); + assertThat(getColumnComment(tableName, "new_part")).isEqualTo("test partition comment"); assertUpdate("DROP TABLE " + tableName); } @@ -538,12 +535,12 @@ private void testTimestampPredicatePushdown(String value) MaterializedResultWithQueryId queryResult = queryRunner.executeWithQueryId( getSession(), "SELECT * FROM " + tableName + " WHERE t < TIMESTAMP '" + value + "'"); - assertEquals(getQueryInfo(queryRunner, queryResult).getQueryStats().getProcessedInputDataSize().toBytes(), 0); + assertThat(getQueryInfo(queryRunner, queryResult).getQueryStats().getProcessedInputDataSize().toBytes()).isEqualTo(0); queryResult = queryRunner.executeWithQueryId( getSession(), "SELECT * FROM " + tableName + " WHERE t > TIMESTAMP '" + value + "'"); - assertEquals(getQueryInfo(queryRunner, queryResult).getQueryStats().getProcessedInputDataSize().toBytes(), 0); + assertThat(getQueryInfo(queryRunner, queryResult).getQueryStats().getProcessedInputDataSize().toBytes()).isEqualTo(0); assertQueryStats( getSession(), @@ -1110,12 +1107,12 @@ public void testUnsupportedCreateTableWithChangeDataFeed() assertQueryFails( "CREATE TABLE " + tableName + "(" + columnName + " int) WITH (change_data_feed_enabled = true)", "\\QUnable to use [%s] when change data feed is enabled\\E".formatted(columnName)); - assertFalse(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); assertQueryFails( "CREATE TABLE " + tableName + " WITH (change_data_feed_enabled = true) AS SELECT 1 AS " + columnName, "\\QUnable to use [%s] when change data feed is enabled\\E".formatted(columnName)); - assertFalse(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); } } @@ -1826,7 +1823,7 @@ public void testCreateTableUnsupportedColumnMappingMode() assertQueryFails("CREATE TABLE " + tableName + " WITH (column_mapping_mode = 'unknown') AS SELECT 1 a", ".* \\QInvalid value [unknown]. Valid values: [ID, NAME, NONE]"); - assertFalse(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); } @Test @@ -2661,13 +2658,17 @@ private void testDeleteWithFilter(String createTableSql, String deleteFilter, bo plan -> { if (pushDownDelete) { boolean tableDelete = searchFrom(plan.getRoot()).where(node -> node instanceof TableDeleteNode).matches(); - assertTrue(tableDelete, "A TableDeleteNode should be present"); + assertThat(tableDelete) + .describedAs("A TableDeleteNode should be present") + .isTrue(); } else { TableFinishNode finishNode = searchFrom(plan.getRoot()) .where(TableFinishNode.class::isInstance) .findOnlyElement(); - assertTrue(finishNode.getTarget() instanceof TableWriterNode.MergeTarget, "Delete operation should be performed through MERGE mechanism"); + assertThat(finishNode.getTarget() instanceof TableWriterNode.MergeTarget) + .describedAs("Delete operation should be performed through MERGE mechanism") + .isTrue(); } }); assertQuery("SELECT customer, purchases, address FROM " + table, "VALUES ('Mary', 10, 'Adelphi'), ('Aaron', 3, 'Dallas')"); diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeCreateTableStatistics.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeCreateTableStatistics.java index d9d705864826..53f7d815609d 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeCreateTableStatistics.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeCreateTableStatistics.java @@ -58,7 +58,6 @@ import static java.lang.Double.POSITIVE_INFINITY; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; @Isolated public class TestDeltaLakeCreateTableStatistics @@ -101,10 +100,10 @@ public void testComplexDataTypes() DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); DeltaLakeColumnHandle columnHandle = new DeltaLakeColumnHandle("d", createUnboundedVarcharType(), OptionalInt.empty(), "d", createUnboundedVarcharType(), REGULAR, Optional.empty()); - assertEquals(fileStatistics.getNumRecords(), Optional.of(2L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.of(utf8Slice("foo"))); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.of(utf8Slice("moo"))); - assertEquals(fileStatistics.getNullCount("d"), Optional.of(0L)); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(2L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.of(utf8Slice("foo"))); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.of(utf8Slice("moo"))); + assertThat(fileStatistics.getNullCount("d")).isEqualTo(Optional.of(0L)); for (String complexColumn : ImmutableList.of("a", "b", "c")) { columnHandle = new DeltaLakeColumnHandle(complexColumn, createUnboundedVarcharType(), OptionalInt.empty(), complexColumn, createUnboundedVarcharType(), REGULAR, Optional.empty()); @@ -128,10 +127,10 @@ public void testDoubleTypesNaN() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(2L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getNullCount(columnName), Optional.empty()); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(2L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.empty()); } } } @@ -152,10 +151,10 @@ public void testDoubleTypesInf() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(3L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.of(NEGATIVE_INFINITY)); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.of(POSITIVE_INFINITY)); - assertEquals(fileStatistics.getNullCount(columnName), Optional.of(0L)); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(3L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.of(NEGATIVE_INFINITY)); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.of(POSITIVE_INFINITY)); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.of(0L)); } } } @@ -176,10 +175,10 @@ public void testDoubleTypesInfAndNaN() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(4L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getNullCount(columnName), Optional.empty()); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(4L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.empty()); } } } @@ -200,10 +199,10 @@ public void testDoubleTypesNaNPositive() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(4L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getNullCount(columnName), Optional.empty()); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(4L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.empty()); } } } @@ -224,10 +223,10 @@ public void testDoubleTypesNaNNegative() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(4L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getNullCount(columnName), Optional.empty()); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(4L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.empty()); } } } @@ -271,7 +270,7 @@ private void testDecimal(int precision, int scale) assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(3L)); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(3L)); Optional expectedMin; Optional expectedMax; if (precision <= MAX_SHORT_PRECISION) { @@ -282,9 +281,9 @@ private void testDecimal(int precision, int scale) expectedMin = Optional.of(encodeScaledValue(new BigDecimal(negative), scale)); expectedMax = Optional.of(encodeScaledValue(new BigDecimal(high), scale)); } - assertEquals(fileStatistics.getMinColumnValue(columnHandle), expectedMin); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), expectedMax); - assertEquals(fileStatistics.getNullCount(columnName), Optional.of(0L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(expectedMin); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(expectedMax); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.of(0L)); } } @@ -300,10 +299,10 @@ public void testNullRecords() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(4L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.of(0.0)); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.of(1.0)); - assertEquals(fileStatistics.getNullCount(columnName), Optional.of(2L)); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(4L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.of(0.0)); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.of(1.0)); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.of(2L)); } } @@ -322,10 +321,10 @@ public void testOnlyNullRecords() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(4L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.empty()); - assertEquals(fileStatistics.getNullCount(columnName), Optional.of(4L)); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(4L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.of(4L)); } } @@ -344,10 +343,10 @@ public void testDateRecords() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(4L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.of(LocalDate.parse("2011-08-08").toEpochDay())); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.of(LocalDate.parse("2013-08-09").toEpochDay())); - assertEquals(fileStatistics.getNullCount(columnName), Optional.of(0L)); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(4L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.of(LocalDate.parse("2011-08-08").toEpochDay())); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.of(LocalDate.parse("2013-08-09").toEpochDay())); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.of(0L)); } } @@ -366,14 +365,10 @@ public void testTimestampMilliRecords() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(3L)); - assertEquals( - fileStatistics.getMinColumnValue(columnHandle), - Optional.of(packDateTimeWithZone(ZonedDateTime.parse("2012-10-31T01:00:00.123Z").toInstant().toEpochMilli(), UTC_KEY))); - assertEquals( - fileStatistics.getMaxColumnValue(columnHandle), - Optional.of(packDateTimeWithZone(ZonedDateTime.parse("2012-10-31T08:00:00.123Z").toInstant().toEpochMilli(), UTC_KEY))); - assertEquals(fileStatistics.getNullCount(columnName), Optional.of(0L)); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(3L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.of(packDateTimeWithZone(ZonedDateTime.parse("2012-10-31T01:00:00.123Z").toInstant().toEpochMilli(), UTC_KEY))); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.of(packDateTimeWithZone(ZonedDateTime.parse("2012-10-31T08:00:00.123Z").toInstant().toEpochMilli(), UTC_KEY))); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.of(0L)); } } @@ -389,10 +384,10 @@ public void testUnicodeValues() assertThat(entry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = entry.getStats().get(); - assertEquals(fileStatistics.getNumRecords(), Optional.of(2L)); - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.of(utf8Slice("ab\uFAD8"))); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.of(utf8Slice("ab\uD83D\uDD74"))); - assertEquals(fileStatistics.getNullCount(columnName), Optional.of(0L)); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(2L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.of(utf8Slice("ab\uFAD8"))); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.of(utf8Slice("ab\uD83D\uDD74"))); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.of(0L)); } } @@ -410,22 +405,22 @@ public void testPartitionedTable() ImmutableList.of(partitionColumn), "VALUES ('a', 1), ('b', 1), ('c', 1), ('c', 2), ('d', 2), ('e', 2), (null, 1)")) { List addFileEntries = getAddFileEntries(table.getName()); - assertEquals(addFileEntries.size(), 2); + assertThat(addFileEntries.size()).isEqualTo(2); for (AddFileEntry addFileEntry : addFileEntries) { assertThat(addFileEntry.getStats()).isPresent(); DeltaLakeFileStatistics fileStatistics = addFileEntry.getStats().get(); if (addFileEntry.getPartitionValues().get(partitionColumn).equals("1")) { - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.of(utf8Slice("a"))); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.of(utf8Slice("c"))); - assertEquals(fileStatistics.getNumRecords(), Optional.of(4L)); - assertEquals(fileStatistics.getNullCount(columnName), Optional.of(1L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.of(utf8Slice("a"))); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.of(utf8Slice("c"))); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(4L)); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.of(1L)); } else if (addFileEntry.getPartitionValues().get(partitionColumn).equals("2")) { - assertEquals(fileStatistics.getMinColumnValue(columnHandle), Optional.of(utf8Slice("c"))); - assertEquals(fileStatistics.getMaxColumnValue(columnHandle), Optional.of(utf8Slice("e"))); - assertEquals(fileStatistics.getNumRecords(), Optional.of(3L)); - assertEquals(fileStatistics.getNullCount(columnName), Optional.of(0L)); + assertThat(fileStatistics.getMinColumnValue(columnHandle)).isEqualTo(Optional.of(utf8Slice("c"))); + assertThat(fileStatistics.getMaxColumnValue(columnHandle)).isEqualTo(Optional.of(utf8Slice("e"))); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(3L)); + assertThat(fileStatistics.getNullCount(columnName)).isEqualTo(Optional.of(0L)); } } } @@ -448,10 +443,8 @@ public void testMultiFileTableWithNaNValue() List statistics = addFileEntries.stream().map(entry -> entry.getStats().get()).collect(toImmutableList()); - assertEquals(statistics.stream().filter(stat -> stat.getMinColumnValue(columnHandle).isEmpty() && stat.getMaxColumnValue(columnHandle).isEmpty()).count(), 1); - assertEquals( - statistics.stream().filter(stat -> stat.getMinColumnValue(columnHandle).isPresent() && stat.getMaxColumnValue(columnHandle).isPresent()).count(), - statistics.size() - 1); + assertThat(statistics.stream().filter(stat -> stat.getMinColumnValue(columnHandle).isEmpty() && stat.getMaxColumnValue(columnHandle).isEmpty()).count()).isEqualTo(1); + assertThat(statistics.stream().filter(stat -> stat.getMinColumnValue(columnHandle).isPresent() && stat.getMaxColumnValue(columnHandle).isPresent()).count()).isEqualTo(statistics.size() - 1); } } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeDynamicFiltering.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeDynamicFiltering.java index 9665cdb4cea4..d9a922743b60 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeDynamicFiltering.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeDynamicFiltering.java @@ -60,8 +60,7 @@ import static io.trino.tpch.TpchTable.LINE_ITEM; import static io.trino.tpch.TpchTable.ORDERS; import static java.lang.String.format; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; @Isolated public class TestDeltaLakeDynamicFiltering @@ -127,7 +126,7 @@ public void testIncompleteDynamicFilterTimeout() .beginTransactionId(transactionId, transactionManager, new AllowAllAccessControl()); QualifiedObjectName tableName = new QualifiedObjectName(DELTA_CATALOG, "default", "orders"); Optional tableHandle = runner.getMetadata().getTableHandle(session, tableName); - assertTrue(tableHandle.isPresent()); + assertThat(tableHandle.isPresent()).isTrue(); SplitSource splitSource = runner.getSplitManager() .getSplits(session, Span.getInvalid(), tableHandle.get(), new IncompleteDynamicFilter(), alwaysTrue()); List splits = new ArrayList<>(); @@ -135,7 +134,7 @@ public void testIncompleteDynamicFilterTimeout() splits.addAll(splitSource.getNextBatch(1000).get().getSplits()); } splitSource.close(); - assertFalse(splits.isEmpty()); + assertThat(splits.isEmpty()).isFalse(); } private Session sessionWithDynamicFiltering(boolean enabled, JoinDistributionType joinDistributionType) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakePageSink.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakePageSink.java index 1494aeb6552c..3a1b1b0cbf4b 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakePageSink.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakePageSink.java @@ -72,8 +72,7 @@ import static java.lang.Math.round; import static java.time.temporal.ChronoUnit.MINUTES; import static java.util.stream.Collectors.toList; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class TestDeltaLakePageSink { @@ -121,23 +120,23 @@ public void testPageSinkStats() .map(dataFileInfoCodec::fromJson) .collect(toImmutableList()); - assertEquals(dataFileInfos.size(), 1); + assertThat(dataFileInfos.size()).isEqualTo(1); DataFileInfo dataFileInfo = dataFileInfos.get(0); List files = ImmutableList.copyOf(new File(tablePath).listFiles((dir, name) -> !name.endsWith(".crc"))); - assertEquals(files.size(), 1); + assertThat(files.size()).isEqualTo(1); File outputFile = files.get(0); - assertEquals(round(stats.getInputPageSizeInBytes().getAllTime().getMax()), page.getRetainedSizeInBytes()); + assertThat(round(stats.getInputPageSizeInBytes().getAllTime().getMax())).isEqualTo(page.getRetainedSizeInBytes()); - assertEquals(dataFileInfo.getStatistics().getNumRecords(), Optional.of(rows)); - assertEquals(dataFileInfo.getPartitionValues(), ImmutableList.of()); - assertEquals(dataFileInfo.getSize(), outputFile.length()); - assertEquals(dataFileInfo.getPath(), outputFile.getName()); + assertThat(dataFileInfo.getStatistics().getNumRecords()).isEqualTo(Optional.of(rows)); + assertThat(dataFileInfo.getPartitionValues()).isEqualTo(ImmutableList.of()); + assertThat(dataFileInfo.getSize()).isEqualTo(outputFile.length()); + assertThat(dataFileInfo.getPath()).isEqualTo(outputFile.getName()); Instant now = Instant.now(); - assertTrue(dataFileInfo.getCreationTime() < now.toEpochMilli()); - assertTrue(dataFileInfo.getCreationTime() > now.minus(1, MINUTES).toEpochMilli()); + assertThat(dataFileInfo.getCreationTime() < now.toEpochMilli()).isTrue(); + assertThat(dataFileInfo.getCreationTime() > now.minus(1, MINUTES).toEpochMilli()).isTrue(); } finally { deleteRecursively(tempDir.toPath(), ALLOW_INSECURE); diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeParquetSchemas.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeParquetSchemas.java index bf671b7fdc2f..8e9fe1c031c5 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeParquetSchemas.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeParquetSchemas.java @@ -32,7 +32,7 @@ import static io.trino.spi.type.VarcharType.VARCHAR; import static org.apache.parquet.schema.Type.Repetition.OPTIONAL; import static org.apache.parquet.schema.Type.Repetition.REQUIRED; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestDeltaLakeParquetSchemas { @@ -350,7 +350,7 @@ private void assertParquetSchemaMappingCreationAccuracy( Map, Type> expectedPrimitiveTypes) { DeltaLakeParquetSchemaMapping parquetSchemaMapping = createParquetSchemaMapping(jsonSchema, typeManager, columnMappingMode, partitionColumnNames); - assertEquals(parquetSchemaMapping.messageType(), expectedMessageType); - assertEquals(parquetSchemaMapping.primitiveTypes(), expectedPrimitiveTypes); + assertThat(parquetSchemaMapping.messageType()).isEqualTo(expectedMessageType); + assertThat(parquetSchemaMapping.primitiveTypes()).isEqualTo(expectedPrimitiveTypes); } } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSplitManager.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSplitManager.java index ff5ea4be8ac6..dd165811ee88 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSplitManager.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeSplitManager.java @@ -62,7 +62,7 @@ import static io.trino.plugin.hive.HiveTestUtils.HDFS_ENVIRONMENT; import static io.trino.plugin.hive.HiveTestUtils.HDFS_FILE_SYSTEM_FACTORY; import static io.trino.plugin.hive.HiveTestUtils.HDFS_FILE_SYSTEM_STATS; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestDeltaLakeSplitManager { @@ -115,7 +115,7 @@ public void testInitialSplits() makeSplit(10_000, 5_000, fileSize, minimumAssignedSplitWeight), makeSplit(15_000, 5_000, fileSize, minimumAssignedSplitWeight)); - assertEquals(splits, expected); + assertThat(splits).isEqualTo(expected); } @Test @@ -142,7 +142,7 @@ public void testNonInitialSplits() makeSplit(25_000, 20_000, fileSize, minimumAssignedSplitWeight), makeSplit(45_000, 5_000, fileSize, minimumAssignedSplitWeight)); - assertEquals(splits, expected); + assertThat(splits).isEqualTo(expected); } @Test @@ -167,7 +167,7 @@ public void testSplitsFromMultipleFiles() makeSplit(2_000, 2_000, secondFileSize, minimumAssignedSplitWeight), makeSplit(4_000, 10_000, secondFileSize, minimumAssignedSplitWeight), makeSplit(14_000, 6_000, secondFileSize, minimumAssignedSplitWeight)); - assertEquals(splits, expected); + assertThat(splits).isEqualTo(expected); } private DeltaLakeSplitManager setupSplitManager(List addFileEntries, DeltaLakeConfig deltaLakeConfig) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeTableName.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeTableName.java index 9177046aedc6..2df36fb8a49a 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeTableName.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeTableName.java @@ -23,9 +23,6 @@ import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED; import static io.trino.testing.assertions.TrinoExceptionAssert.assertTrinoExceptionThrownBy; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; public class TestDeltaLakeTableName { @@ -47,32 +44,32 @@ public void testParse() @Test public void testIsDataTable() { - assertTrue(DeltaLakeTableName.isDataTable("abc")); + assertThat(DeltaLakeTableName.isDataTable("abc")).isTrue(); - assertFalse(DeltaLakeTableName.isDataTable("abc$data")); // it's invalid - assertFalse(DeltaLakeTableName.isDataTable("abc$history")); - assertFalse(DeltaLakeTableName.isDataTable("abc$invalid")); + assertThat(DeltaLakeTableName.isDataTable("abc$data")).isFalse(); // it's invalid + assertThat(DeltaLakeTableName.isDataTable("abc$history")).isFalse(); + assertThat(DeltaLakeTableName.isDataTable("abc$invalid")).isFalse(); } @Test public void testTableNameFrom() { - assertEquals(DeltaLakeTableName.tableNameFrom("abc"), "abc"); - assertEquals(DeltaLakeTableName.tableNameFrom("abc$data"), "abc"); - assertEquals(DeltaLakeTableName.tableNameFrom("abc$history"), "abc"); - assertEquals(DeltaLakeTableName.tableNameFrom("abc$properties"), "abc"); - assertEquals(DeltaLakeTableName.tableNameFrom("abc$invalid"), "abc"); + assertThat(DeltaLakeTableName.tableNameFrom("abc")).isEqualTo("abc"); + assertThat(DeltaLakeTableName.tableNameFrom("abc$data")).isEqualTo("abc"); + assertThat(DeltaLakeTableName.tableNameFrom("abc$history")).isEqualTo("abc"); + assertThat(DeltaLakeTableName.tableNameFrom("abc$properties")).isEqualTo("abc"); + assertThat(DeltaLakeTableName.tableNameFrom("abc$invalid")).isEqualTo("abc"); } @Test public void testTableTypeFrom() { - assertEquals(DeltaLakeTableName.tableTypeFrom("abc"), Optional.of(DATA)); - assertEquals(DeltaLakeTableName.tableTypeFrom("abc$data"), Optional.empty()); // it's invalid - assertEquals(DeltaLakeTableName.tableTypeFrom("abc$history"), Optional.of(HISTORY)); - assertEquals(DeltaLakeTableName.tableTypeFrom("abc$properties"), Optional.of(PROPERTIES)); + assertThat(DeltaLakeTableName.tableTypeFrom("abc")).isEqualTo(Optional.of(DATA)); + assertThat(DeltaLakeTableName.tableTypeFrom("abc$data")).isEqualTo(Optional.empty()); // it's invalid + assertThat(DeltaLakeTableName.tableTypeFrom("abc$history")).isEqualTo(Optional.of(HISTORY)); + assertThat(DeltaLakeTableName.tableTypeFrom("abc$properties")).isEqualTo(Optional.of(PROPERTIES)); - assertEquals(DeltaLakeTableName.tableTypeFrom("abc$invalid"), Optional.empty()); + assertThat(DeltaLakeTableName.tableTypeFrom("abc$invalid")).isEqualTo(Optional.empty()); } private static void assertNoValidTableType(String inputName) @@ -90,7 +87,7 @@ private static void assertInvalid(String inputName, String message) private static void assertParseNameAndType(String inputName, String tableName, DeltaLakeTableType tableType) { - assertEquals(DeltaLakeTableName.tableNameFrom(inputName), tableName); - assertEquals(DeltaLakeTableName.tableTypeFrom(inputName), Optional.of(tableType)); + assertThat(DeltaLakeTableName.tableNameFrom(inputName)).isEqualTo(tableName); + assertThat(DeltaLakeTableName.tableTypeFrom(inputName)).isEqualTo(Optional.of(tableType)); } } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeWriter.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeWriter.java index 1410ed80ad48..7665b2ec9287 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeWriter.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeWriter.java @@ -44,7 +44,7 @@ import static java.lang.Float.floatToRawIntBits; import static java.nio.ByteOrder.LITTLE_ENDIAN; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestDeltaLakeWriter { @@ -61,10 +61,10 @@ public void testMergeIntStatistics() DeltaLakeColumnHandle intColumn = new DeltaLakeColumnHandle(columnName, INTEGER, OptionalInt.empty(), columnName, INTEGER, REGULAR, Optional.empty()); DeltaLakeFileStatistics fileStats = mergeStats(buildMultimap(columnName, metadata), ImmutableMap.of(columnName, INTEGER), 20); - assertEquals(fileStats.getNumRecords(), Optional.of(20L)); - assertEquals(fileStats.getMinColumnValue(intColumn), Optional.of(-200L)); - assertEquals(fileStats.getMaxColumnValue(intColumn), Optional.of(250L)); - assertEquals(fileStats.getNullCount(columnName), Optional.of(13L)); + assertThat(fileStats.getNumRecords()).isEqualTo(Optional.of(20L)); + assertThat(fileStats.getMinColumnValue(intColumn)).isEqualTo(Optional.of(-200L)); + assertThat(fileStats.getMaxColumnValue(intColumn)).isEqualTo(Optional.of(250L)); + assertThat(fileStats.getNullCount(columnName)).isEqualTo(Optional.of(13L)); } @Test @@ -80,10 +80,10 @@ public void testMergeFloatStatistics() DeltaLakeColumnHandle floatColumn = new DeltaLakeColumnHandle(columnName, REAL, OptionalInt.empty(), columnName, REAL, REGULAR, Optional.empty()); DeltaLakeFileStatistics fileStats = mergeStats(buildMultimap(columnName, metadata), ImmutableMap.of(columnName, REAL), 20); - assertEquals(fileStats.getNumRecords(), Optional.of(20L)); - assertEquals(fileStats.getMinColumnValue(floatColumn), Optional.of((long) floatToRawIntBits(-2.001f))); - assertEquals(fileStats.getMaxColumnValue(floatColumn), Optional.of((long) floatToRawIntBits(1.0f))); - assertEquals(fileStats.getNullCount(columnName), Optional.of(13L)); + assertThat(fileStats.getNumRecords()).isEqualTo(Optional.of(20L)); + assertThat(fileStats.getMinColumnValue(floatColumn)).isEqualTo(Optional.of((long) floatToRawIntBits(-2.001f))); + assertThat(fileStats.getMaxColumnValue(floatColumn)).isEqualTo(Optional.of((long) floatToRawIntBits(1.0f))); + assertThat(fileStats.getNullCount(columnName)).isEqualTo(Optional.of(13L)); } @Test @@ -101,10 +101,10 @@ public void testMergeFloatNaNStatistics() DeltaLakeColumnHandle floatColumn = new DeltaLakeColumnHandle(columnName, REAL, OptionalInt.empty(), columnName, REAL, REGULAR, Optional.empty()); DeltaLakeFileStatistics fileStats = mergeStats(buildMultimap(columnName, metadata), ImmutableMap.of(columnName, REAL), 20); - assertEquals(fileStats.getNumRecords(), Optional.of(20L)); - assertEquals(fileStats.getMinColumnValue(floatColumn), Optional.empty()); - assertEquals(fileStats.getMaxColumnValue(floatColumn), Optional.empty()); - assertEquals(fileStats.getNullCount(columnName), Optional.empty()); + assertThat(fileStats.getNumRecords()).isEqualTo(Optional.of(20L)); + assertThat(fileStats.getMinColumnValue(floatColumn)).isEqualTo(Optional.empty()); + assertThat(fileStats.getMaxColumnValue(floatColumn)).isEqualTo(Optional.empty()); + assertThat(fileStats.getNullCount(columnName)).isEqualTo(Optional.empty()); } @Test @@ -122,10 +122,10 @@ public void testMergeDoubleNaNStatistics() DeltaLakeColumnHandle doubleColumn = new DeltaLakeColumnHandle(columnName, DOUBLE, OptionalInt.empty(), columnName, DOUBLE, REGULAR, Optional.empty()); DeltaLakeFileStatistics fileStats = mergeStats(buildMultimap(columnName, metadata), ImmutableMap.of(columnName, DOUBLE), 20); - assertEquals(fileStats.getNumRecords(), Optional.of(20L)); - assertEquals(fileStats.getMinColumnValue(doubleColumn), Optional.empty()); - assertEquals(fileStats.getMaxColumnValue(doubleColumn), Optional.empty()); - assertEquals(fileStats.getNullCount(columnName), Optional.empty()); + assertThat(fileStats.getNumRecords()).isEqualTo(Optional.of(20L)); + assertThat(fileStats.getMinColumnValue(doubleColumn)).isEqualTo(Optional.empty()); + assertThat(fileStats.getMaxColumnValue(doubleColumn)).isEqualTo(Optional.empty()); + assertThat(fileStats.getNullCount(columnName)).isEqualTo(Optional.empty()); } @Test @@ -141,10 +141,10 @@ public void testMergeStringStatistics() DeltaLakeColumnHandle varcharColumn = new DeltaLakeColumnHandle(columnName, VarcharType.createUnboundedVarcharType(), OptionalInt.empty(), columnName, VarcharType.createUnboundedVarcharType(), REGULAR, Optional.empty()); DeltaLakeFileStatistics fileStats = mergeStats(buildMultimap(columnName, metadata), ImmutableMap.of(columnName, createUnboundedVarcharType()), 20); - assertEquals(fileStats.getNumRecords(), Optional.of(20L)); - assertEquals(fileStats.getMinColumnValue(varcharColumn), Optional.of(utf8Slice("aba"))); - assertEquals(fileStats.getMaxColumnValue(varcharColumn), Optional.of(utf8Slice("ab⌘"))); - assertEquals(fileStats.getNullCount(columnName), Optional.of(12L)); + assertThat(fileStats.getNumRecords()).isEqualTo(Optional.of(20L)); + assertThat(fileStats.getMinColumnValue(varcharColumn)).isEqualTo(Optional.of(utf8Slice("aba"))); + assertThat(fileStats.getMaxColumnValue(varcharColumn)).isEqualTo(Optional.of(utf8Slice("ab⌘"))); + assertThat(fileStats.getNullCount(columnName)).isEqualTo(Optional.of(12L)); } @Test @@ -160,10 +160,10 @@ public void testMergeStringUnicodeStatistics() DeltaLakeColumnHandle varcharColumn = new DeltaLakeColumnHandle(columnName, VarcharType.createUnboundedVarcharType(), OptionalInt.empty(), columnName, VarcharType.createUnboundedVarcharType(), REGULAR, Optional.empty()); DeltaLakeFileStatistics fileStats = mergeStats(buildMultimap(columnName, metadata), ImmutableMap.of(columnName, createUnboundedVarcharType()), 20); - assertEquals(fileStats.getNumRecords(), Optional.of(20L)); - assertEquals(fileStats.getMinColumnValue(varcharColumn), Optional.of(utf8Slice("aba"))); - assertEquals(fileStats.getMaxColumnValue(varcharColumn), Optional.of(utf8Slice("ab\uD83D\uDD74"))); - assertEquals(fileStats.getNullCount(columnName), Optional.of(12L)); + assertThat(fileStats.getNumRecords()).isEqualTo(Optional.of(20L)); + assertThat(fileStats.getMinColumnValue(varcharColumn)).isEqualTo(Optional.of(utf8Slice("aba"))); + assertThat(fileStats.getMaxColumnValue(varcharColumn)).isEqualTo(Optional.of(utf8Slice("ab\uD83D\uDD74"))); + assertThat(fileStats.getNullCount(columnName)).isEqualTo(Optional.of(12L)); } private ColumnChunkMetaData createMetaData(String columnName, PrimitiveType columnType, long valueCount, Statistics statistics) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestPredicatePushdown.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestPredicatePushdown.java index 2ca8bcde9c93..ec95becbea82 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestPredicatePushdown.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestPredicatePushdown.java @@ -15,7 +15,6 @@ import com.google.common.collect.ContiguousSet; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Sets; import io.trino.plugin.hive.containers.HiveMinioDataLake; import io.trino.spi.QueryId; import io.trino.testing.AbstractTestQueryFramework; @@ -24,7 +23,6 @@ import io.trino.testing.MaterializedRow; import io.trino.testing.QueryRunner; import org.junit.jupiter.api.Test; -import org.testng.asserts.SoftAssert; import java.nio.file.Path; import java.util.OptionalLong; @@ -34,7 +32,7 @@ import static io.trino.plugin.deltalake.DeltaLakeQueryRunner.createS3DeltaLakeQueryRunner; import static io.trino.testing.TestingNames.randomNameSuffix; import static java.lang.String.format; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestPredicatePushdown extends AbstractTestQueryFramework @@ -97,9 +95,7 @@ public void testDeletePushdown() 200, 500); // Check that the correct data was deleted - assertEquals( - execute(format("SELECT custkey FROM %s", table)).getOnlyColumnAsSet(), - ContiguousSet.closed(1L, 1300L)); + assertThat(execute(format("SELECT custkey FROM %s", table)).getOnlyColumnAsSet()).isEqualTo(ContiguousSet.closed(1L, 1300L)); table = testTable.register("delete_pushdown_disjoint"); // 11 groups have data outside of (500, 1100] @@ -107,9 +103,7 @@ public void testDeletePushdown() format("DELETE FROM %s WHERE custkey <= 500 OR custkey > 1100", table), 900, 1100); - assertEquals( - execute(format("SELECT custkey FROM %s", table)).getOnlyColumnAsSet(), - ContiguousSet.closed(501L, 1100L)); + assertThat(execute(format("SELECT custkey FROM %s", table)).getOnlyColumnAsSet()).isEqualTo(ContiguousSet.closed(501L, 1100L)); } @Test @@ -150,24 +144,14 @@ private void assertPushdown(String actual, String expected, long countProcessed) Set expectedRows = Set.copyOf( computeExpected(expected, result.getResult().getTypes()).getMaterializedRows()); - SoftAssert softly = new SoftAssert(); - softly.assertTrue( - result.getResult().getUpdateType().isEmpty(), - "Query should not have update type"); - softly.assertEqualsNoOrder( - actualRows.toArray(), - expectedRows.toArray(), - format( - "Wrong query results:\n" - + "\t\tmissing rows: %s\n" - + "\t\textra rows: %s", - Sets.difference(expectedRows, actualRows), - Sets.difference(actualRows, expectedRows))); - softly.assertEquals( - getProcessedPositions(result.getQueryId()), - countProcessed, - "Wrong number of rows processed after pushdown to Parquet"); - softly.assertAll(); + assertThat(result.getResult().getUpdateType()) + .describedAs("Query should not have update type") + .isEmpty(); + + assertThat(actualRows).isEqualTo(expectedRows); + assertThat(getProcessedPositions(result.getQueryId())) + .describedAs("Wrong number of rows processed after pushdown to Parquet") + .isEqualTo(countProcessed); } /** @@ -182,14 +166,17 @@ private void assertPushdownUpdate(String sql, long count, long countProcessed) MaterializedResultWithQueryId result = executeWithQueryId(sql); OptionalLong actualCount = result.getResult().getUpdateCount(); - SoftAssert softly = new SoftAssert(); - softly.assertTrue(actualCount.isPresent(), "Missing update count"); - softly.assertEquals(actualCount.getAsLong(), count, "Wrong number of rows updated"); - softly.assertEquals( - getProcessedPositions(result.getQueryId()), - countProcessed, - "Wrong amount of data filtered by pushdown to Parquet"); - softly.assertAll(); + assertThat(actualCount) + .describedAs("Missing update count") + .isPresent(); + + assertThat(actualCount.getAsLong()) + .describedAs("Wrong number of rows updated") + .isEqualTo(count); + + assertThat(getProcessedPositions(result.getQueryId())) + .describedAs("Wrong amount of data filtered by pushdown to Parquet") + .isEqualTo(countProcessed); } private MaterializedResultWithQueryId executeWithQueryId(String sql) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestReadJsonTransactionLog.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestReadJsonTransactionLog.java index 3d87f04b4904..45f546e075eb 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestReadJsonTransactionLog.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestReadJsonTransactionLog.java @@ -35,7 +35,7 @@ import static com.google.common.base.Verify.verify; import static com.google.common.collect.ImmutableList.toImmutableList; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestReadJsonTransactionLog { @@ -44,49 +44,41 @@ public class TestReadJsonTransactionLog @Test public void testAdd() { - assertEquals( - readJsonTransactionLogs("databricks73/person/_delta_log") - .map(this::deserialize) - .map(DeltaLakeTransactionLogEntry::getAdd) - .filter(Objects::nonNull) - .map(AddFileEntry::getPath) - .filter(Objects::nonNull) - .count(), - 18); + assertThat(readJsonTransactionLogs("databricks73/person/_delta_log") + .map(this::deserialize) + .map(DeltaLakeTransactionLogEntry::getAdd) + .filter(Objects::nonNull) + .map(AddFileEntry::getPath) + .filter(Objects::nonNull) + .count()).isEqualTo(18); - assertEquals( - readJsonTransactionLogs("deltalake/person/_delta_log") - .map(this::deserialize) - .map(DeltaLakeTransactionLogEntry::getAdd) - .filter(Objects::nonNull) - .map(AddFileEntry::getPath) - .filter(Objects::nonNull) - .count(), - 18); + assertThat(readJsonTransactionLogs("deltalake/person/_delta_log") + .map(this::deserialize) + .map(DeltaLakeTransactionLogEntry::getAdd) + .filter(Objects::nonNull) + .map(AddFileEntry::getPath) + .filter(Objects::nonNull) + .count()).isEqualTo(18); } @Test public void testRemove() { - assertEquals( - readJsonTransactionLogs("databricks73/person/_delta_log") - .map(this::deserialize) - .map(DeltaLakeTransactionLogEntry::getRemove) - .filter(Objects::nonNull) - .map(RemoveFileEntry::getPath) - .filter(Objects::nonNull) - .count(), - 6); + assertThat(readJsonTransactionLogs("databricks73/person/_delta_log") + .map(this::deserialize) + .map(DeltaLakeTransactionLogEntry::getRemove) + .filter(Objects::nonNull) + .map(RemoveFileEntry::getPath) + .filter(Objects::nonNull) + .count()).isEqualTo(6); - assertEquals( - readJsonTransactionLogs("deltalake/person/_delta_log") - .map(this::deserialize) - .map(DeltaLakeTransactionLogEntry::getRemove) - .filter(Objects::nonNull) - .map(RemoveFileEntry::getPath) - .filter(Objects::nonNull) - .count(), - 6); + assertThat(readJsonTransactionLogs("deltalake/person/_delta_log") + .map(this::deserialize) + .map(DeltaLakeTransactionLogEntry::getRemove) + .filter(Objects::nonNull) + .map(RemoveFileEntry::getPath) + .filter(Objects::nonNull) + .count()).isEqualTo(6); } @Test @@ -94,9 +86,9 @@ public void testReadLastCheckpointFile() throws JsonProcessingException { LastCheckpoint lastCheckpoint = objectMapper.readValue("{\"version\":10,\"size\":17}", LastCheckpoint.class); - assertEquals(lastCheckpoint.getVersion(), 10L); - assertEquals(lastCheckpoint.getSize(), BigInteger.valueOf(17L)); - assertEquals(lastCheckpoint.getParts(), Optional.empty()); + assertThat(lastCheckpoint.getVersion()).isEqualTo(10L); + assertThat(lastCheckpoint.getSize()).isEqualTo(BigInteger.valueOf(17L)); + assertThat(lastCheckpoint.getParts()).isEqualTo(Optional.empty()); } @Test @@ -104,9 +96,9 @@ public void testReadLastCheckpointFileForMultipart() throws JsonProcessingException { LastCheckpoint lastCheckpoint = objectMapper.readValue("{\"version\":237580,\"size\":658573,\"parts\":2}", LastCheckpoint.class); - assertEquals(lastCheckpoint.getVersion(), 237580L); - assertEquals(lastCheckpoint.getSize(), BigInteger.valueOf(658573L)); - assertEquals(lastCheckpoint.getParts(), Optional.of(2)); + assertThat(lastCheckpoint.getVersion()).isEqualTo(237580L); + assertThat(lastCheckpoint.getSize()).isEqualTo(BigInteger.valueOf(658573L)); + assertThat(lastCheckpoint.getParts()).isEqualTo(Optional.of(2)); } private Stream readJsonTransactionLogs(String location) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestSplitPruning.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestSplitPruning.java index 5c23d74303f5..99ff36ebfa62 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestSplitPruning.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestSplitPruning.java @@ -37,7 +37,6 @@ import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.Assert.assertEquals; @TestInstance(PER_CLASS) public class TestSplitPruning @@ -139,7 +138,7 @@ public void testStatsPruningNaN() MaterializedResult result = getDistributedQueryRunner().execute( getSession(), format("SELECT name FROM %s WHERE val IS NOT NULL", tableName)); - assertEquals(result.getOnlyColumnAsSet(), Set.of("a5", "b5", "a6", "b6")); + assertThat(result.getOnlyColumnAsSet()).isEqualTo(Set.of("a5", "b5", "a6", "b6")); } } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestTransactionLogAccess.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestTransactionLogAccess.java index 281804f7bec3..4e2b46578e14 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestTransactionLogAccess.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestTransactionLogAccess.java @@ -82,9 +82,6 @@ import static java.util.stream.Collectors.toCollection; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; @Execution(SAME_THREAD) // e.g. TrackingFileSystemFactory is shared mutable state public class TestTransactionLogAccess @@ -171,16 +168,16 @@ public void testGetMetadataEntry() MetadataEntry metadataEntry = transactionLogAccess.getMetadataEntry(tableSnapshot, SESSION); - assertEquals(metadataEntry.getCreatedTime(), 1579190100722L); - assertEquals(metadataEntry.getId(), "b6aeffad-da73-4dde-b68e-937e468b1fdf"); + assertThat(metadataEntry.getCreatedTime()).isEqualTo(1579190100722L); + assertThat(metadataEntry.getId()).isEqualTo("b6aeffad-da73-4dde-b68e-937e468b1fdf"); assertThat(metadataEntry.getOriginalPartitionColumns()).containsOnly("age"); assertThat(metadataEntry.getLowercasePartitionColumns()).containsOnly("age"); MetadataEntry.Format format = metadataEntry.getFormat(); - assertEquals(format.getOptions().keySet().size(), 0); - assertEquals(format.getProvider(), "parquet"); + assertThat(format.getOptions().keySet().size()).isEqualTo(0); + assertThat(format.getProvider()).isEqualTo("parquet"); - assertEquals(tableSnapshot.getCachedMetadata(), Optional.of(metadataEntry)); + assertThat(tableSnapshot.getCachedMetadata()).isEqualTo(Optional.of(metadataEntry)); } @Test @@ -191,7 +188,7 @@ public void testGetMetadataEntryUppercase() MetadataEntry metadataEntry = transactionLogAccess.getMetadataEntry(tableSnapshot, SESSION); assertThat(metadataEntry.getOriginalPartitionColumns()).containsOnly("ALA"); assertThat(metadataEntry.getLowercasePartitionColumns()).containsOnly("ala"); - assertEquals(tableSnapshot.getCachedMetadata(), Optional.of(metadataEntry)); + assertThat(tableSnapshot.getCachedMetadata()).isEqualTo(Optional.of(metadataEntry)); } @Test @@ -207,7 +204,7 @@ public void testGetActiveAddEntries() .stream() .map(AddFileEntry::getPath) .collect(Collectors.toSet()); - assertEquals(paths, EXPECTED_ADD_FILE_PATHS); + assertThat(paths).isEqualTo(EXPECTED_ADD_FILE_PATHS); AddFileEntry addFileEntry = addFileEntries .stream() @@ -221,9 +218,9 @@ public void testGetActiveAddEntries() .hasSize(1) .containsEntry("age", Optional.of("42")); - assertEquals(addFileEntry.getSize(), 2687); - assertEquals(addFileEntry.getModificationTime(), 1579190188000L); - assertFalse(addFileEntry.isDataChange()); + assertThat(addFileEntry.getSize()).isEqualTo(2687); + assertThat(addFileEntry.getModificationTime()).isEqualTo(1579190188000L); + assertThat(addFileEntry.isDataChange()).isFalse(); } @Test @@ -264,8 +261,8 @@ public void testAddEntryPruning() .map(AddFileEntry::getPath) .collect(Collectors.toSet()); - assertFalse(paths.contains("age=25/part-00001-aceaf062-1cd1-45cb-8f83-277ffebe995c.c000.snappy.parquet")); - assertFalse(paths.contains("age=29/part-00000-3794c463-cb0c-4beb-8d07-7cc1e3b5920f.c000.snappy.parquet")); + assertThat(paths.contains("age=25/part-00001-aceaf062-1cd1-45cb-8f83-277ffebe995c.c000.snappy.parquet")).isFalse(); + assertThat(paths.contains("age=29/part-00000-3794c463-cb0c-4beb-8d07-7cc1e3b5920f.c000.snappy.parquet")).isFalse(); } @Test @@ -286,8 +283,8 @@ public void testAddEntryOverrides() List activeEntries = addFileEntries.stream() .filter(addFileEntry -> addFileEntry.getPath().equals(path)) .toList(); - assertEquals(activeEntries.size(), 1); - assertEquals(activeEntries.get(0).getModificationTime(), 9999999L); + assertThat(activeEntries.size()).isEqualTo(1); + assertThat(activeEntries.get(0).getModificationTime()).isEqualTo(9999999L); } } @@ -305,8 +302,8 @@ public void testAddRemoveAdd() .filter(addFileEntry -> addFileEntry.getPath().equals("age=30/part-00002-5800be2e-2373-47d8-8b86-776a8ea9d69f.c000.snappy.parquet")) .toList(); - assertEquals(activeEntries.size(), 1); - assertEquals(activeEntries.get(0).getModificationTime(), 9999999L); + assertThat(activeEntries.size()).isEqualTo(1); + assertThat(activeEntries.get(0).getModificationTime()).isEqualTo(9999999L); } @Test @@ -317,7 +314,7 @@ public void testGetRemoveEntries() try (Stream removeEntries = transactionLogAccess.getRemoveEntries(tableSnapshot, SESSION)) { Set removedEntries = removeEntries.collect(Collectors.toSet()); - assertEquals(removedEntries, EXPECTED_REMOVE_ENTRIES); + assertThat(removedEntries).isEqualTo(EXPECTED_REMOVE_ENTRIES); } } @@ -328,18 +325,16 @@ public void testGetCommitInfoEntries() setupTransactionLogAccessFromResources("person", "databricks73/person"); try (Stream commitInfoEntries = transactionLogAccess.getCommitInfoEntries(tableSnapshot, SESSION)) { Set entrySet = commitInfoEntries.collect(Collectors.toSet()); - assertEquals( - entrySet, - ImmutableSet.of( - new CommitInfoEntry(11, 1579190200860L, "671960514434781", "michal.slizak@starburstdata.com", "WRITE", - ImmutableMap.of("mode", "Append", "partitionBy", "[\"age\"]"), null, new CommitInfoEntry.Notebook("3040849856940931"), - "0116-154224-guppy476", 10L, "WriteSerializable", Optional.of(true)), - new CommitInfoEntry(12, 1579190206644L, "671960514434781", "michal.slizak@starburstdata.com", "WRITE", - ImmutableMap.of("mode", "Append", "partitionBy", "[\"age\"]"), null, new CommitInfoEntry.Notebook("3040849856940931"), - "0116-154224-guppy476", 11L, "WriteSerializable", Optional.of(true)), - new CommitInfoEntry(13, 1579190210571L, "671960514434781", "michal.slizak@starburstdata.com", "WRITE", - ImmutableMap.of("mode", "Append", "partitionBy", "[\"age\"]"), null, new CommitInfoEntry.Notebook("3040849856940931"), - "0116-154224-guppy476", 12L, "WriteSerializable", Optional.of(true)))); + assertThat(entrySet).isEqualTo(ImmutableSet.of( + new CommitInfoEntry(11, 1579190200860L, "671960514434781", "michal.slizak@starburstdata.com", "WRITE", + ImmutableMap.of("mode", "Append", "partitionBy", "[\"age\"]"), null, new CommitInfoEntry.Notebook("3040849856940931"), + "0116-154224-guppy476", 10L, "WriteSerializable", Optional.of(true)), + new CommitInfoEntry(12, 1579190206644L, "671960514434781", "michal.slizak@starburstdata.com", "WRITE", + ImmutableMap.of("mode", "Append", "partitionBy", "[\"age\"]"), null, new CommitInfoEntry.Notebook("3040849856940931"), + "0116-154224-guppy476", 11L, "WriteSerializable", Optional.of(true)), + new CommitInfoEntry(13, 1579190210571L, "671960514434781", "michal.slizak@starburstdata.com", "WRITE", + ImmutableMap.of("mode", "Append", "partitionBy", "[\"age\"]"), null, new CommitInfoEntry.Notebook("3040849856940931"), + "0116-154224-guppy476", 12L, "WriteSerializable", Optional.of(true)))); } } @@ -364,8 +359,8 @@ private void testAllGetMetadataEntry(String tableName, String resourcePath) assertThat(metadataEntry.getOriginalPartitionColumns()).containsOnly("age"); MetadataEntry.Format format = metadataEntry.getFormat(); - assertEquals(format.getOptions().keySet().size(), 0); - assertEquals(format.getProvider(), "parquet"); + assertThat(format.getOptions().keySet().size()).isEqualTo(0); + assertThat(format.getProvider()).isEqualTo("parquet"); } @Test @@ -390,7 +385,7 @@ private void testAllGetActiveAddEntries(String tableName, String resourcePath) .map(AddFileEntry::getPath) .collect(Collectors.toSet()); - assertEquals(paths, EXPECTED_ADD_FILE_PATHS); + assertThat(paths).isEqualTo(EXPECTED_ADD_FILE_PATHS); } @Test @@ -412,7 +407,7 @@ private void testAllGetRemoveEntries(String tableName, String resourcePath) Set removedPaths = removeEntries.map(RemoveFileEntry::getPath).collect(Collectors.toSet()); Set expectedPaths = EXPECTED_REMOVE_ENTRIES.stream().map(RemoveFileEntry::getPath).collect(Collectors.toSet()); - assertEquals(removedPaths, expectedPaths); + assertThat(removedPaths).isEqualTo(expectedPaths); } } @@ -433,9 +428,9 @@ private void testAllGetProtocolEntries(String tableName, String resourcePath) try (Stream protocolEntryStream = transactionLogAccess.getProtocolEntries(tableSnapshot, SESSION)) { List protocolEntries = protocolEntryStream.toList(); - assertEquals(protocolEntries.size(), 1); - assertEquals(protocolEntries.get(0).getMinReaderVersion(), 1); - assertEquals(protocolEntries.get(0).getMinWriterVersion(), 2); + assertThat(protocolEntries.size()).isEqualTo(1); + assertThat(protocolEntries.get(0).getMinReaderVersion()).isEqualTo(1); + assertThat(protocolEntries.get(0).getMinWriterVersion()).isEqualTo(2); } } @@ -458,12 +453,12 @@ public void testMetadataCacheUpdates() Files.copy(resourceDir.resolve(LAST_CHECKPOINT_FILENAME), new File(transactionLogDir, LAST_CHECKPOINT_FILENAME).toPath()); setupTransactionLogAccess(tableName, tableDir.toURI().toString()); - assertEquals(tableSnapshot.getVersion(), 11L); + assertThat(tableSnapshot.getVersion()).isEqualTo(11L); String lastTransactionName = format("%020d.json", 12); Files.copy(resourceDir.resolve(lastTransactionName), new File(transactionLogDir, lastTransactionName).toPath()); TableSnapshot updatedSnapshot = transactionLogAccess.loadSnapshot(SESSION, new SchemaTableName("schema", tableName), tableDir.toURI().toString()); - assertEquals(updatedSnapshot.getVersion(), 12); + assertThat(updatedSnapshot.getVersion()).isEqualTo(12); } @Test @@ -646,32 +641,32 @@ public void testSnapshotsAreConsistent() List allDataFiles = transactionLogAccess.getActiveFiles(updatedTableSnapshot, metadataEntry, protocolEntry, SESSION); List dataFilesWithFixedVersion = transactionLogAccess.getActiveFiles(tableSnapshot, metadataEntry, protocolEntry, SESSION); for (String newFilePath : newDataFiles) { - assertTrue(allDataFiles.stream().anyMatch(entry -> entry.getPath().equals(newFilePath))); - assertTrue(dataFilesWithFixedVersion.stream().noneMatch(entry -> entry.getPath().equals(newFilePath))); + assertThat(allDataFiles.stream().anyMatch(entry -> entry.getPath().equals(newFilePath))).isTrue(); + assertThat(dataFilesWithFixedVersion.stream().noneMatch(entry -> entry.getPath().equals(newFilePath))).isTrue(); } - assertEquals(expectedDataFiles.size(), dataFilesWithFixedVersion.size()); + assertThat(expectedDataFiles.size()).isEqualTo(dataFilesWithFixedVersion.size()); List columns = extractColumnMetadata(transactionLogAccess.getMetadataEntry(tableSnapshot, SESSION), transactionLogAccess.getProtocolEntry(SESSION, tableSnapshot), TESTING_TYPE_MANAGER); for (int i = 0; i < expectedDataFiles.size(); i++) { AddFileEntry expected = expectedDataFiles.get(i); AddFileEntry actual = dataFilesWithFixedVersion.get(i); - assertEquals(expected.getPath(), actual.getPath()); - assertEquals(expected.getPartitionValues(), actual.getPartitionValues()); - assertEquals(expected.getSize(), actual.getSize()); - assertEquals(expected.getModificationTime(), actual.getModificationTime()); - assertEquals(expected.isDataChange(), actual.isDataChange()); - assertEquals(expected.getTags(), actual.getTags()); + assertThat(expected.getPath()).isEqualTo(actual.getPath()); + assertThat(expected.getPartitionValues()).isEqualTo(actual.getPartitionValues()); + assertThat(expected.getSize()).isEqualTo(actual.getSize()); + assertThat(expected.getModificationTime()).isEqualTo(actual.getModificationTime()); + assertThat(expected.isDataChange()).isEqualTo(actual.isDataChange()); + assertThat(expected.getTags()).isEqualTo(actual.getTags()); - assertTrue(expected.getStats().isPresent()); - assertTrue(actual.getStats().isPresent()); + assertThat(expected.getStats().isPresent()).isTrue(); + assertThat(actual.getStats().isPresent()).isTrue(); for (ColumnMetadata column : columns) { DeltaLakeColumnHandle columnHandle = new DeltaLakeColumnHandle(column.getName(), column.getType(), OptionalInt.empty(), column.getName(), column.getType(), REGULAR, Optional.empty()); - assertEquals(expected.getStats().get().getMinColumnValue(columnHandle), actual.getStats().get().getMinColumnValue(columnHandle)); - assertEquals(expected.getStats().get().getMaxColumnValue(columnHandle), actual.getStats().get().getMaxColumnValue(columnHandle)); - assertEquals(expected.getStats().get().getNullCount(columnHandle.getBaseColumnName()), actual.getStats().get().getNullCount(columnHandle.getBaseColumnName())); - assertEquals(expected.getStats().get().getNumRecords(), actual.getStats().get().getNumRecords()); + assertThat(expected.getStats().get().getMinColumnValue(columnHandle)).isEqualTo(actual.getStats().get().getMinColumnValue(columnHandle)); + assertThat(expected.getStats().get().getMaxColumnValue(columnHandle)).isEqualTo(actual.getStats().get().getMaxColumnValue(columnHandle)); + assertThat(expected.getStats().get().getNullCount(columnHandle.getBaseColumnName())).isEqualTo(actual.getStats().get().getNullCount(columnHandle.getBaseColumnName())); + assertThat(expected.getStats().get().getNumRecords()).isEqualTo(actual.getStats().get().getNumRecords()); } } } @@ -693,15 +688,15 @@ public void testAddNewTransactionLogs() copyTransactionLogEntry(0, 1, resourceDir, transactionLogDir); setupTransactionLogAccess(tableName, tableLocation); - assertEquals(tableSnapshot.getVersion(), 0L); + assertThat(tableSnapshot.getVersion()).isEqualTo(0L); copyTransactionLogEntry(1, 2, resourceDir, transactionLogDir); TableSnapshot firstUpdate = transactionLogAccess.loadSnapshot(SESSION, schemaTableName, tableLocation); - assertEquals(firstUpdate.getVersion(), 1L); + assertThat(firstUpdate.getVersion()).isEqualTo(1L); copyTransactionLogEntry(2, 3, resourceDir, transactionLogDir); TableSnapshot secondUpdate = transactionLogAccess.loadSnapshot(SESSION, schemaTableName, tableLocation); - assertEquals(secondUpdate.getVersion(), 2L); + assertThat(secondUpdate.getVersion()).isEqualTo(2L); } @Test @@ -741,13 +736,9 @@ public void testParquetStructStatistics() for (String columnName : statsValues.keySet()) { // Types would need to be specified properly if stats were being read from JSON but are not can be ignored when reading parsed stats from parquet, // so it is safe to use INTEGER as a placeholder - assertEquals( - fileStats.getMinColumnValue(new DeltaLakeColumnHandle(columnName, IntegerType.INTEGER, OptionalInt.empty(), columnName, IntegerType.INTEGER, REGULAR, Optional.empty())), - Optional.of(statsValues.get(columnName))); + assertThat(fileStats.getMinColumnValue(new DeltaLakeColumnHandle(columnName, IntegerType.INTEGER, OptionalInt.empty(), columnName, IntegerType.INTEGER, REGULAR, Optional.empty()))).isEqualTo(Optional.of(statsValues.get(columnName))); - assertEquals( - fileStats.getMaxColumnValue(new DeltaLakeColumnHandle(columnName, IntegerType.INTEGER, OptionalInt.empty(), columnName, IntegerType.INTEGER, REGULAR, Optional.empty())), - Optional.of(statsValues.get(columnName))); + assertThat(fileStats.getMaxColumnValue(new DeltaLakeColumnHandle(columnName, IntegerType.INTEGER, OptionalInt.empty(), columnName, IntegerType.INTEGER, REGULAR, Optional.empty()))).isEqualTo(Optional.of(statsValues.get(columnName))); } } @@ -803,7 +794,7 @@ public void testTableSnapshotsActiveDataFilesCache() () -> { setupTransactionLogAccess(tableName, tableDir, shortLivedActiveDataFilesCacheConfig); List addFileEntries = transactionLogAccess.getActiveFiles(tableSnapshot, metadataEntry, protocolEntry, SESSION); - assertEquals(addFileEntries.size(), 12); + assertThat(addFileEntries.size()).isEqualTo(12); }, ImmutableMultiset.builder() .add(new FileOperation("_last_checkpoint", INPUT_FILE_NEW_STREAM)) @@ -819,7 +810,7 @@ public void testTableSnapshotsActiveDataFilesCache() assertFileSystemAccesses( () -> { List addFileEntries = transactionLogAccess.getActiveFiles(tableSnapshot, metadataEntry, protocolEntry, SESSION); - assertEquals(addFileEntries.size(), 12); + assertThat(addFileEntries.size()).isEqualTo(12); }, ImmutableMultiset.of()); } @@ -841,7 +832,7 @@ public void testFlushSnapshotAndActiveFileCache() () -> { setupTransactionLogAccess(tableName, tableDir, shortLivedActiveDataFilesCacheConfig); List addFileEntries = transactionLogAccess.getActiveFiles(tableSnapshot, metadataEntry, protocolEntry, SESSION); - assertEquals(addFileEntries.size(), 12); + assertThat(addFileEntries.size()).isEqualTo(12); }, ImmutableMultiset.builder() .add(new FileOperation("_last_checkpoint", INPUT_FILE_NEW_STREAM)) @@ -859,7 +850,7 @@ public void testFlushSnapshotAndActiveFileCache() () -> { transactionLogAccess.loadSnapshot(SESSION, new SchemaTableName("schema", tableName), tableDir); List addFileEntries = transactionLogAccess.getActiveFiles(tableSnapshot, metadataEntry, protocolEntry, SESSION); - assertEquals(addFileEntries.size(), 12); + assertThat(addFileEntries.size()).isEqualTo(12); }, ImmutableMultiset.builder() .add(new FileOperation("_last_checkpoint", INPUT_FILE_NEW_STREAM)) @@ -889,7 +880,7 @@ public void testTableSnapshotsActiveDataFilesCacheDisabled() () -> { setupTransactionLogAccess(tableName, tableDir, shortLivedActiveDataFilesCacheConfig); List addFileEntries = transactionLogAccess.getActiveFiles(tableSnapshot, metadataEntry, protocolEntry, SESSION); - assertEquals(addFileEntries.size(), 12); + assertThat(addFileEntries.size()).isEqualTo(12); }, ImmutableMultiset.builder() .add(new FileOperation("_last_checkpoint", INPUT_FILE_NEW_STREAM)) @@ -906,7 +897,7 @@ public void testTableSnapshotsActiveDataFilesCacheDisabled() assertFileSystemAccesses( () -> { List addFileEntries = transactionLogAccess.getActiveFiles(tableSnapshot, metadataEntry, protocolEntry, SESSION); - assertEquals(addFileEntries.size(), 12); + assertThat(addFileEntries.size()).isEqualTo(12); }, ImmutableMultiset.builder() .addCopies(new FileOperation("00000000000000000010.checkpoint.parquet", INPUT_FILE_GET_LENGTH), 2) // TODO (https://github.com/trinodb/trino/issues/16775) why not e.g. once? diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/expression/TestSparkExpressionParser.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/expression/TestSparkExpressionParser.java index 7e4299e6ab9a..54bf271892c7 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/expression/TestSparkExpressionParser.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/expression/TestSparkExpressionParser.java @@ -18,8 +18,8 @@ import org.junit.jupiter.api.Test; import static io.trino.plugin.deltalake.expression.SparkExpressionParser.createExpression; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.testng.Assert.assertEquals; public class TestSparkExpressionParser { @@ -55,12 +55,12 @@ public void testUnsupportedStringLiteral() @Test public void testArithmeticBinary() { - assertEquals(createExpression("a + b * c"), new ArithmeticBinaryExpression( + assertThat(createExpression("a + b * c")).isEqualTo(new ArithmeticBinaryExpression( Operator.ADD, new Identifier("a"), new ArithmeticBinaryExpression(Operator.MULTIPLY, new Identifier("b"), new Identifier("c")))); - assertEquals(createExpression("a * b + c"), new ArithmeticBinaryExpression( + assertThat(createExpression("a * b + c")).isEqualTo(new ArithmeticBinaryExpression( Operator.ADD, new ArithmeticBinaryExpression(Operator.MULTIPLY, new Identifier("a"), new Identifier("b")), new Identifier("c"))); @@ -69,7 +69,7 @@ public void testArithmeticBinary() private static void assertStringLiteral(String sparkExpression, String expected) { SparkExpression expression = createExpression(sparkExpression); - assertEquals(expression, new StringLiteral(expected)); + assertThat(expression).isEqualTo(new StringLiteral(expected)); } private static void assertParseFailure(String sparkExpression, String reason) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/expression/TestSparkExpressions.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/expression/TestSparkExpressions.java index acffab7a6512..7a5392f84f29 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/expression/TestSparkExpressions.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/expression/TestSparkExpressions.java @@ -16,8 +16,8 @@ import org.intellij.lang.annotations.Language; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.testng.Assert.assertEquals; public class TestSparkExpressions { @@ -208,7 +208,7 @@ public void testUnsupportedCallFunction() private static void assertExpressionTranslates(@Language("SQL") String sparkExpression, @Language("SQL") String trinoExpression) { - assertEquals(toTrinoExpression(sparkExpression), trinoExpression); + assertThat(toTrinoExpression(sparkExpression)).isEqualTo(trinoExpression); } private static String toTrinoExpression(@Language("SQL") String sparkExpression) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeConcurrentModificationGlueMetastore.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeConcurrentModificationGlueMetastore.java index 197be9b65088..9fb30ddd5957 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeConcurrentModificationGlueMetastore.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeConcurrentModificationGlueMetastore.java @@ -46,8 +46,8 @@ import static io.trino.plugin.hive.metastore.glue.TestingGlueHiveMetastore.createTestingAsyncGlueClient; import static io.trino.testing.TestingNames.randomNameSuffix; import static io.trino.testing.TestingSession.testSessionBuilder; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.Assert.assertFalse; @TestInstance(PER_CLASS) public class TestDeltaLakeConcurrentModificationGlueMetastore @@ -115,7 +115,7 @@ public void testDropTableWithConcurrentModifications() failNextGlueDeleteTableCall.set(true); assertUpdate("DROP TABLE " + tableName); - assertFalse(getQueryRunner().tableExists(getSession(), tableName)); + assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse(); } @AfterAll diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/statistics/TestDeltaLakeFileBasedTableStatisticsProvider.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/statistics/TestDeltaLakeFileBasedTableStatisticsProvider.java index 02aece4602b8..a2ca52ab4e67 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/statistics/TestDeltaLakeFileBasedTableStatisticsProvider.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/statistics/TestDeltaLakeFileBasedTableStatisticsProvider.java @@ -60,7 +60,6 @@ import static java.lang.Double.NEGATIVE_INFINITY; import static java.lang.Double.POSITIVE_INFINITY; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; public class TestDeltaLakeFileBasedTableStatisticsProvider { @@ -132,11 +131,11 @@ public void testStatisticsNaN() { DeltaLakeTableHandle tableHandle = registerTable("nan"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); - assertEquals(stats.getRowCount(), Estimate.of(1)); - assertEquals(stats.getColumnStatistics().size(), 1); + assertThat(stats.getRowCount()).isEqualTo(Estimate.of(1)); + assertThat(stats.getColumnStatistics().size()).isEqualTo(1); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange(), Optional.empty()); + assertThat(columnStatistics.getRange()).isEqualTo(Optional.empty()); } @Test @@ -145,8 +144,8 @@ public void testStatisticsInf() DeltaLakeTableHandle tableHandle = registerTable("positive_infinity"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), POSITIVE_INFINITY); - assertEquals(columnStatistics.getRange().get().getMax(), POSITIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(POSITIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(POSITIVE_INFINITY); } @Test @@ -155,8 +154,8 @@ public void testStatisticsNegInf() DeltaLakeTableHandle tableHandle = registerTable("negative_infinity"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), NEGATIVE_INFINITY); - assertEquals(columnStatistics.getRange().get().getMax(), NEGATIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(NEGATIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(NEGATIVE_INFINITY); } @Test @@ -165,8 +164,8 @@ public void testStatisticsNegZero() DeltaLakeTableHandle tableHandle = registerTable("negative_zero"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), -0.0d); - assertEquals(columnStatistics.getRange().get().getMax(), -0.0d); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(-0.0d); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(-0.0d); } @Test @@ -176,8 +175,8 @@ public void testStatisticsInfinityAndNaN() DeltaLakeTableHandle tableHandle = registerTable("infinity_nan"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), POSITIVE_INFINITY); - assertEquals(columnStatistics.getRange().get().getMax(), POSITIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(POSITIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(POSITIVE_INFINITY); } @Test @@ -187,8 +186,8 @@ public void testStatisticsNegativeInfinityAndNaN() DeltaLakeTableHandle tableHandle = registerTable("negative_infinity_nan"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), NEGATIVE_INFINITY); - assertEquals(columnStatistics.getRange().get().getMax(), POSITIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(NEGATIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(POSITIVE_INFINITY); } @Test @@ -198,8 +197,8 @@ public void testStatisticsZeroAndNaN() DeltaLakeTableHandle tableHandle = registerTable("zero_nan"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), 0.0); - assertEquals(columnStatistics.getRange().get().getMax(), POSITIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(0.0); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(POSITIVE_INFINITY); } @Test @@ -208,8 +207,8 @@ public void testStatisticsZeroAndInfinity() DeltaLakeTableHandle tableHandle = registerTable("zero_infinity"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), 0.0); - assertEquals(columnStatistics.getRange().get().getMax(), POSITIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(0.0); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(POSITIVE_INFINITY); } @Test @@ -218,8 +217,8 @@ public void testStatisticsZeroAndNegativeInfinity() DeltaLakeTableHandle tableHandle = registerTable("zero_negative_infinity"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), NEGATIVE_INFINITY); - assertEquals(columnStatistics.getRange().get().getMax(), 0.0); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(NEGATIVE_INFINITY); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(0.0); } @Test @@ -229,7 +228,7 @@ public void testStatisticsNaNWithMultipleFiles() DeltaLakeTableHandle tableHandle = registerTable("nan_multi_file"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange(), Optional.empty()); + assertThat(columnStatistics.getRange()).isEqualTo(Optional.empty()); } @Test @@ -238,8 +237,8 @@ public void testStatisticsMultipleFiles() DeltaLakeTableHandle tableHandle = registerTable("basic_multi_file"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), -42.0); - assertEquals(columnStatistics.getRange().get().getMax(), 42.0); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(-42.0); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(42.0); DeltaLakeTableHandle tableHandleWithUnenforcedConstraint = new DeltaLakeTableHandle( tableHandle.getSchemaName(), @@ -258,8 +257,8 @@ public void testStatisticsMultipleFiles() 0); stats = getTableStatistics(SESSION, tableHandleWithUnenforcedConstraint); columnStatistics = stats.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getRange().get().getMin(), 0.0); - assertEquals(columnStatistics.getRange().get().getMax(), 42.0); + assertThat(columnStatistics.getRange().get().getMin()).isEqualTo(0.0); + assertThat(columnStatistics.getRange().get().getMax()).isEqualTo(42.0); } @Test @@ -303,10 +302,10 @@ public void testStatisticsNoRecords() private void assertEmptyStats(TableStatistics tableStatistics) { - assertEquals(tableStatistics.getRowCount(), Estimate.of(0)); + assertThat(tableStatistics.getRowCount()).isEqualTo(Estimate.of(0)); ColumnStatistics columnStatistics = tableStatistics.getColumnStatistics().get(COLUMN_HANDLE); - assertEquals(columnStatistics.getNullsFraction(), Estimate.of(0)); - assertEquals(columnStatistics.getDistinctValuesCount(), Estimate.of(0)); + assertThat(columnStatistics.getNullsFraction()).isEqualTo(Estimate.of(0)); + assertThat(columnStatistics.getDistinctValuesCount()).isEqualTo(Estimate.of(0)); } @Test @@ -315,53 +314,53 @@ public void testStatisticsParquetParsedStatistics() // The transaction log for this table was created so that the checkpoints only write struct statistics, not json statistics DeltaLakeTableHandle tableHandle = registerTable("parquet_struct_statistics"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); - assertEquals(stats.getRowCount(), Estimate.of(9)); + assertThat(stats.getRowCount()).isEqualTo(Estimate.of(9)); Map statisticsMap = stats.getColumnStatistics(); ColumnStatistics columnStats = statisticsMap.get(new DeltaLakeColumnHandle("dec_short", DecimalType.createDecimalType(5, 1), OptionalInt.empty(), "dec_short", DecimalType.createDecimalType(5, 1), REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); - assertEquals(columnStats.getRange().get().getMin(), -10.1); - assertEquals(columnStats.getRange().get().getMax(), 10.1); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); + assertThat(columnStats.getRange().get().getMin()).isEqualTo(-10.1); + assertThat(columnStats.getRange().get().getMax()).isEqualTo(10.1); columnStats = statisticsMap.get(new DeltaLakeColumnHandle("dec_long", DecimalType.createDecimalType(25, 3), OptionalInt.empty(), "dec_long", DecimalType.createDecimalType(25, 3), REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); - assertEquals(columnStats.getRange().get().getMin(), -999999999999.123); - assertEquals(columnStats.getRange().get().getMax(), 999999999999.123); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); + assertThat(columnStats.getRange().get().getMin()).isEqualTo(-999999999999.123); + assertThat(columnStats.getRange().get().getMax()).isEqualTo(999999999999.123); columnStats = statisticsMap.get(new DeltaLakeColumnHandle("l", BIGINT, OptionalInt.empty(), "l", BIGINT, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); - assertEquals(columnStats.getRange().get().getMin(), -10000000.0); - assertEquals(columnStats.getRange().get().getMax(), 10000000.0); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); + assertThat(columnStats.getRange().get().getMin()).isEqualTo(-10000000.0); + assertThat(columnStats.getRange().get().getMax()).isEqualTo(10000000.0); columnStats = statisticsMap.get(new DeltaLakeColumnHandle("in", INTEGER, OptionalInt.empty(), "in", INTEGER, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); - assertEquals(columnStats.getRange().get().getMin(), -20000000.0); - assertEquals(columnStats.getRange().get().getMax(), 20000000.0); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); + assertThat(columnStats.getRange().get().getMin()).isEqualTo(-20000000.0); + assertThat(columnStats.getRange().get().getMax()).isEqualTo(20000000.0); columnStats = statisticsMap.get(new DeltaLakeColumnHandle("sh", SMALLINT, OptionalInt.empty(), "sh", SMALLINT, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); - assertEquals(columnStats.getRange().get().getMin(), -123.0); - assertEquals(columnStats.getRange().get().getMax(), 123.0); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); + assertThat(columnStats.getRange().get().getMin()).isEqualTo(-123.0); + assertThat(columnStats.getRange().get().getMax()).isEqualTo(123.0); columnStats = statisticsMap.get(new DeltaLakeColumnHandle("byt", TINYINT, OptionalInt.empty(), "byt", TINYINT, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); - assertEquals(columnStats.getRange().get().getMin(), -42.0); - assertEquals(columnStats.getRange().get().getMax(), 42.0); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); + assertThat(columnStats.getRange().get().getMin()).isEqualTo(-42.0); + assertThat(columnStats.getRange().get().getMax()).isEqualTo(42.0); columnStats = statisticsMap.get(new DeltaLakeColumnHandle("fl", REAL, OptionalInt.empty(), "fl", REAL, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); - assertEquals((float) columnStats.getRange().get().getMin(), -0.123f); - assertEquals((float) columnStats.getRange().get().getMax(), 0.123f); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); + assertThat((float) columnStats.getRange().get().getMin()).isEqualTo(-0.123f); + assertThat((float) columnStats.getRange().get().getMax()).isEqualTo(0.123f); columnStats = statisticsMap.get(new DeltaLakeColumnHandle("dou", DOUBLE, OptionalInt.empty(), "dou", DOUBLE, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); - assertEquals(columnStats.getRange().get().getMin(), -0.321); - assertEquals(columnStats.getRange().get().getMax(), 0.321); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); + assertThat(columnStats.getRange().get().getMin()).isEqualTo(-0.321); + assertThat(columnStats.getRange().get().getMax()).isEqualTo(0.321); columnStats = statisticsMap.get(new DeltaLakeColumnHandle("dat", DATE, OptionalInt.empty(), "dat", DATE, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); - assertEquals(columnStats.getRange().get().getMin(), (double) LocalDate.parse("1900-01-01").toEpochDay()); - assertEquals(columnStats.getRange().get().getMax(), (double) LocalDate.parse("5000-01-01").toEpochDay()); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); + assertThat(columnStats.getRange().get().getMin()).isEqualTo((double) LocalDate.parse("1900-01-01").toEpochDay()); + assertThat(columnStats.getRange().get().getMax()).isEqualTo((double) LocalDate.parse("5000-01-01").toEpochDay()); } @Test @@ -371,15 +370,15 @@ public void testStatisticsParquetParsedStatisticsNaNValues() // The table has a REAL and DOUBLE columns each with 9 values, one of them being NaN DeltaLakeTableHandle tableHandle = registerTable("parquet_struct_statistics_nan"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); - assertEquals(stats.getRowCount(), Estimate.of(9)); + assertThat(stats.getRowCount()).isEqualTo(Estimate.of(9)); Map statisticsMap = stats.getColumnStatistics(); ColumnStatistics columnStats = statisticsMap.get(new DeltaLakeColumnHandle("fl", REAL, OptionalInt.empty(), "fl", REAL, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); assertThat(columnStats.getRange()).isEmpty(); columnStats = statisticsMap.get(new DeltaLakeColumnHandle("dou", DOUBLE, OptionalInt.empty(), "dou", DOUBLE, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.zero()); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.zero()); assertThat(columnStats.getRange()).isEmpty(); } @@ -390,11 +389,11 @@ public void testStatisticsParquetParsedStatisticsNullCount() // The table has one INTEGER column 'i' where 3 of the 9 values are null DeltaLakeTableHandle tableHandle = registerTable("parquet_struct_statistics_null_count"); TableStatistics stats = getTableStatistics(SESSION, tableHandle); - assertEquals(stats.getRowCount(), Estimate.of(9)); + assertThat(stats.getRowCount()).isEqualTo(Estimate.of(9)); Map statisticsMap = stats.getColumnStatistics(); ColumnStatistics columnStats = statisticsMap.get(new DeltaLakeColumnHandle("i", INTEGER, OptionalInt.empty(), "i", INTEGER, REGULAR, Optional.empty())); - assertEquals(columnStats.getNullsFraction(), Estimate.of(3.0 / 9.0)); + assertThat(columnStats.getNullsFraction()).isEqualTo(Estimate.of(3.0 / 9.0)); } @Test @@ -415,9 +414,9 @@ public void testExtendedStatisticsWithDataSize() assertThat(extendedStatistics).isNotEmpty(); Map columnStatistics = extendedStatistics.get().getColumnStatistics(); assertThat(columnStatistics).hasSize(3); - assertEquals(columnStatistics.get("regionkey").getTotalSizeInBytes(), OptionalLong.empty()); - assertEquals(columnStatistics.get("name").getTotalSizeInBytes(), OptionalLong.of(34)); - assertEquals(columnStatistics.get("comment").getTotalSizeInBytes(), OptionalLong.of(330)); + assertThat(columnStatistics.get("regionkey").getTotalSizeInBytes()).isEqualTo(OptionalLong.empty()); + assertThat(columnStatistics.get("name").getTotalSizeInBytes()).isEqualTo(OptionalLong.of(34)); + assertThat(columnStatistics.get("comment").getTotalSizeInBytes()).isEqualTo(OptionalLong.of(330)); } @Test @@ -433,16 +432,16 @@ public void testMergeExtendedStatisticsWithoutAndWithDataSize() Map columnStatisticsWithDataSize = statisticsWithDataSize.get().getColumnStatistics(); DeltaLakeColumnStatistics mergedRegionKey = columnStatisticsWithoutDataSize.get("regionkey").update(columnStatisticsWithDataSize.get("regionkey")); - assertEquals(mergedRegionKey.getTotalSizeInBytes(), OptionalLong.empty()); - assertEquals(mergedRegionKey.getNdvSummary().cardinality(), 5); + assertThat(mergedRegionKey.getTotalSizeInBytes()).isEqualTo(OptionalLong.empty()); + assertThat(mergedRegionKey.getNdvSummary().cardinality()).isEqualTo(5); DeltaLakeColumnStatistics mergedName = columnStatisticsWithoutDataSize.get("name").update(columnStatisticsWithDataSize.get("name")); - assertEquals(mergedName.getTotalSizeInBytes(), OptionalLong.empty()); - assertEquals(mergedName.getNdvSummary().cardinality(), 5); + assertThat(mergedName.getTotalSizeInBytes()).isEqualTo(OptionalLong.empty()); + assertThat(mergedName.getNdvSummary().cardinality()).isEqualTo(5); DeltaLakeColumnStatistics mergedComment = columnStatisticsWithoutDataSize.get("comment").update(columnStatisticsWithDataSize.get("comment")); - assertEquals(mergedComment.getTotalSizeInBytes(), OptionalLong.empty()); - assertEquals(mergedComment.getNdvSummary().cardinality(), 5); + assertThat(mergedComment.getTotalSizeInBytes()).isEqualTo(OptionalLong.empty()); + assertThat(mergedComment.getNdvSummary().cardinality()).isEqualTo(5); } private TableStatistics getTableStatistics(ConnectorSession session, DeltaLakeTableHandle tableHandle) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestDeltaLakeParquetStatisticsUtils.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestDeltaLakeParquetStatisticsUtils.java index e4fa3b469d45..b88d427a1e82 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestDeltaLakeParquetStatisticsUtils.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestDeltaLakeParquetStatisticsUtils.java @@ -37,7 +37,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.time.ZoneOffset.UTC; import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestDeltaLakeParquetStatisticsUtils { @@ -53,12 +53,8 @@ public void testIntegerStatistics() .withNumNulls(10) .build(); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, IntegerType.INTEGER)), - ImmutableMap.of(columnName, -100)); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, IntegerType.INTEGER)), - ImmutableMap.of(columnName, 150)); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, IntegerType.INTEGER))).isEqualTo(ImmutableMap.of(columnName, -100)); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, IntegerType.INTEGER))).isEqualTo(ImmutableMap.of(columnName, 150)); } @Test @@ -72,12 +68,8 @@ public void testStringStatistics() .withNumNulls(1) .build(); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, createUnboundedVarcharType())), - ImmutableMap.of(columnName, "abc")); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, createUnboundedVarcharType())), - ImmutableMap.of(columnName, "bac")); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, createUnboundedVarcharType()))).isEqualTo(ImmutableMap.of(columnName, "abc")); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, createUnboundedVarcharType()))).isEqualTo(ImmutableMap.of(columnName, "bac")); } @Test @@ -91,12 +83,8 @@ public void testFloatStatistics() .withNumNulls(2) .build(); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, REAL)), - ImmutableMap.of(columnName, 100.0f)); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, REAL)), - ImmutableMap.of(columnName, 1000.001f)); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, REAL))).isEqualTo(ImmutableMap.of(columnName, 100.0f)); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, REAL))).isEqualTo(ImmutableMap.of(columnName, 1000.001f)); columnName = "t_double"; type = new PrimitiveType(Type.Repetition.REQUIRED, PrimitiveType.PrimitiveTypeName.DOUBLE, columnName); @@ -106,12 +94,8 @@ public void testFloatStatistics() .withNumNulls(2) .build(); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, DoubleType.DOUBLE)), - ImmutableMap.of(columnName, 100.0)); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, DoubleType.DOUBLE)), - ImmutableMap.of(columnName, 1000.001)); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, DoubleType.DOUBLE))).isEqualTo(ImmutableMap.of(columnName, 100.0)); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, DoubleType.DOUBLE))).isEqualTo(ImmutableMap.of(columnName, 1000.001)); } @Test @@ -125,12 +109,8 @@ public void testDateStatistics() .withNumNulls(2) .build(); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, DATE)), - ImmutableMap.of(columnName, "2020-08-26")); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, DATE)), - ImmutableMap.of(columnName, "2020-09-17")); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, DATE))).isEqualTo(ImmutableMap.of(columnName, "2020-08-26")); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, DATE))).isEqualTo(ImmutableMap.of(columnName, "2020-09-17")); } @Test @@ -144,12 +124,8 @@ public void testTimestampStatisticsHighPrecision() .withNumNulls(2) .build(); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, TIMESTAMP_TZ_MILLIS)), - ImmutableMap.of(columnName, "2020-08-26T01:02:03.123Z")); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, TIMESTAMP_TZ_MILLIS)), - ImmutableMap.of(columnName, "2020-08-26T01:02:03.124Z")); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, TIMESTAMP_TZ_MILLIS))).isEqualTo(ImmutableMap.of(columnName, "2020-08-26T01:02:03.123Z")); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, TIMESTAMP_TZ_MILLIS))).isEqualTo(ImmutableMap.of(columnName, "2020-08-26T01:02:03.124Z")); } @Test @@ -163,12 +139,8 @@ public void testTimestampStatisticsMillisPrecision() .withNumNulls(2) .build(); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, TIMESTAMP_TZ_MILLIS)), - ImmutableMap.of(columnName, "2020-08-26T01:02:03.123Z")); - assertEquals( - DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, TIMESTAMP_TZ_MILLIS)), - ImmutableMap.of(columnName, "2020-08-26T01:02:03.123Z")); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMin(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, TIMESTAMP_TZ_MILLIS))).isEqualTo(ImmutableMap.of(columnName, "2020-08-26T01:02:03.123Z")); + assertThat(DeltaLakeParquetStatisticsUtils.jsonEncodeMax(ImmutableMap.of(columnName, Optional.of(stats)), ImmutableMap.of(columnName, TIMESTAMP_TZ_MILLIS))).isEqualTo(ImmutableMap.of(columnName, "2020-08-26T01:02:03.123Z")); } private static byte[] toParquetEncoding(LocalDateTime time) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestDeltaLakeSchemaSupport.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestDeltaLakeSchemaSupport.java index f0924f859ed5..6c41a669b538 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestDeltaLakeSchemaSupport.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestDeltaLakeSchemaSupport.java @@ -68,7 +68,6 @@ import static io.trino.type.IntervalYearMonthType.INTERVAL_YEAR_MONTH; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; -import static org.testng.Assert.assertEquals; public class TestDeltaLakeSchemaSupport { @@ -114,8 +113,8 @@ private void testSinglePrimitiveFieldSchema(String json, ColumnMetadata metadata List schema = DeltaLakeSchemaSupport.getColumnMetadata(json, typeManager, ColumnMappingMode.NONE).stream() .map(DeltaLakeColumnMetadata::getColumnMetadata) .collect(toImmutableList()); - assertEquals(schema.size(), 1); - assertEquals(schema.get(0), metadata); + assertThat(schema.size()).isEqualTo(1); + assertThat(schema.get(0)).isEqualTo(metadata); } // |-- a: integer (nullable = false) @@ -144,26 +143,25 @@ public void testComplexSchema() List schema = DeltaLakeSchemaSupport.getColumnMetadata(json, typeManager, ColumnMappingMode.NONE).stream() .map(DeltaLakeColumnMetadata::getColumnMetadata) .collect(toImmutableList()); - assertEquals(schema.size(), 5); + assertThat(schema.size()).isEqualTo(5); // asserting on the string representations, since they're more readable - assertEquals(schema.get(0).toString(), "ColumnMetadata{name='a', type=integer, nullable}"); - assertEquals(schema.get(1).toString(), "ColumnMetadata{name='b', type=row(b1 integer, b2 row(b21 varchar, b22 boolean)), nullable}"); - assertEquals(schema.get(2).toString(), "ColumnMetadata{name='c', type=array(integer), nullable}"); - assertEquals(schema.get(3).toString(), "ColumnMetadata{name='d', type=array(row(d1 integer)), nullable}"); - assertEquals(schema.get(4).toString(), "ColumnMetadata{name='e', type=map(varchar, row(e1 date, e2 timestamp(3) with time zone)), nullable}"); + assertThat(schema.get(0).toString()).isEqualTo("ColumnMetadata{name='a', type=integer, nullable}"); + assertThat(schema.get(1).toString()).isEqualTo("ColumnMetadata{name='b', type=row(b1 integer, b2 row(b21 varchar, b22 boolean)), nullable}"); + assertThat(schema.get(2).toString()).isEqualTo("ColumnMetadata{name='c', type=array(integer), nullable}"); + assertThat(schema.get(3).toString()).isEqualTo("ColumnMetadata{name='d', type=array(row(d1 integer)), nullable}"); + assertThat(schema.get(4).toString()).isEqualTo("ColumnMetadata{name='e', type=map(varchar, row(e1 date, e2 timestamp(3) with time zone)), nullable}"); } @Test public void testSerializeStatisticsAsJson() throws JsonProcessingException { - assertEquals(serializeStatsAsJson( + assertThat(serializeStatsAsJson( new DeltaLakeJsonFileStatistics( Optional.of(100L), Optional.of(ImmutableMap.of("c", 42)), Optional.of(ImmutableMap.of("c", 51)), - Optional.of(ImmutableMap.of("c", 1L)))), - "{\"numRecords\":100,\"minValues\":{\"c\":42},\"maxValues\":{\"c\":51},\"nullCount\":{\"c\":1}}"); + Optional.of(ImmutableMap.of("c", 1L))))).isEqualTo("{\"numRecords\":100,\"minValues\":{\"c\":42},\"maxValues\":{\"c\":51},\"nullCount\":{\"c\":1}}"); } @Test @@ -179,13 +177,12 @@ public void testSerializeStatisticsWithNullValuesAsJson() minValues.put("c2", 10); maxValues.put("c2", 26); - assertEquals(serializeStatsAsJson( - new DeltaLakeJsonFileStatistics( - Optional.of(1L), - Optional.of(minValues), - Optional.of(maxValues), - Optional.of(ImmutableMap.of("c1", 1L, "c2", 0L)))), - "{\"numRecords\":1,\"minValues\":{\"c2\":10},\"maxValues\":{\"c2\":26},\"nullCount\":{\"c1\":1,\"c2\":0}}"); + assertThat(serializeStatsAsJson( + new DeltaLakeJsonFileStatistics( + Optional.of(1L), + Optional.of(minValues), + Optional.of(maxValues), + Optional.of(ImmutableMap.of("c1", 1L, "c2", 0L))))).isEqualTo("{\"numRecords\":1,\"minValues\":{\"c2\":10},\"maxValues\":{\"c2\":26},\"nullCount\":{\"c1\":1,\"c2\":0}}"); } @Test diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestProtocolEntry.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestProtocolEntry.java index b5f2c478ca3d..01a9d3788243 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestProtocolEntry.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestProtocolEntry.java @@ -20,8 +20,8 @@ import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.testng.Assert.assertEquals; public class TestProtocolEntry { @@ -32,15 +32,11 @@ public void testProtocolEntryFromJson() { @Language("JSON") String json = "{\"minReaderVersion\":2,\"minWriterVersion\":5}"; - assertEquals( - codec.fromJson(json), - new ProtocolEntry(2, 5, Optional.empty(), Optional.empty())); + assertThat(codec.fromJson(json)).isEqualTo(new ProtocolEntry(2, 5, Optional.empty(), Optional.empty())); @Language("JSON") String jsonWithFeatures = "{\"minReaderVersion\":3,\"minWriterVersion\":7,\"readerFeatures\":[\"deletionVectors\"],\"writerFeatures\":[\"timestampNTZ\"]}"; - assertEquals( - codec.fromJson(jsonWithFeatures), - new ProtocolEntry(3, 7, Optional.of(ImmutableSet.of("deletionVectors")), Optional.of(ImmutableSet.of("timestampNTZ")))); + assertThat(codec.fromJson(jsonWithFeatures)).isEqualTo(new ProtocolEntry(3, 7, Optional.of(ImmutableSet.of("deletionVectors")), Optional.of(ImmutableSet.of("timestampNTZ")))); } @Test @@ -62,22 +58,18 @@ public void testInvalidProtocolEntryFromJson() @Test public void testProtocolEntryToJson() { - assertEquals( - codec.toJson(new ProtocolEntry(2, 5, Optional.empty(), Optional.empty())), - """ - { - "minReaderVersion" : 2, - "minWriterVersion" : 5 - }"""); + assertThat(codec.toJson(new ProtocolEntry(2, 5, Optional.empty(), Optional.empty()))).isEqualTo(""" + { + "minReaderVersion" : 2, + "minWriterVersion" : 5 + }"""); - assertEquals( - codec.toJson(new ProtocolEntry(3, 7, Optional.of(ImmutableSet.of("deletionVectors")), Optional.of(ImmutableSet.of("timestampNTZ")))), - """ - { - "minReaderVersion" : 3, - "minWriterVersion" : 7, - "readerFeatures" : [ "deletionVectors" ], - "writerFeatures" : [ "timestampNTZ" ] - }"""); + assertThat(codec.toJson(new ProtocolEntry(3, 7, Optional.of(ImmutableSet.of("deletionVectors")), Optional.of(ImmutableSet.of("timestampNTZ"))))).isEqualTo(""" + { + "minReaderVersion" : 3, + "minWriterVersion" : 7, + "readerFeatures" : [ "deletionVectors" ], + "writerFeatures" : [ "timestampNTZ" ] + }"""); } } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestTableSnapshot.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestTableSnapshot.java index 3b6186fe7654..b7301d812581 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestTableSnapshot.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestTableSnapshot.java @@ -59,7 +59,6 @@ import static java.util.stream.Collectors.toCollection; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_METHOD; -import static org.testng.Assert.assertEquals; @TestInstance(PER_METHOD) // e.g. TrackingFileSystemFactory is shared mutable state public class TestTableSnapshot @@ -240,7 +239,7 @@ public void testMaxTransactionId() parquetReaderOptions, true, domainCompactionThreshold); - assertEquals(tableSnapshot.getVersion(), 13L); + assertThat(tableSnapshot.getVersion()).isEqualTo(13L); } private void assertFileSystemAccesses(ThrowingRunnable callback, Multiset expectedAccesses) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestTransactionLogParser.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestTransactionLogParser.java index 0e35b212be84..aba6dae2167e 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestTransactionLogParser.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/TestTransactionLogParser.java @@ -23,7 +23,7 @@ import static io.trino.plugin.deltalake.transactionlog.TransactionLogParser.getMandatoryCurrentVersion; import static io.trino.plugin.hive.HiveTestUtils.HDFS_ENVIRONMENT; import static io.trino.plugin.hive.HiveTestUtils.HDFS_FILE_SYSTEM_STATS; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestTransactionLogParser { @@ -35,8 +35,8 @@ public void testGetCurrentVersion() String basePath = getClass().getClassLoader().getResource("databricks73").toURI().toString(); - assertEquals(getMandatoryCurrentVersion(fileSystem, appendPath(basePath, "simple_table_without_checkpoint")), 9); - assertEquals(getMandatoryCurrentVersion(fileSystem, appendPath(basePath, "simple_table_ending_on_checkpoint")), 10); - assertEquals(getMandatoryCurrentVersion(fileSystem, appendPath(basePath, "simple_table_past_checkpoint")), 11); + assertThat(getMandatoryCurrentVersion(fileSystem, appendPath(basePath, "simple_table_without_checkpoint"))).isEqualTo(9); + assertThat(getMandatoryCurrentVersion(fileSystem, appendPath(basePath, "simple_table_ending_on_checkpoint"))).isEqualTo(10); + assertThat(getMandatoryCurrentVersion(fileSystem, appendPath(basePath, "simple_table_past_checkpoint"))).isEqualTo(11); } } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointBuilder.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointBuilder.java index 292b816be1a4..74bc61dcf8a6 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointBuilder.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointBuilder.java @@ -30,7 +30,7 @@ import static io.trino.plugin.deltalake.transactionlog.DeltaLakeTransactionLogEntry.protocolEntry; import static io.trino.plugin.deltalake.transactionlog.DeltaLakeTransactionLogEntry.removeFileEntry; import static io.trino.plugin.deltalake.transactionlog.DeltaLakeTransactionLogEntry.transactionEntry; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestCheckpointBuilder { @@ -77,6 +77,6 @@ public void testCheckpointBuilder() Set.of(app1TransactionV3, app2TransactionV5), Set.of(addA2), Set.of(removeB, removeC)); - assertEquals(expectedCheckpoint, builder.build()); + assertThat(expectedCheckpoint).isEqualTo(builder.build()); } } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointWriter.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointWriter.java index c17f72519d4e..c78b09b42304 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointWriter.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointWriter.java @@ -67,7 +67,6 @@ import static io.trino.type.InternalTypeManager.TESTING_TYPE_MANAGER; import static io.trino.util.DateTimeUtils.parseDate; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; public class TestCheckpointWriter { @@ -193,13 +192,11 @@ public void testCheckpointWriteReadJsonRoundtrip() writer.write(entries, createOutputFile(targetPath)); CheckpointEntries readEntries = readCheckpoint(targetPath, metadataEntry, protocolEntry, true); - assertEquals(readEntries.getTransactionEntries(), entries.getTransactionEntries()); - assertEquals(readEntries.getRemoveFileEntries(), entries.getRemoveFileEntries()); - assertEquals(readEntries.getMetadataEntry(), entries.getMetadataEntry()); - assertEquals(readEntries.getProtocolEntry(), entries.getProtocolEntry()); - assertEquals( - readEntries.getAddFileEntries().stream().map(this::makeComparable).collect(toImmutableSet()), - entries.getAddFileEntries().stream().map(this::makeComparable).collect(toImmutableSet())); + assertThat(readEntries.getTransactionEntries()).isEqualTo(entries.getTransactionEntries()); + assertThat(readEntries.getRemoveFileEntries()).isEqualTo(entries.getRemoveFileEntries()); + assertThat(readEntries.getMetadataEntry()).isEqualTo(entries.getMetadataEntry()); + assertThat(readEntries.getProtocolEntry()).isEqualTo(entries.getProtocolEntry()); + assertThat(readEntries.getAddFileEntries().stream().map(this::makeComparable).collect(toImmutableSet())).isEqualTo(entries.getAddFileEntries().stream().map(this::makeComparable).collect(toImmutableSet())); } @Test @@ -330,13 +327,11 @@ public void testCheckpointWriteReadParquetStatisticsRoundtrip() writer.write(entries, createOutputFile(targetPath)); CheckpointEntries readEntries = readCheckpoint(targetPath, metadataEntry, protocolEntry, true); - assertEquals(readEntries.getTransactionEntries(), entries.getTransactionEntries()); - assertEquals(readEntries.getRemoveFileEntries(), entries.getRemoveFileEntries()); - assertEquals(readEntries.getMetadataEntry(), entries.getMetadataEntry()); - assertEquals(readEntries.getProtocolEntry(), entries.getProtocolEntry()); - assertEquals( - readEntries.getAddFileEntries().stream().map(this::makeComparable).collect(toImmutableSet()), - entries.getAddFileEntries().stream().map(this::makeComparable).collect(toImmutableSet())); + assertThat(readEntries.getTransactionEntries()).isEqualTo(entries.getTransactionEntries()); + assertThat(readEntries.getRemoveFileEntries()).isEqualTo(entries.getRemoveFileEntries()); + assertThat(readEntries.getMetadataEntry()).isEqualTo(entries.getMetadataEntry()); + assertThat(readEntries.getProtocolEntry()).isEqualTo(entries.getProtocolEntry()); + assertThat(readEntries.getAddFileEntries().stream().map(this::makeComparable).collect(toImmutableSet())).isEqualTo(entries.getAddFileEntries().stream().map(this::makeComparable).collect(toImmutableSet())); } @Test diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestTransactionLogTail.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestTransactionLogTail.java index 7d005a9928b8..37407458abd2 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestTransactionLogTail.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestTransactionLogTail.java @@ -25,8 +25,7 @@ import static io.trino.plugin.hive.HiveTestUtils.HDFS_ENVIRONMENT; import static io.trino.plugin.hive.HiveTestUtils.HDFS_FILE_SYSTEM_STATS; import static java.lang.String.format; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; public class TestTransactionLogTail { @@ -42,8 +41,8 @@ private void testTail(String dataSource) throws Exception { String tableLocation = getClass().getClassLoader().getResource(format("%s/person", dataSource)).toURI().toString(); - assertEquals(readJsonTransactionLogTails(tableLocation).size(), 7); - assertEquals(updateJsonTransactionLogTails(tableLocation).size(), 7); + assertThat(readJsonTransactionLogTails(tableLocation).size()).isEqualTo(7); + assertThat(updateJsonTransactionLogTails(tableLocation).size()).isEqualTo(7); } private List updateJsonTransactionLogTails(String tableLocation) @@ -52,7 +51,7 @@ private List updateJsonTransactionLogTails(String TrinoFileSystem fileSystem = new HdfsFileSystemFactory(HDFS_ENVIRONMENT, HDFS_FILE_SYSTEM_STATS).create(SESSION); TransactionLogTail transactionLogTail = TransactionLogTail.loadNewTail(fileSystem, tableLocation, Optional.of(10L), Optional.of(12L)); Optional updatedLogTail = transactionLogTail.getUpdatedTail(fileSystem, tableLocation, Optional.empty()); - assertTrue(updatedLogTail.isPresent()); + assertThat(updatedLogTail.isPresent()).isTrue(); return updatedLogTail.get().getFileEntries(); } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/statistics/TestDeltaLakeFileStatistics.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/statistics/TestDeltaLakeFileStatistics.java index 9145e2d112c9..7d38c1271e53 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/statistics/TestDeltaLakeFileStatistics.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/transactionlog/statistics/TestDeltaLakeFileStatistics.java @@ -67,9 +67,6 @@ import static java.lang.Float.floatToIntBits; import static java.time.ZoneOffset.UTC; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; public class TestDeltaLakeFileStatistics { @@ -141,66 +138,34 @@ public void testParseParquetStatistics() while (checkpointEntryIterator.hasNext()) { DeltaLakeTransactionLogEntry entry = checkpointEntryIterator.next(); if (entry.getAdd() != null && entry.getAdd().getPath().contains("part-00000-17951bea-0d04-43c1-979c-ea1fac19b382-c000.snappy.parquet")) { - assertNull(matchingAddFileEntry); + assertThat(matchingAddFileEntry).isNull(); matchingAddFileEntry = entry; } } - assertNotNull(matchingAddFileEntry); + assertThat(matchingAddFileEntry).isNotNull(); assertThat(matchingAddFileEntry.getAdd().getStats()).isPresent(); testStatisticsValues(matchingAddFileEntry.getAdd().getStats().get()); } private static void testStatisticsValues(DeltaLakeFileStatistics fileStatistics) { - assertEquals(fileStatistics.getNumRecords(), Optional.of(1L)); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("byt", TINYINT, OptionalInt.empty(), "byt", TINYINT, REGULAR, Optional.empty())), - Optional.of(42L)); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("dat", DATE, OptionalInt.empty(), "dat", DATE, REGULAR, Optional.empty())), - Optional.of(LocalDate.parse("5000-01-01").toEpochDay())); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("dec_long", DecimalType.createDecimalType(25, 3), OptionalInt.empty(), "dec_long", DecimalType.createDecimalType(25, 3), REGULAR, Optional.empty())), - Optional.of(encodeScaledValue(new BigDecimal("999999999999.123"), 3))); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("dec_short", DecimalType.createDecimalType(5, 1), OptionalInt.empty(), "dec_short", DecimalType.createDecimalType(5, 1), REGULAR, Optional.empty())), - Optional.of(new BigDecimal("10.1").unscaledValue().longValueExact())); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("dou", DoubleType.DOUBLE, OptionalInt.empty(), "dou", DoubleType.DOUBLE, REGULAR, Optional.empty())), - Optional.of(0.321)); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("fl", REAL, OptionalInt.empty(), "fl", REAL, REGULAR, Optional.empty())), - Optional.of((long) floatToIntBits(0.123f))); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("in", INTEGER, OptionalInt.empty(), "in", INTEGER, REGULAR, Optional.empty())), - Optional.of(20000000L)); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("l", BIGINT, OptionalInt.empty(), "l", BIGINT, REGULAR, Optional.empty())), - Optional.of(10000000L)); + assertThat(fileStatistics.getNumRecords()).isEqualTo(Optional.of(1L)); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("byt", TINYINT, OptionalInt.empty(), "byt", TINYINT, REGULAR, Optional.empty()))).isEqualTo(Optional.of(42L)); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("dat", DATE, OptionalInt.empty(), "dat", DATE, REGULAR, Optional.empty()))).isEqualTo(Optional.of(LocalDate.parse("5000-01-01").toEpochDay())); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("dec_long", DecimalType.createDecimalType(25, 3), OptionalInt.empty(), "dec_long", DecimalType.createDecimalType(25, 3), REGULAR, Optional.empty()))).isEqualTo(Optional.of(encodeScaledValue(new BigDecimal("999999999999.123"), 3))); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("dec_short", DecimalType.createDecimalType(5, 1), OptionalInt.empty(), "dec_short", DecimalType.createDecimalType(5, 1), REGULAR, Optional.empty()))).isEqualTo(Optional.of(new BigDecimal("10.1").unscaledValue().longValueExact())); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("dou", DoubleType.DOUBLE, OptionalInt.empty(), "dou", DoubleType.DOUBLE, REGULAR, Optional.empty()))).isEqualTo(Optional.of(0.321)); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("fl", REAL, OptionalInt.empty(), "fl", REAL, REGULAR, Optional.empty()))).isEqualTo(Optional.of((long) floatToIntBits(0.123f))); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("in", INTEGER, OptionalInt.empty(), "in", INTEGER, REGULAR, Optional.empty()))).isEqualTo(Optional.of(20000000L)); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("l", BIGINT, OptionalInt.empty(), "l", BIGINT, REGULAR, Optional.empty()))).isEqualTo(Optional.of(10000000L)); Type rowType = RowType.rowType(RowType.field("s1", INTEGER), RowType.field("s3", VarcharType.createUnboundedVarcharType())); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("row", rowType, OptionalInt.empty(), "row", rowType, REGULAR, Optional.empty())), - Optional.empty()); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("arr", new ArrayType(INTEGER), OptionalInt.empty(), "arr", new ArrayType(INTEGER), REGULAR, Optional.empty())), - Optional.empty()); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("m", new MapType(INTEGER, VarcharType.createUnboundedVarcharType(), new TypeOperators()), OptionalInt.empty(), "m", new MapType(INTEGER, VarcharType.createUnboundedVarcharType(), new TypeOperators()), REGULAR, Optional.empty())), - Optional.empty()); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("sh", SMALLINT, OptionalInt.empty(), "sh", SMALLINT, REGULAR, Optional.empty())), - Optional.of(123L)); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("str", VarcharType.createUnboundedVarcharType(), OptionalInt.empty(), "str", VarcharType.createUnboundedVarcharType(), REGULAR, Optional.empty())), - Optional.of(utf8Slice("a"))); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("ts", TIMESTAMP_TZ_MILLIS, OptionalInt.empty(), "ts", TIMESTAMP_TZ_MILLIS, REGULAR, Optional.empty())), - Optional.of(packDateTimeWithZone(LocalDateTime.parse("2960-10-31T01:00:00.000").toInstant(UTC).toEpochMilli(), UTC_KEY))); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("bool", BOOLEAN, OptionalInt.empty(), "bool", BOOLEAN, REGULAR, Optional.empty())), - Optional.empty()); - assertEquals( - fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("bin", VARBINARY, OptionalInt.empty(), "bin", VARBINARY, REGULAR, Optional.empty())), - Optional.empty()); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("row", rowType, OptionalInt.empty(), "row", rowType, REGULAR, Optional.empty()))).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("arr", new ArrayType(INTEGER), OptionalInt.empty(), "arr", new ArrayType(INTEGER), REGULAR, Optional.empty()))).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("m", new MapType(INTEGER, VarcharType.createUnboundedVarcharType(), new TypeOperators()), OptionalInt.empty(), "m", new MapType(INTEGER, VarcharType.createUnboundedVarcharType(), new TypeOperators()), REGULAR, Optional.empty()))).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("sh", SMALLINT, OptionalInt.empty(), "sh", SMALLINT, REGULAR, Optional.empty()))).isEqualTo(Optional.of(123L)); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("str", VarcharType.createUnboundedVarcharType(), OptionalInt.empty(), "str", VarcharType.createUnboundedVarcharType(), REGULAR, Optional.empty()))).isEqualTo(Optional.of(utf8Slice("a"))); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("ts", TIMESTAMP_TZ_MILLIS, OptionalInt.empty(), "ts", TIMESTAMP_TZ_MILLIS, REGULAR, Optional.empty()))).isEqualTo(Optional.of(packDateTimeWithZone(LocalDateTime.parse("2960-10-31T01:00:00.000").toInstant(UTC).toEpochMilli(), UTC_KEY))); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("bool", BOOLEAN, OptionalInt.empty(), "bool", BOOLEAN, REGULAR, Optional.empty()))).isEqualTo(Optional.empty()); + assertThat(fileStatistics.getMinColumnValue(new DeltaLakeColumnHandle("bin", VARBINARY, OptionalInt.empty(), "bin", VARBINARY, REGULAR, Optional.empty()))).isEqualTo(Optional.empty()); } } diff --git a/plugin/trino-druid/pom.xml b/plugin/trino-druid/pom.xml index c85fe5d7d2e6..b9256f5ae8d1 100644 --- a/plugin/trino-druid/pom.xml +++ b/plugin/trino-druid/pom.xml @@ -229,33 +229,5 @@ - - - org.testng - testng - test - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/plugin/trino-druid/src/test/java/io/trino/plugin/druid/TestDruidConnectorTest.java b/plugin/trino-druid/src/test/java/io/trino/plugin/druid/TestDruidConnectorTest.java index 94fce7df9394..8c9cfe4df1ee 100644 --- a/plugin/trino-druid/src/test/java/io/trino/plugin/druid/TestDruidConnectorTest.java +++ b/plugin/trino-druid/src/test/java/io/trino/plugin/druid/TestDruidConnectorTest.java @@ -58,7 +58,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assumptions.abort; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.Assert.assertFalse; @TestInstance(PER_CLASS) public class TestDruidConnectorTest @@ -336,10 +335,10 @@ public void testNativeQuerySelectFromTestTable() public void testNativeQueryCreateStatement() { // override because Druid fails to prepare statement, while other connectors succeed in preparing statement and then fail because of no metadata available - assertFalse(getQueryRunner().tableExists(getSession(), "numbers")); + assertThat(getQueryRunner().tableExists(getSession(), "numbers")).isFalse(); assertThatThrownBy(() -> query("SELECT * FROM TABLE(system.query(query => 'CREATE TABLE numbers(n INTEGER)'))")) .hasMessageContaining("Failed to get table handle for prepared query"); - assertFalse(getQueryRunner().tableExists(getSession(), "numbers")); + assertThat(getQueryRunner().tableExists(getSession(), "numbers")).isFalse(); } @Test diff --git a/plugin/trino-elasticsearch/pom.xml b/plugin/trino-elasticsearch/pom.xml index 7fb5d81fb87b..667fd0e799af 100644 --- a/plugin/trino-elasticsearch/pom.xml +++ b/plugin/trino-elasticsearch/pom.xml @@ -401,12 +401,6 @@ testcontainers test - - - org.testng - testng - test - @@ -439,25 +433,5 @@ - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java index 521c4e04fb8a..a9700e9fa1cb 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/BaseElasticsearchConnectorTest.java @@ -52,9 +52,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; @TestInstance(PER_CLASS) public abstract class BaseElasticsearchConnectorTest @@ -638,7 +635,7 @@ public void testAsRawJson() .row(null, null, "\"Check out the bi-weekly Trino Community Broadcast https://trino.io/broadcast/\"", null, null, null, "5309") .build(); - assertEquals(rows.getMaterializedRows(), expected.getMaterializedRows()); + assertThat(rows.getMaterializedRows()).isEqualTo(expected.getMaterializedRows()); MaterializedResult nestedRows = computeActual("" + "SELECT " + @@ -657,7 +654,7 @@ public void testAsRawJson() .row(null, null, "\"Join the Trino Slack: https://trino.io/slack.html\"", null, null, null, "867") .build(); - assertEquals(nestedRows.getMaterializedRows(), nestedExpected.getMaterializedRows()); + assertThat(nestedRows.getMaterializedRows()).isEqualTo(nestedExpected.getMaterializedRows()); MaterializedResult arrayRows = computeActual("" + "SELECT " + @@ -676,7 +673,7 @@ public void testAsRawJson() .row(null, null, "\"If you like Presto, you'll love Trino: https://trino.io/slack.html\"", null, null, null, "321") .build(); - assertEquals(arrayRows.getMaterializedRows(), arrayExpected.getMaterializedRows()); + assertThat(arrayRows.getMaterializedRows()).isEqualTo(arrayExpected.getMaterializedRows()); MaterializedResult rawRows = computeActual("" + "SELECT " + @@ -695,7 +692,7 @@ public void testAsRawJson() .row(null, null, "\"The founders and core contributors of Presto, and are now working on Trino: https://trino.io/blog/2020/12/27/announcing-trino.html\"", null, null, null, "654") .build(); - assertEquals(rawRows.getMaterializedRows(), rawRowsExpected.getMaterializedRows()); + assertThat(rawRows.getMaterializedRows()).isEqualTo(rawRowsExpected.getMaterializedRows()); } @Test @@ -799,7 +796,7 @@ public void testAsRawJsonForAllPrimitiveTypes() assertThat(rows.getTypes()) .hasOnlyElementsOfType(VarcharType.class); - assertEquals(rows.getMaterializedRows(), expected.getMaterializedRows()); + assertThat(rows.getMaterializedRows()).isEqualTo(expected.getMaterializedRows()); deleteIndex(indexName); } @@ -858,7 +855,7 @@ public void testAsRawJsonCases() .row("\"dGVzdA==\"", "true", "123") .build(); - assertEquals(rows.getMaterializedRows(), expected.getMaterializedRows()); + assertThat(rows.getMaterializedRows()).isEqualTo(expected.getMaterializedRows()); assertThat(rows.getTypes()) .hasOnlyElementsOfType(VarcharType.class); @@ -1208,7 +1205,7 @@ public void testDataTypes() 123456.78d) .build(); - assertEquals(rows.getMaterializedRows(), expected.getMaterializedRows()); + assertThat(rows.getMaterializedRows()).isEqualTo(expected.getMaterializedRows()); } @Test @@ -1238,7 +1235,7 @@ public void testTableWithUnsupportedTypes() .row(1L) .build(); - assertEquals(rows.getMaterializedRows(), expected.getMaterializedRows()); + assertThat(rows.getMaterializedRows()).isEqualTo(expected.getMaterializedRows()); } @Test @@ -1428,7 +1425,7 @@ public void testCoercions() .row(1.0f, 1.0d, 1, 1L) .build(); - assertEquals(rows.getMaterializedRows(), expected.getMaterializedRows()); + assertThat(rows.getMaterializedRows()).isEqualTo(expected.getMaterializedRows()); } @Test @@ -1624,7 +1621,7 @@ public void testDataTypesNested() LocalDateTime.of(1970, 1, 1, 0, 0), "1.2.3.4", "2001:db8::1:0:0:1") .build(); - assertEquals(rows.getMaterializedRows(), expected.getMaterializedRows()); + assertThat(rows.getMaterializedRows()).isEqualTo(expected.getMaterializedRows()); } @Test @@ -1694,7 +1691,7 @@ public void testNestedTypeDataTypesNested() LocalDateTime.of(1970, 1, 1, 0, 0), "1.2.3.4", "2001:db8::1:0:0:1") .build(); - assertEquals(rows.getMaterializedRows(), expected.getMaterializedRows()); + assertThat(rows.getMaterializedRows()).isEqualTo(expected.getMaterializedRows()); } @Test @@ -1806,7 +1803,7 @@ public void testEmptyIndexWithMappings() createIndex(indexName, mappings); assertQuery(format("SELECT column_name FROM information_schema.columns WHERE table_name = '%s'", indexName), "VALUES ('dummy_column')"); - assertTrue(computeActual("SHOW TABLES").getOnlyColumnAsSet().contains(indexName)); + assertThat(computeActual("SHOW TABLES").getOnlyColumnAsSet().contains(indexName)).isTrue(); assertQueryReturnsEmptyResult("SELECT * FROM " + indexName); } @@ -1909,7 +1906,7 @@ public void testQueryTableFunction() protected void assertTableDoesNotExist(String name) { assertQueryReturnsEmptyResult(format("SELECT * FROM information_schema.columns WHERE table_name = '%s'", name)); - assertFalse(computeActual("SHOW TABLES").getOnlyColumnAsSet().contains(name)); + assertThat(computeActual("SHOW TABLES").getOnlyColumnAsSet().contains(name)).isFalse(); assertQueryFails("SELECT * FROM " + name, ".*Table '" + catalogName + ".tpch." + name + "' does not exist"); } diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchBackpressure.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchBackpressure.java index 9412bdebe66d..dbaf93176066 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchBackpressure.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchBackpressure.java @@ -17,7 +17,6 @@ import com.google.common.collect.ImmutableMap; import io.trino.testing.AbstractTestQueryFramework; import io.trino.testing.QueryRunner; -import io.trino.testng.services.ManageTestResources.Suppress; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; @@ -35,11 +34,8 @@ public class TestElasticsearchBackpressure { private static final String image = "elasticsearch:7.0.0"; - @Suppress(because = "Not a TestNG test class") private Network network; - @Suppress(because = "Not a TestNG test class") private ElasticsearchServer elasticsearch; - @Suppress(because = "Not a TestNG test class") private ElasticsearchNginxProxy elasticsearchNginxProxy; @Override diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchMetadata.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchMetadata.java index 9ab47e1d93d6..f1f7c17cf9ac 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchMetadata.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchMetadata.java @@ -18,26 +18,26 @@ import java.util.Optional; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestElasticsearchMetadata { @Test public void testLikeToRegexp() { - assertEquals(likeToRegexp("a_b_c", Optional.empty()), "a.b.c"); - assertEquals(likeToRegexp("a%b%c", Optional.empty()), "a.*b.*c"); - assertEquals(likeToRegexp("a%b_c", Optional.empty()), "a.*b.c"); - assertEquals(likeToRegexp("a[b", Optional.empty()), "a\\[b"); - assertEquals(likeToRegexp("a_\\_b", Optional.of("\\")), "a._b"); - assertEquals(likeToRegexp("a$_b", Optional.of("$")), "a_b"); - assertEquals(likeToRegexp("s_.m%ex\\t", Optional.of("$")), "s.\\.m.*ex\\\\t"); - assertEquals(likeToRegexp("\000%", Optional.empty()), "\000.*"); - assertEquals(likeToRegexp("\000%", Optional.of("\000")), "%"); - assertEquals(likeToRegexp("中文%", Optional.empty()), "中文.*"); - assertEquals(likeToRegexp("こんにちは%", Optional.empty()), "こんにちは.*"); - assertEquals(likeToRegexp("안녕하세요%", Optional.empty()), "안녕하세요.*"); - assertEquals(likeToRegexp("Привет%", Optional.empty()), "Привет.*"); + assertThat(likeToRegexp("a_b_c", Optional.empty())).isEqualTo("a.b.c"); + assertThat(likeToRegexp("a%b%c", Optional.empty())).isEqualTo("a.*b.*c"); + assertThat(likeToRegexp("a%b_c", Optional.empty())).isEqualTo("a.*b.c"); + assertThat(likeToRegexp("a[b", Optional.empty())).isEqualTo("a\\[b"); + assertThat(likeToRegexp("a_\\_b", Optional.of("\\"))).isEqualTo("a._b"); + assertThat(likeToRegexp("a$_b", Optional.of("$"))).isEqualTo("a_b"); + assertThat(likeToRegexp("s_.m%ex\\t", Optional.of("$"))).isEqualTo("s.\\.m.*ex\\\\t"); + assertThat(likeToRegexp("\000%", Optional.empty())).isEqualTo("\000.*"); + assertThat(likeToRegexp("\000%", Optional.of("\000"))).isEqualTo("%"); + assertThat(likeToRegexp("中文%", Optional.empty())).isEqualTo("中文.*"); + assertThat(likeToRegexp("こんにちは%", Optional.empty())).isEqualTo("こんにちは.*"); + assertThat(likeToRegexp("안녕하세요%", Optional.empty())).isEqualTo("안녕하세요.*"); + assertThat(likeToRegexp("Привет%", Optional.empty())).isEqualTo("Привет.*"); } private static String likeToRegexp(String pattern, Optional escapeChar) diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchQueryBuilder.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchQueryBuilder.java index a6d660033572..f040188b5f12 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchQueryBuilder.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/TestElasticsearchQueryBuilder.java @@ -37,7 +37,7 @@ import static io.trino.spi.type.DoubleType.DOUBLE; import static io.trino.spi.type.IntegerType.INTEGER; import static io.trino.spi.type.VarcharType.VARCHAR; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestElasticsearchQueryBuilder { @@ -133,6 +133,6 @@ public void testMultiConstraint() private static void assertQueryBuilder(Map domains, QueryBuilder expected) { QueryBuilder actual = buildSearchQuery(TupleDomain.withColumnDomains(domains), Optional.empty(), Map.of()); - assertEquals(actual, expected); + assertThat(actual).isEqualTo(expected); } } diff --git a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/client/TestExtractAddress.java b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/client/TestExtractAddress.java index fc8213bf8070..34a982f53f16 100644 --- a/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/client/TestExtractAddress.java +++ b/plugin/trino-elasticsearch/src/test/java/io/trino/plugin/elasticsearch/client/TestExtractAddress.java @@ -18,22 +18,22 @@ import java.util.Optional; import static io.trino.plugin.elasticsearch.client.ElasticsearchClient.extractAddress; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestExtractAddress { @Test public void test() { - assertEquals(extractAddress("node/1.2.3.4:9200"), Optional.of("node:9200")); - assertEquals(extractAddress("1.2.3.4:9200"), Optional.of("1.2.3.4:9200")); - assertEquals(extractAddress("node/1.2.3.4:9200"), Optional.of("node:9200")); - assertEquals(extractAddress("node/[fe80::1]:9200"), Optional.of("node:9200")); - assertEquals(extractAddress("[fe80::1]:9200"), Optional.of("[fe80::1]:9200")); + assertThat(extractAddress("node/1.2.3.4:9200")).isEqualTo(Optional.of("node:9200")); + assertThat(extractAddress("1.2.3.4:9200")).isEqualTo(Optional.of("1.2.3.4:9200")); + assertThat(extractAddress("node/1.2.3.4:9200")).isEqualTo(Optional.of("node:9200")); + assertThat(extractAddress("node/[fe80::1]:9200")).isEqualTo(Optional.of("node:9200")); + assertThat(extractAddress("[fe80::1]:9200")).isEqualTo(Optional.of("[fe80::1]:9200")); - assertEquals(extractAddress(""), Optional.empty()); - assertEquals(extractAddress("node/1.2.3.4"), Optional.empty()); - assertEquals(extractAddress("node/1.2.3.4:xxxx"), Optional.empty()); - assertEquals(extractAddress("1.2.3.4:xxxx"), Optional.empty()); + assertThat(extractAddress("")).isEqualTo(Optional.empty()); + assertThat(extractAddress("node/1.2.3.4")).isEqualTo(Optional.empty()); + assertThat(extractAddress("node/1.2.3.4:xxxx")).isEqualTo(Optional.empty()); + assertThat(extractAddress("1.2.3.4:xxxx")).isEqualTo(Optional.empty()); } } diff --git a/plugin/trino-hive-hadoop2/pom.xml b/plugin/trino-hive-hadoop2/pom.xml index 02a3f5437a36..1069cda0c04a 100644 --- a/plugin/trino-hive-hadoop2/pom.xml +++ b/plugin/trino-hive-hadoop2/pom.xml @@ -217,28 +217,6 @@ - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - - default diff --git a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHive.java b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHive.java index c4568db9be42..2ae7c145603d 100644 --- a/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHive.java +++ b/plugin/trino-hive-hadoop2/src/test/java/io/trino/plugin/hive/TestHive.java @@ -48,14 +48,6 @@ public void initialize() setup(HostAndPort.fromString(metastore), database); } - @Test - public void forceTestNgToRespectSingleThreaded() - { - // TODO: Remove after updating TestNG to 7.4.0+ (https://github.com/trinodb/trino/issues/8571) - // TestNG doesn't enforce @Test(singleThreaded = true) when tests are defined in base class. According to - // https://github.com/cbeust/testng/issues/2361#issuecomment-688393166 a workaround it to add a dummy test to the leaf test class. - } - @Test @Override public void testHideDeltaLakeTables() diff --git a/plugin/trino-hudi/pom.xml b/plugin/trino-hudi/pom.xml index 81f18cd509dd..377ddb7edd5b 100644 --- a/plugin/trino-hudi/pom.xml +++ b/plugin/trino-hudi/pom.xml @@ -337,33 +337,10 @@ junit-jupiter-engine test - - - org.testng - testng - test - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - org.basepom.maven duplicate-finder-maven-plugin diff --git a/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiPartitionManager.java b/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiPartitionManager.java index a998d8a311b5..41a4c566d978 100644 --- a/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiPartitionManager.java +++ b/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiPartitionManager.java @@ -34,7 +34,7 @@ import static io.trino.plugin.hive.metastore.StorageFormat.fromHiveStorageFormat; import static io.trino.plugin.hive.util.HiveBucketing.BucketingVersion.BUCKETING_V1; import static io.trino.plugin.hudi.model.HudiTableType.COPY_ON_WRITE; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestHudiPartitionManager { @@ -82,6 +82,6 @@ public void testParseValuesAndFilterPartition() List actualPartitions = hudiPartitionManager.getEffectivePartitions( tableHandle, metastore); - assertEquals(actualPartitions, PARTITIONS); + assertThat(actualPartitions).isEqualTo(PARTITIONS); } } diff --git a/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiSessionProperties.java b/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiSessionProperties.java index 62d039c763e7..d36fb8085225 100644 --- a/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiSessionProperties.java +++ b/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiSessionProperties.java @@ -19,10 +19,8 @@ import io.trino.testing.TestingConnectorSession; import org.junit.jupiter.api.Test; -import java.util.List; - import static io.trino.plugin.hudi.HudiSessionProperties.getColumnsToHide; -import static org.testng.Assert.assertEqualsNoOrder; +import static org.assertj.core.api.Assertions.assertThat; public class TestHudiSessionProperties { @@ -35,8 +33,7 @@ public void testSessionPropertyColumnsToHide() ConnectorSession session = TestingConnectorSession.builder() .setPropertyMetadata(sessionProperties.getSessionProperties()) .build(); - List expectedColumnsToHide = ImmutableList.of("col1", "col2"); - List actualColumnsToHide = getColumnsToHide(session); - assertEqualsNoOrder(expectedColumnsToHide.toArray(), actualColumnsToHide.toArray()); + assertThat(getColumnsToHide(session)) + .containsExactlyInAnyOrderElementsOf(ImmutableList.of("col1", "col2")); } } diff --git a/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiSmokeTest.java b/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiSmokeTest.java index 37c53555268d..71a687134880 100644 --- a/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiSmokeTest.java +++ b/plugin/trino-hudi/src/test/java/io/trino/plugin/hudi/TestHudiSmokeTest.java @@ -29,7 +29,6 @@ import static io.trino.plugin.hudi.testing.ResourceHudiTablesInitializer.TestingTable.STOCK_TICKS_COW; import static io.trino.plugin.hudi.testing.ResourceHudiTablesInitializer.TestingTable.STOCK_TICKS_MOR; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; public class TestHudiSmokeTest extends AbstractTestQueryFramework @@ -144,7 +143,7 @@ public void testFileSizeColumn() { String path = (String) computeScalar("SELECT \"$path\" FROM " + HUDI_COW_PT_TBL + " WHERE id = 1"); long fileSize = (long) computeScalar("SELECT \"$file_size\" FROM " + HUDI_COW_PT_TBL + " WHERE id = 1"); - assertEquals(fileSize, Files.size(toPath(path))); + assertThat(fileSize).isEqualTo(Files.size(toPath(path))); } @Test @@ -153,7 +152,8 @@ public void testFileModifiedColumn() { String path = (String) computeScalar("SELECT \"$path\" FROM " + HUDI_COW_PT_TBL + " WHERE id = 1"); ZonedDateTime fileModifiedTime = (ZonedDateTime) computeScalar("SELECT \"$file_modified_time\" FROM " + HUDI_COW_PT_TBL + " WHERE id = 1"); - assertEquals(fileModifiedTime.toInstant().toEpochMilli(), Files.getLastModifiedTime(toPath(path)).toInstant().toEpochMilli()); + assertThat(fileModifiedTime.toInstant().toEpochMilli()) + .isEqualTo(Files.getLastModifiedTime(toPath(path)).toInstant().toEpochMilli()); } @Test diff --git a/plugin/trino-kudu/pom.xml b/plugin/trino-kudu/pom.xml index b08e9e5c280f..b2f0c17510ed 100644 --- a/plugin/trino-kudu/pom.xml +++ b/plugin/trino-kudu/pom.xml @@ -255,24 +255,5 @@ - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - diff --git a/plugin/trino-memory/pom.xml b/plugin/trino-memory/pom.xml index d4229c226040..42c275e8d656 100644 --- a/plugin/trino-memory/pom.xml +++ b/plugin/trino-memory/pom.xml @@ -197,26 +197,4 @@ test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/plugin/trino-password-authenticators/pom.xml b/plugin/trino-password-authenticators/pom.xml index d6b102b822e7..5917227dc985 100644 --- a/plugin/trino-password-authenticators/pom.xml +++ b/plugin/trino-password-authenticators/pom.xml @@ -171,26 +171,4 @@ test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/plugin/trino-pinot/pom.xml b/plugin/trino-pinot/pom.xml index 59edd39af6e5..ec26b1e8977c 100755 --- a/plugin/trino-pinot/pom.xml +++ b/plugin/trino-pinot/pom.xml @@ -678,23 +678,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - org.apache.maven.plugins maven-enforcer-plugin diff --git a/plugin/trino-prometheus/pom.xml b/plugin/trino-prometheus/pom.xml index 09d1c5dcecfd..0b9722d07590 100644 --- a/plugin/trino-prometheus/pom.xml +++ b/plugin/trino-prometheus/pom.xml @@ -263,26 +263,4 @@ test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/plugin/trino-raptor-legacy/pom.xml b/plugin/trino-raptor-legacy/pom.xml index 646f7ed4caa7..47b013da9f6c 100644 --- a/plugin/trino-raptor-legacy/pom.xml +++ b/plugin/trino-raptor-legacy/pom.xml @@ -271,6 +271,12 @@ jakarta.ws.rs-api test + + org.aspectj + aspectjweaver + 1.9.9.1 + test + org.assertj @@ -320,26 +326,4 @@ test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/AbstractTestBackupStore.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/AbstractTestBackupStore.java index 59b937340036..57f45c085991 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/AbstractTestBackupStore.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/AbstractTestBackupStore.java @@ -13,7 +13,7 @@ */ package io.trino.plugin.raptor.legacy.backup; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.nio.file.Path; diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestFileBackupStore.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestFileBackupStore.java index b113f9be8dbe..66bd6d445abc 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestFileBackupStore.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestFileBackupStore.java @@ -13,9 +13,10 @@ */ package io.trino.plugin.raptor.legacy.backup; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.io.File; import java.io.IOException; @@ -25,12 +26,14 @@ import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE; import static java.lang.String.format; import static java.nio.file.Files.createTempDirectory; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.testng.Assert.assertEquals; +@TestInstance(PER_CLASS) public class TestFileBackupStore extends AbstractTestBackupStore { - @BeforeClass + @BeforeAll public void setup() throws IOException { @@ -39,7 +42,7 @@ public void setup() store.start(); } - @AfterClass(alwaysRun = true) + @AfterAll public void tearDown() throws Exception { diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupStore.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupStore.java index e9f717a26ee4..975b86c3bf6d 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupStore.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/backup/TestHttpBackupStore.java @@ -28,9 +28,11 @@ import io.airlift.node.testing.TestingNodeModule; import io.trino.spi.NodeManager; import io.trino.testing.TestingNodeManager; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; import java.io.IOException; import java.net.URI; @@ -43,13 +45,14 @@ import static io.airlift.jaxrs.JaxrsBinder.jaxrsBinder; import static java.nio.file.Files.createTempDirectory; -@Test(singleThreaded = true) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +@Execution(ExecutionMode.SAME_THREAD) public class TestHttpBackupStore extends AbstractTestBackupStore { private LifeCycleManager lifeCycleManager; - @BeforeMethod + @BeforeEach public void setup() throws IOException { @@ -77,7 +80,7 @@ public void setup() store = injector.getInstance(BackupStore.class); } - @AfterMethod(alwaysRun = true) + @AfterEach public void teardown() throws IOException { diff --git a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/security/TestRaptorReadOnlySecurity.java b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/security/TestRaptorReadOnlySecurity.java index 5f17c2143a6b..fa67df2db1e5 100644 --- a/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/security/TestRaptorReadOnlySecurity.java +++ b/plugin/trino-raptor-legacy/src/test/java/io/trino/plugin/raptor/legacy/security/TestRaptorReadOnlySecurity.java @@ -16,7 +16,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import io.trino.testing.QueryRunner; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static io.trino.plugin.raptor.legacy.RaptorQueryRunner.createRaptorQueryRunner; import static org.assertj.core.api.Assertions.assertThatThrownBy; diff --git a/plugin/trino-redis/pom.xml b/plugin/trino-redis/pom.xml index b7db43f7912d..4142d0de508b 100644 --- a/plugin/trino-redis/pom.xml +++ b/plugin/trino-redis/pom.xml @@ -216,33 +216,10 @@ testcontainers test - - - org.testng - testng - test - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - org.basepom.maven duplicate-finder-maven-plugin diff --git a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestMinimalFunctionality.java b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestMinimalFunctionality.java index a891275cdf4d..ac67e6d9d108 100644 --- a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestMinimalFunctionality.java +++ b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestMinimalFunctionality.java @@ -25,7 +25,6 @@ import static io.trino.transaction.TransactionBuilder.transaction; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertTrue; public class TestMinimalFunctionality extends AbstractTestMinimalFunctionality @@ -44,7 +43,7 @@ public void testTableExists() .singleStatement() .execute(SESSION, session -> { Optional handle = queryRunner.getServer().getMetadata().getTableHandle(session, name); - assertTrue(handle.isPresent()); + assertThat(handle).isPresent(); }); } diff --git a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisPlugin.java b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisPlugin.java index 9487abe4678d..ab4112829f57 100644 --- a/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisPlugin.java +++ b/plugin/trino-redis/src/test/java/io/trino/plugin/redis/TestRedisPlugin.java @@ -21,7 +21,7 @@ import static com.google.common.collect.Iterables.getOnlyElement; import static io.airlift.testing.Assertions.assertInstanceOf; -import static org.testng.Assert.assertNotNull; +import static org.assertj.core.api.Assertions.assertThat; public class TestRedisPlugin { @@ -41,7 +41,7 @@ public void testStartup() .put("bootstrap.quiet", "true") .buildOrThrow(), new TestingConnectorContext()); - assertNotNull(connector); + assertThat(connector).isNotNull(); connector.shutdown(); } } diff --git a/plugin/trino-redshift/pom.xml b/plugin/trino-redshift/pom.xml index 7f47fcaf3700..2a14b45a060f 100644 --- a/plugin/trino-redshift/pom.xml +++ b/plugin/trino-redshift/pom.xml @@ -199,36 +199,8 @@ junit-jupiter-engine test - - - org.testng - testng - test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - - default diff --git a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftTableStatisticsReader.java b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftTableStatisticsReader.java index fe471829e926..762cadb465b5 100644 --- a/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftTableStatisticsReader.java +++ b/plugin/trino-redshift/src/test/java/io/trino/plugin/redshift/TestRedshiftTableStatisticsReader.java @@ -58,8 +58,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.from; import static org.assertj.core.api.Assertions.withinPercentage; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; public class TestRedshiftTableStatisticsReader extends AbstractTestQueryFramework @@ -147,7 +145,7 @@ public void testNullsFraction() TableStatistics stats = collectStats( "SELECT CASE custkey % 3 WHEN 0 THEN NULL ELSE custkey END FROM " + TEST_SCHEMA + ".customer", ImmutableList.of(custkeyColumnHandle)); - assertEquals(stats.getRowCount(), Estimate.of(1500)); + assertThat(stats.getRowCount()).isEqualTo(Estimate.of(1500)); ColumnStatistics columnStatistics = stats.getColumnStatistics().get(custkeyColumnHandle); assertThat(columnStatistics.getNullsFraction().getValue()).isCloseTo(1.0 / 3, withinPercentage(1)); @@ -187,7 +185,7 @@ public void testAverageColumnLength() .hasEntrySatisfying(columns.get(3), statsCloseTo(1.0, 0.99, 14)) .hasEntrySatisfying(columns.get(4), statsCloseTo(1.0, 0.5, 700)) .hasEntrySatisfying(columns.get(5), statsCloseTo(51, 0.5, 800)) - .satisfies(stats -> assertNull(stats.get(columns.get(6)))); + .satisfies(stats -> assertThat(stats.get(columns.get(6))).isNull()); } @Test diff --git a/plugin/trino-resource-group-managers/pom.xml b/plugin/trino-resource-group-managers/pom.xml index b18c76ab044f..afb9ee34af36 100644 --- a/plugin/trino-resource-group-managers/pom.xml +++ b/plugin/trino-resource-group-managers/pom.xml @@ -265,26 +265,4 @@ test - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/plugin/trino-session-property-managers/pom.xml b/plugin/trino-session-property-managers/pom.xml index 74aabce98b64..1deddf09d9b1 100644 --- a/plugin/trino-session-property-managers/pom.xml +++ b/plugin/trino-session-property-managers/pom.xml @@ -217,33 +217,5 @@ testcontainers test - - - org.testng - testng - test - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/AbstractTestSessionPropertyManager.java b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/AbstractTestSessionPropertyManager.java index 43cb801f95ef..7268289354ff 100644 --- a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/AbstractTestSessionPropertyManager.java +++ b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/AbstractTestSessionPropertyManager.java @@ -19,7 +19,7 @@ import io.trino.spi.resourcegroups.QueryType; import io.trino.spi.resourcegroups.ResourceGroupId; import io.trino.spi.session.SessionConfigurationContext; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.Map; import java.util.Optional; diff --git a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/TestSessionPropertyManagerInTransaction.java b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/TestSessionPropertyManagerInTransaction.java index 60c68b9f57cc..d366e673407b 100644 --- a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/TestSessionPropertyManagerInTransaction.java +++ b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/TestSessionPropertyManagerInTransaction.java @@ -18,7 +18,7 @@ import io.trino.testing.AbstractTestQueryFramework; import io.trino.testing.DistributedQueryRunner; import io.trino.testing.QueryRunner; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.io.File; diff --git a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManager.java b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManager.java index c3e54d178e3f..6e21e9acfded 100644 --- a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManager.java +++ b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManager.java @@ -19,20 +19,24 @@ import io.trino.plugin.session.SessionMatchSpec; import io.trino.spi.resourcegroups.ResourceGroupId; import io.trino.spi.session.SessionConfigurationContext; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; import java.util.Map; import java.util.Optional; import java.util.regex.Pattern; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; -@Test(singleThreaded = true) +@TestInstance(PER_CLASS) +@Execution(SAME_THREAD) public class TestDbSessionPropertyManager extends AbstractTestSessionPropertyManager { @@ -45,7 +49,7 @@ public class TestDbSessionPropertyManager private static final ResourceGroupId TEST_RG = new ResourceGroupId("rg1"); - @BeforeClass + @BeforeAll public void setup() { mysqlContainer = new TestingMySqlContainer(); @@ -60,14 +64,14 @@ public void setup() dao = daoProvider.get(); } - @BeforeMethod + @BeforeEach public void setupTest() { specsProvider = new RefreshingDbSpecsProvider(config, dao); manager = new DbSessionPropertyManager(specsProvider); } - @AfterMethod(alwaysRun = true) + @AfterEach public void teardown() { dao.dropSessionPropertiesTable(); @@ -75,7 +79,7 @@ public void teardown() dao.dropSessionSpecsTable(); } - @AfterClass(alwaysRun = true) + @AfterAll public void destroy() { specsProvider.destroy(); @@ -90,9 +94,11 @@ protected void assertProperties(Map systemProperties, Map sessionProperties1 = manager.getSystemSessionProperties(context1); - assertEquals(sessionProperties1.get("prop_1"), "val_1"); - assertFalse(sessionProperties1.containsKey("prop_2")); + assertThat(sessionProperties1.get("prop_1")).isEqualTo("val_1"); + assertThat(sessionProperties1.containsKey("prop_2")).isFalse(); specsProvider.refresh(); SessionConfigurationContext context2 = new SessionConfigurationContext("bar123", Optional.of("bar123"), ImmutableSet.of(), Optional.empty(), TEST_RG); Map sessionProperties2 = manager.getSystemSessionProperties(context2); - assertEquals(sessionProperties2.get("prop_2"), "val_2"); - assertFalse(sessionProperties2.containsKey("prop_1")); + assertThat(sessionProperties2.get("prop_2")).isEqualTo("val_2"); + assertThat(sessionProperties2.containsKey("prop_1")).isFalse(); specsProvider.refresh(); SessionConfigurationContext context3 = new SessionConfigurationContext("foo123", Optional.of("bar123"), ImmutableSet.of(), Optional.empty(), TEST_RG); Map sessionProperties3 = manager.getSystemSessionProperties(context3); - assertEquals(sessionProperties3.get("prop_1"), "val_1"); - assertEquals(sessionProperties3.get("prop_2"), "val_2"); + assertThat(sessionProperties3.get("prop_1")).isEqualTo("val_1"); + assertThat(sessionProperties3.get("prop_2")).isEqualTo("val_2"); specsProvider.refresh(); SessionConfigurationContext context4 = new SessionConfigurationContext("abc", Optional.empty(), ImmutableSet.of(), Optional.empty(), TEST_RG); Map sessionProperties4 = manager.getSystemSessionProperties(context4); - assertFalse(sessionProperties4.containsKey("prop_1")); - assertFalse(sessionProperties4.containsKey("prop_2")); + assertThat(sessionProperties4.containsKey("prop_1")).isFalse(); + assertThat(sessionProperties4.containsKey("prop_2")).isFalse(); } /** @@ -181,10 +187,10 @@ public void testReloads() long failuresAfter = specsProvider.getDbLoadFailures().getTotalCount(); // Failed reloading, use cached configurations - assertEquals(failuresAfter - failuresBefore, 1); + assertThat(failuresAfter - failuresBefore).isEqualTo(1); Map sessionProperties1 = manager.getSystemSessionProperties(context1); - assertEquals(sessionProperties1.get("prop_1"), "val_1"); - assertEquals(sessionProperties1.get("prop_3"), null); + assertThat(sessionProperties1.get("prop_1")).isEqualTo("val_1"); + assertThat(sessionProperties1.get("prop_3")).isEqualTo(null); } /** @@ -209,10 +215,10 @@ public void testOrderingOfSpecs() SessionConfigurationContext context = new SessionConfigurationContext("foo", Optional.of("bar"), ImmutableSet.of(), Optional.empty(), TEST_RG); Map sessionProperties = manager.getSystemSessionProperties(context); - assertEquals(sessionProperties.get("prop_1"), "val_1_3"); - assertEquals(sessionProperties.get("prop_2"), "val_2_2"); - assertEquals(sessionProperties.get("prop_3"), "val_3_1"); - assertEquals(sessionProperties.size(), 3); + assertThat(sessionProperties.get("prop_1")).isEqualTo("val_1_3"); + assertThat(sessionProperties.get("prop_2")).isEqualTo("val_2_2"); + assertThat(sessionProperties.get("prop_3")).isEqualTo("val_3_1"); + assertThat(sessionProperties.size()).isEqualTo(3); } @Test @@ -228,9 +234,8 @@ public void testCatalogSessionProperties() specsProvider.refresh(); SessionConfigurationContext context1 = new SessionConfigurationContext("foo", Optional.empty(), ImmutableSet.of(), Optional.empty(), TEST_RG); - assertEquals(manager.getCatalogSessionProperties(context1), - ImmutableMap.of("catalog_1", - ImmutableMap.of("prop_1", "val_1_bis", "prop_2", "val_2", "prop_3", "val_3"))); + assertThat(manager.getCatalogSessionProperties(context1)).isEqualTo(ImmutableMap.of("catalog_1", + ImmutableMap.of("prop_1", "val_1_bis", "prop_2", "val_2", "prop_3", "val_3"))); } @Test @@ -238,7 +243,7 @@ public void testEmptyTables() { specsProvider.refresh(); SessionConfigurationContext context1 = new SessionConfigurationContext("foo", Optional.empty(), ImmutableSet.of(), Optional.empty(), TEST_RG); - assertEquals(manager.getSystemSessionProperties(context1), ImmutableMap.of()); - assertEquals(manager.getCatalogSessionProperties(context1), ImmutableMap.of()); + assertThat(manager.getSystemSessionProperties(context1)).isEqualTo(ImmutableMap.of()); + assertThat(manager.getCatalogSessionProperties(context1)).isEqualTo(ImmutableMap.of()); } } diff --git a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerConfig.java b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerConfig.java index c5c4a071524e..a07d94198e03 100644 --- a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerConfig.java +++ b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerConfig.java @@ -15,7 +15,7 @@ import com.google.common.collect.ImmutableMap; import io.airlift.units.Duration; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.Map; import java.util.concurrent.TimeUnit; diff --git a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerIntegration.java b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerIntegration.java index fb9ec0de90e8..33751da94278 100644 --- a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerIntegration.java +++ b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/db/TestDbSessionPropertyManagerIntegration.java @@ -39,10 +39,12 @@ import io.trino.testing.MaterializedResult; import org.jdbi.v3.core.Jdbi; import org.jdbi.v3.sqlobject.SqlObjectPlugin; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; import java.io.IOException; import java.util.Map; @@ -54,11 +56,13 @@ import static java.util.Collections.emptyMap; import static java.util.Locale.ENGLISH; import static java.util.concurrent.TimeUnit.DAYS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; +import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD; import static org.weakref.jmx.guice.ExportBinder.newExporter; -@Test(singleThreaded = true) // see @BeforeMethod +@TestInstance(PER_CLASS) +@Execution(SAME_THREAD) public class TestDbSessionPropertyManagerIntegration { private DistributedQueryRunner queryRunner; @@ -74,18 +78,19 @@ private static DistributedQueryRunner createQueryRunner() throws Exception { Session session = testSessionBuilder().build(); - assertEquals(session.getSystemProperties(), emptyMap()); + assertThat(session.getSystemProperties()).isEqualTo(emptyMap()); Duration sessionValue = session.getSystemProperty(EXAMPLE_PROPERTY, Duration.class); - assertEquals(sessionValue, EXAMPLE_VALUE_DEFAULT); - assertNotEquals(EXAMPLE_VALUE_DEFAULT, EXAMPLE_VALUE_CONFIGURED); + assertThat(sessionValue).isEqualTo(EXAMPLE_VALUE_DEFAULT); + assertThat(EXAMPLE_VALUE_DEFAULT) + .isNotEqualTo(EXAMPLE_VALUE_CONFIGURED); DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).build(); queryRunner.installPlugin(new TestingSessionPropertyConfigurationManagerPlugin()); return queryRunner; } - @BeforeClass + @BeforeAll public void setup() throws Exception { @@ -94,7 +99,7 @@ public void setup() queryRunner = createQueryRunner(); } - @AfterClass(alwaysRun = true) + @AfterAll public void destroy() throws IOException { @@ -106,7 +111,7 @@ public void destroy() mysqlContainer = null; } - @BeforeMethod + @BeforeEach public void setupTest() { queryRunner.getCoordinator().getSessionPropertyDefaults() @@ -125,7 +130,7 @@ public void setupTest() .onDemand(SessionPropertiesDao.class); } - @Test(description = "Test successful and unsuccessful reloading of SessionMatchSpecs from the database") + @Test // "Test successful and unsuccessful reloading of SessionMatchSpecs from the database" public void testOperation() { // Configure the session property for users with user regex user1.* @@ -166,7 +171,7 @@ private void assertSessionPropertyValue(String user, Duration expectedValue) .collect(onlyElement()) .getField(1); - assertEquals(Duration.valueOf(actualValueString), expectedValue); + assertThat(Duration.valueOf(actualValueString)).isEqualTo(expectedValue); } /** diff --git a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/file/TestFileSessionPropertyManager.java b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/file/TestFileSessionPropertyManager.java index e4f911644b00..311c2e8c5b31 100644 --- a/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/file/TestFileSessionPropertyManager.java +++ b/plugin/trino-session-property-managers/src/test/java/io/trino/plugin/session/file/TestFileSessionPropertyManager.java @@ -26,7 +26,7 @@ import java.util.Map; import static io.trino.plugin.session.file.FileSessionPropertyManager.CODEC; -import static org.testng.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class TestFileSessionPropertyManager extends AbstractTestSessionPropertyManager @@ -39,8 +39,8 @@ protected void assertProperties(Map systemProperties, Map - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - diff --git a/plugin/trino-thrift-testing-server/pom.xml b/plugin/trino-thrift-testing-server/pom.xml index dddd285c164a..0fd32725cf0b 100644 --- a/plugin/trino-thrift-testing-server/pom.xml +++ b/plugin/trino-thrift-testing-server/pom.xml @@ -140,33 +140,5 @@ junit-jupiter-engine test - - - org.testng - testng - test - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - - - diff --git a/plugin/trino-thrift-testing-server/src/test/java/io/trino/plugin/thrift/server/TestListBasedRecordSet.java b/plugin/trino-thrift-testing-server/src/test/java/io/trino/plugin/thrift/server/TestListBasedRecordSet.java index a6c28fd9fa3e..9dc1a726e83b 100644 --- a/plugin/trino-thrift-testing-server/src/test/java/io/trino/plugin/thrift/server/TestListBasedRecordSet.java +++ b/plugin/trino-thrift-testing-server/src/test/java/io/trino/plugin/thrift/server/TestListBasedRecordSet.java @@ -23,10 +23,8 @@ import static io.trino.spi.type.BigintType.BIGINT; import static io.trino.spi.type.IntegerType.INTEGER; import static io.trino.spi.type.VarcharType.VARCHAR; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; public class TestListBasedRecordSet { @@ -34,9 +32,9 @@ public class TestListBasedRecordSet public void testEmptyCursor() { ListBasedRecordSet recordSet = new ListBasedRecordSet(ImmutableList.of(), ImmutableList.of(BIGINT, INTEGER)); - assertEquals(recordSet.getColumnTypes(), ImmutableList.of(BIGINT, INTEGER)); + assertThat(recordSet.getColumnTypes()).isEqualTo(ImmutableList.of(BIGINT, INTEGER)); RecordCursor cursor = recordSet.cursor(); - assertFalse(cursor.advanceNextPosition()); + assertThat(cursor.advanceNextPosition()).isFalse(); } @Test @@ -47,23 +45,23 @@ public void testCursor() Arrays.asList("1", null, "3"), Arrays.asList("ab", "c", null)), ImmutableList.of(BIGINT, VARCHAR)); - assertEquals(recordSet.getColumnTypes(), ImmutableList.of(BIGINT, VARCHAR)); + assertThat(recordSet.getColumnTypes()).isEqualTo(ImmutableList.of(BIGINT, VARCHAR)); RecordCursor cursor = recordSet.cursor(); - assertTrue(cursor.advanceNextPosition()); - assertEquals(cursor.getType(0), BIGINT); - assertEquals(cursor.getType(1), VARCHAR); + assertThat(cursor.advanceNextPosition()).isTrue(); + assertThat(cursor.getType(0)).isEqualTo(BIGINT); + assertThat(cursor.getType(1)).isEqualTo(VARCHAR); assertThatThrownBy(() -> cursor.getLong(2)) .isInstanceOf(IndexOutOfBoundsException.class) .hasMessage("Index 2 out of bounds for length 2"); - assertEquals(cursor.getLong(0), 1L); - assertEquals(cursor.getSlice(1), Slices.utf8Slice("ab")); - assertTrue(cursor.advanceNextPosition()); - assertTrue(cursor.isNull(0)); - assertEquals(cursor.getSlice(1), Slices.utf8Slice("c")); - assertTrue(cursor.advanceNextPosition()); - assertEquals(cursor.getLong(0), 3L); - assertTrue(cursor.isNull(1)); - assertFalse(cursor.advanceNextPosition()); + assertThat(cursor.getLong(0)).isEqualTo(1L); + assertThat(cursor.getSlice(1)).isEqualTo(Slices.utf8Slice("ab")); + assertThat(cursor.advanceNextPosition()).isTrue(); + assertThat(cursor.isNull(0)).isTrue(); + assertThat(cursor.getSlice(1)).isEqualTo(Slices.utf8Slice("c")); + assertThat(cursor.advanceNextPosition()).isTrue(); + assertThat(cursor.getLong(0)).isEqualTo(3L); + assertThat(cursor.isNull(1)).isTrue(); + assertThat(cursor.advanceNextPosition()).isFalse(); assertThatThrownBy(() -> cursor.getLong(0)) .isInstanceOf(IndexOutOfBoundsException.class) .hasMessage("Index 3 out of bounds for length 3"); diff --git a/plugin/trino-thrift/pom.xml b/plugin/trino-thrift/pom.xml index 480aab9517ce..6d1795b5c2cb 100644 --- a/plugin/trino-thrift/pom.xml +++ b/plugin/trino-thrift/pom.xml @@ -257,24 +257,5 @@ - - - org.apache.maven.plugins - maven-surefire-plugin - - - - org.apache.maven.surefire - surefire-junit-platform - ${dep.plugin.surefire.version} - - - org.apache.maven.surefire - surefire-testng - ${dep.plugin.surefire.version} - - - -