Skip to content

Commit

Permalink
update tests to assertj
Browse files Browse the repository at this point in the history
  • Loading branch information
clettieri committed Sep 13, 2023
1 parent ed0dcbb commit 569e5bf
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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
Expand Down

0 comments on commit 569e5bf

Please sign in to comment.