From 569e5bfc9e4a26d3fdbe342c78ff0c736fc7629e Mon Sep 17 00:00:00 2001 From: Chris Lettieri Date: Wed, 13 Sep 2023 14:34:07 -0400 Subject: [PATCH] update tests to assertj --- .../TestAlterTablePartitionFields.java | 33 ++++++++++++++----- .../TestAlterTablePartitionFields.java | 33 ++++++++++++++----- .../TestAlterTablePartitionFields.java | 33 ++++++++++++++----- .../TestAlterTablePartitionFields.java | 33 ++++++++++++++----- 4 files changed, 100 insertions(+), 32 deletions(-) diff --git a/spark/v3.1/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java b/spark/v3.1/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java index 3a3e2549b446..952764fe2507 100644 --- a/spark/v3.1/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java +++ b/spark/v3.1/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java @@ -28,6 +28,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Test; +import org.assertj.core.api.Assertions; public class TestAlterTablePartitionFields extends SparkExtensionsTestBase { public TestAlterTablePartitionFields( @@ -186,7 +187,9 @@ public void testAddYearPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD year(ts)", tableName); @@ -195,7 +198,9 @@ public void testAddYearPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).year("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -205,7 +210,9 @@ public void testAddMonthPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD month(ts)", tableName); @@ -214,7 +221,9 @@ public void testAddMonthPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).month("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -224,7 +233,9 @@ public void testAddDayPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD day(ts)", tableName); @@ -233,7 +244,9 @@ public void testAddDayPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).day("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -243,7 +256,9 @@ public void testAddHourPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD hour(ts)", tableName); @@ -252,7 +267,9 @@ public void testAddHourPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).hour("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test diff --git a/spark/v3.2/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java b/spark/v3.2/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java index a8a563da14e1..660aeca9820f 100644 --- a/spark/v3.2/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java +++ b/spark/v3.2/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java @@ -28,6 +28,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Test; +import org.assertj.core.api.Assertions; public class TestAlterTablePartitionFields extends SparkExtensionsTestBase { public TestAlterTablePartitionFields( @@ -186,7 +187,9 @@ public void testAddYearPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD year(ts)", tableName); @@ -195,7 +198,9 @@ public void testAddYearPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).year("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -205,7 +210,9 @@ public void testAddMonthPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD month(ts)", tableName); @@ -214,7 +221,9 @@ public void testAddMonthPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).month("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -224,7 +233,9 @@ public void testAddDayPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD day(ts)", tableName); @@ -233,7 +244,9 @@ public void testAddDayPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).day("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -243,7 +256,9 @@ public void testAddHourPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD hour(ts)", tableName); @@ -252,7 +267,9 @@ public void testAddHourPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).hour("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test diff --git a/spark/v3.3/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java b/spark/v3.3/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java index 3e31170dae7b..97ee6e8633ca 100644 --- a/spark/v3.3/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java +++ b/spark/v3.3/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java @@ -28,6 +28,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Test; +import org.assertj.core.api.Assertions; public class TestAlterTablePartitionFields extends SparkExtensionsTestBase { public TestAlterTablePartitionFields( @@ -186,7 +187,9 @@ public void testAddYearPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD year(ts)", tableName); @@ -195,7 +198,9 @@ public void testAddYearPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).year("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -205,7 +210,9 @@ public void testAddMonthPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD month(ts)", tableName); @@ -214,7 +221,9 @@ public void testAddMonthPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).month("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -224,7 +233,9 @@ public void testAddDayPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD day(ts)", tableName); @@ -233,7 +244,9 @@ public void testAddDayPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).day("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -243,7 +256,9 @@ public void testAddHourPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD hour(ts)", tableName); @@ -252,7 +267,9 @@ public void testAddHourPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).hour("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test diff --git a/spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java b/spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java index 3e31170dae7b..97ee6e8633ca 100644 --- a/spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java +++ b/spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java @@ -28,6 +28,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Test; +import org.assertj.core.api.Assertions; public class TestAlterTablePartitionFields extends SparkExtensionsTestBase { public TestAlterTablePartitionFields( @@ -186,7 +187,9 @@ public void testAddYearPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD year(ts)", tableName); @@ -195,7 +198,9 @@ public void testAddYearPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).year("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -205,7 +210,9 @@ public void testAddMonthPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD month(ts)", tableName); @@ -214,7 +221,9 @@ public void testAddMonthPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).month("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -224,7 +233,9 @@ public void testAddDayPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD day(ts)", tableName); @@ -233,7 +244,9 @@ public void testAddDayPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).day("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test @@ -243,7 +256,9 @@ public void testAddHourPartition() { tableName); Table table = validationCatalog.loadTable(tableIdent); - Assert.assertTrue("Table should start unpartitioned", table.spec().isUnpartitioned()); + Assertions.assertThat(table.spec().isUnpartitioned()) + .as("Table should start unpartitioned") + .isTrue(); sql("ALTER TABLE %s ADD PARTITION FIELD hour(ts)", tableName); @@ -252,7 +267,9 @@ public void testAddHourPartition() { PartitionSpec expected = PartitionSpec.builderFor(table.schema()).withSpecId(1).hour("ts").build(); - Assert.assertEquals("Should have new spec field", expected, table.spec()); + Assertions.assertThat(table.spec()) + .as("Should have new spec field") + .isEqualTo(expected); } @Test