-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to junit5 for mr #9241
Switch to junit5 for mr #9241
Conversation
@@ -54,9 +53,9 @@ public class TestCatalogs { | |||
|
|||
private Configuration conf; | |||
|
|||
@Rule public TemporaryFolder temp = new TemporaryFolder(); | |||
@TempDir public Path temp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TempDir public Path temp; | |
@TempDir private Path temp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Assert.assertEquals(PartitionSpecParser.toJson(SPEC), PartitionSpecParser.toJson(table.spec())); | ||
Assertions.assertThat(SchemaParser.toJson(table.schema())) | ||
.isEqualTo(SchemaParser.toJson(SCHEMA)); | ||
Assertions.assertThat(PartitionSpecParser.toJson(table.spec())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use the statically imported assertThat()
method here and everywhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Fixed this by doing static import in all changed files.
@@ -198,11 +202,11 @@ public void testCreateDropTableToCatalog() throws IOException { | |||
public void testLoadCatalogDefault() { | |||
String catalogName = "barCatalog"; | |||
Optional<Catalog> defaultCatalog = Catalogs.loadCatalog(conf, catalogName); | |||
Assert.assertTrue(defaultCatalog.isPresent()); | |||
Assertions.assertThat(defaultCatalog.isPresent()).isTrue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assertions.assertThat(defaultCatalog.isPresent()).isTrue(); | |
assertThat(defaultCatalog).isPresent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this in latest commit 10a0099
@@ -212,11 +216,11 @@ public void testLoadCatalogHive() { | |||
InputFormatConfig.catalogPropertyConfigKey(catalogName, CatalogUtil.ICEBERG_CATALOG_TYPE), | |||
CatalogUtil.ICEBERG_CATALOG_TYPE_HIVE); | |||
Optional<Catalog> hiveCatalog = Catalogs.loadCatalog(conf, catalogName); | |||
Assert.assertTrue(hiveCatalog.isPresent()); | |||
Assertions.assertThat(hiveCatalog.isPresent()).isTrue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also update all the other places that are similar to this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -230,13 +234,13 @@ public void testLoadCatalogHadoop() { | |||
catalogName, CatalogProperties.WAREHOUSE_LOCATION), | |||
"/tmp/mylocation"); | |||
Optional<Catalog> hadoopCatalog = Catalogs.loadCatalog(conf, catalogName); | |||
Assert.assertTrue(hadoopCatalog.isPresent()); | |||
Assertions.assertThat(hadoopCatalog.isPresent()).isTrue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
import org.junit.Assume; | ||
import org.junit.Test; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Assumptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use AssertJ assumptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. done
assertEquals(actual.child().op(), expected.child().op()); | ||
assertEquals(childExpressionActual.ref().name(), childExpressionExpected.ref().name()); | ||
assertEquals(childExpressionActual.literal(), childExpressionExpected.literal()); | ||
Assertions.assertThat(expected.op()).isEqualTo(actual.op()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's ok to statically import assertThat()
here and in the other files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes Got it.
@@ -80,7 +79,7 @@ public class TestHiveIcebergOutputCommitter { | |||
private static final PartitionSpec PARTITIONED_SPEC = | |||
PartitionSpec.builderFor(CUSTOMER_SCHEMA).bucket("customer_id", 3).build(); | |||
|
|||
@Rule public TemporaryFolder temp = new TemporaryFolder(); | |||
@TempDir public Path temp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TempDir public Path temp; | |
@TempDir private Path temp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed this
JobConf conf = jobConf(table, 1); | ||
|
||
Assertions.assertThatThrownBy( | ||
() -> writeRecords(table.name(), 1, 0, true, false, conf, failingCommitter)) | ||
.isInstanceOf(RuntimeException.class) | ||
.hasMessage(exceptionMessage); | ||
|
||
Assert.assertEquals(1, argumentCaptor.getAllValues().size()); | ||
Assertions.assertThat(argumentCaptor.getAllValues().size()).isEqualTo(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as previously mentioned about size assertions: hasSize(xyz)
is better here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this in 10a0099
|
||
public class TestHiveIcebergSerDe { | ||
|
||
private static final Schema schema = | ||
new Schema(required(1, "string_field", Types.StringType.get())); | ||
|
||
@Rule public TemporaryFolder tmp = new TemporaryFolder(); | ||
@TempDir public Path tmp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TempDir public Path tmp; | |
@TempDir private Path tmp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also update this in all the other files being touched by this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Assume.assumeFalse( | ||
"No test yet for Hive3 (Date/Timestamp creation)", HiveVersion.min(HiveVersion.HIVE_3)); | ||
assumeThat(HiveVersion.min(HiveVersion.HIVE_3)) | ||
.as("No test yet for Hive3 (Date/Timestamp creation)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a .isFalse()
at the end, otherwise it wouldn't anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I missed that. Thank you for noticing.
@lschetanrao this just needs one minor update around the assumption. Can you also please open an issue to address parameterized tests in this module? |
Yes sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, the CI failure around the labeler is being fixed separately and is not related to the changes introduced here
Closes #9083
The goal here is to switch all imports to Junit5 and to use AssertJ-style assertions.
All test cases except the ones using parameterized tests have been migrated. Once #9161 gets merged, I will make the necessary changes to migrate Parameterized test as well.