-
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
Flink v1.16: Switch Flink v1.16 tests to Junit5 (Part 1) #9565
Changes from all commits
65b1693
3e757fb
aa2131e
6c42d3f
5453e07
f0a26b8
49ace4c
c5ec5ef
f649401
0f73166
b26ed5c
5ec1077
6361a44
c60c1d0
8e3aa87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,6 +18,8 @@ | |||||
*/ | ||||||
package org.apache.iceberg.flink; | ||||||
|
||||||
import static org.assertj.core.api.Assertions.assertThat; | ||||||
|
||||||
import java.util.Iterator; | ||||||
import org.apache.flink.table.data.RowData; | ||||||
import org.apache.iceberg.RecordWrapperTest; | ||||||
|
@@ -28,8 +30,6 @@ | |||||
import org.apache.iceberg.data.Record; | ||||||
import org.apache.iceberg.flink.data.RandomRowData; | ||||||
import org.apache.iceberg.util.StructLikeWrapper; | ||||||
import org.assertj.core.api.Assertions; | ||||||
import org.junit.Assert; | ||||||
|
||||||
public class TestRowDataWrapper extends RecordWrapperTest { | ||||||
|
||||||
|
@@ -49,12 +49,12 @@ public void testTime() { | |||||
return; | ||||||
} | ||||||
|
||||||
Assertions.assertThat(actual).isNotNull(); | ||||||
Assertions.assertThat(expected).isNotNull(); | ||||||
assertThat(actual).isNotNull(); | ||||||
assertThat(expected).isNotNull(); | ||||||
|
||||||
int expectedMilliseconds = (int) ((long) expected / 1000_000); | ||||||
int actualMilliseconds = (int) ((long) actual / 1000_000); | ||||||
Assert.assertEquals(message, expectedMilliseconds, actualMilliseconds); | ||||||
assertThat(expectedMilliseconds).as(message).isEqualTo(actualMilliseconds); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the actual/expected is the wrong way around. It should be |
||||||
} | ||||||
}); | ||||||
} | ||||||
|
@@ -75,8 +75,8 @@ protected void generateAndValidate(Schema schema, RecordWrapperTest.AssertMethod | |||||
StructLikeWrapper actualWrapper = StructLikeWrapper.forType(schema.asStruct()); | ||||||
StructLikeWrapper expectedWrapper = StructLikeWrapper.forType(schema.asStruct()); | ||||||
for (int i = 0; i < numRecords; i++) { | ||||||
Assert.assertTrue("Should have more records", actual.hasNext()); | ||||||
Assert.assertTrue("Should have more RowData", expected.hasNext()); | ||||||
assertThat(actual.hasNext()).as("Should have more records").isTrue(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
same for the other places that use a similar pattern. We want to avoid using isTrue/isFalse as much as possible, because we want to get rich context from AssertJ when the assertion ever fails |
||||||
assertThat(expected.hasNext()).as("Should have more RowData").isTrue(); | ||||||
|
||||||
StructLike recordStructLike = recordWrapper.wrap(actual.next()); | ||||||
StructLike rowDataStructLike = rowDataWrapper.wrap(expected.next()); | ||||||
|
@@ -87,7 +87,7 @@ protected void generateAndValidate(Schema schema, RecordWrapperTest.AssertMethod | |||||
expectedWrapper.set(rowDataStructLike)); | ||||||
} | ||||||
|
||||||
Assert.assertFalse("Shouldn't have more record", actual.hasNext()); | ||||||
Assert.assertFalse("Shouldn't have more RowData", expected.hasNext()); | ||||||
assertThat(actual.hasNext()).as("Shouldn't have more record").isFalse(); | ||||||
assertThat(expected.hasNext()).as("Shouldn't have more RowData").isFalse(); | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
import org.apache.iceberg.flink.DataGenerator; | ||
import org.apache.iceberg.flink.DataGenerators; | ||
import org.apache.iceberg.flink.TestHelpers; | ||
import org.junit.Test; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TestStructRowData { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not also include the other files from the |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,11 @@ | |
*/ | ||
package org.apache.iceberg.flink.sink; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have expected to include other test files from the |
||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrong import. We should be using |
||
|
||
import org.apache.flink.table.data.RowData; | ||
import org.apache.iceberg.flink.AvroGenericRecordConverterBase; | ||
import org.apache.iceberg.flink.DataGenerator; | ||
import org.junit.Assert; | ||
|
||
public class TestAvroGenericRecordToRowDataMapper extends AvroGenericRecordConverterBase { | ||
@Override | ||
|
@@ -32,6 +33,6 @@ protected void testConverter(DataGenerator dataGenerator) throws Exception { | |
AvroGenericRecordToRowDataMapper.forAvroSchema(dataGenerator.avroSchema()); | ||
RowData expected = dataGenerator.generateFlinkRowData(); | ||
RowData actual = mapper.map(dataGenerator.generateAvroGenericRecord()); | ||
Assert.assertEquals(expected, actual); | ||
assertEquals(expected, actual); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
*/ | ||
package org.apache.iceberg.flink.sink; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.apache.flink.table.data.GenericRowData; | ||
|
@@ -35,8 +37,7 @@ | |
import org.apache.iceberg.flink.data.RandomRowData; | ||
import org.apache.iceberg.relocated.com.google.common.collect.Lists; | ||
import org.apache.iceberg.types.Types; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TestRowDataPartitionKey { | ||
private static final Schema SCHEMA = | ||
|
@@ -91,10 +92,10 @@ public void testNullPartitionValue() { | |
for (RowData row : rows) { | ||
PartitionKey partitionKey = new PartitionKey(spec, schema); | ||
partitionKey.partition(rowWrapper.wrap(row)); | ||
Assert.assertEquals(partitionKey.size(), 1); | ||
assertThat(partitionKey.size()).isEqualTo(1); | ||
|
||
String expectedStr = row.isNullAt(1) ? null : row.getString(1).toString(); | ||
Assert.assertEquals(expectedStr, partitionKey.get(0, String.class)); | ||
assertThat(expectedStr).isEqualTo(partitionKey.get(0, String.class)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the ordering of actual/expected needs to be fixed here |
||
} | ||
} | ||
|
||
|
@@ -116,15 +117,15 @@ public void testPartitionWithOneNestedField() { | |
|
||
PartitionKey partitionKey1 = new PartitionKey(spec1, NESTED_SCHEMA); | ||
partitionKey1.partition(rowWrapper.wrap(row)); | ||
Assert.assertEquals(partitionKey1.size(), 1); | ||
assertThat(partitionKey1.size()).isEqualTo(1); | ||
|
||
Assert.assertEquals(record.get(0), partitionKey1.get(0, String.class)); | ||
assertThat(record.get(0)).isEqualTo(partitionKey1.get(0, String.class)); | ||
|
||
PartitionKey partitionKey2 = new PartitionKey(spec2, NESTED_SCHEMA); | ||
partitionKey2.partition(rowWrapper.wrap(row)); | ||
Assert.assertEquals(partitionKey2.size(), 1); | ||
assertThat(partitionKey2.size()).isEqualTo(1); | ||
|
||
Assert.assertEquals(record.get(1), partitionKey2.get(0, Integer.class)); | ||
assertThat(record.get(1)).isEqualTo(partitionKey2.get(0, Integer.class)); | ||
} | ||
} | ||
|
||
|
@@ -154,16 +155,16 @@ public void testPartitionMultipleNestedField() { | |
Record record = (Record) records.get(i).get(0); | ||
|
||
pk1.partition(rowWrapper.wrap(row)); | ||
Assert.assertEquals(2, pk1.size()); | ||
assertThat(pk1.size()).isEqualTo(2); | ||
|
||
Assert.assertEquals(record.get(1), pk1.get(0, Integer.class)); | ||
Assert.assertEquals(record.get(0), pk1.get(1, String.class)); | ||
assertThat(record.get(1)).isEqualTo(pk1.get(0, Integer.class)); | ||
assertThat(record.get(0)).isEqualTo(pk1.get(1, String.class)); | ||
|
||
pk2.partition(rowWrapper.wrap(row)); | ||
Assert.assertEquals(2, pk2.size()); | ||
assertThat(pk2.size()).isEqualTo(2); | ||
|
||
Assert.assertEquals(record.get(0), pk2.get(0, String.class)); | ||
Assert.assertEquals(record.get(1), pk2.get(1, Integer.class)); | ||
assertThat(record.get(0)).isEqualTo(pk2.get(0, String.class)); | ||
assertThat(record.get(1)).isEqualTo(pk2.get(1, Integer.class)); | ||
} | ||
} | ||
|
||
|
@@ -190,19 +191,19 @@ public void testPartitionValueTypes() { | |
pk.partition(rowWrapper.wrap(row)); | ||
expectedPK.partition(recordWrapper.wrap(record)); | ||
|
||
Assert.assertEquals( | ||
"Partition with column " + column + " should have one field.", 1, pk.size()); | ||
assertThat(pk.size()) | ||
.as("Partition with column " + column + " should have one field.") | ||
.isEqualTo(1); | ||
|
||
if (column.equals("timeType")) { | ||
Assert.assertEquals( | ||
"Partition with column " + column + " should have the expected values", | ||
expectedPK.get(0, Long.class) / 1000, | ||
pk.get(0, Long.class) / 1000); | ||
assertThat(expectedPK.get(0, Long.class) / 1000) | ||
.as("Partition with column " + column + " should have the expected values") | ||
.isEqualTo(pk.get(0, Long.class) / 1000); | ||
|
||
} else { | ||
Assert.assertEquals( | ||
"Partition with column " + column + " should have the expected values", | ||
expectedPK.get(0, javaClasses[0]), | ||
pk.get(0, javaClasses[0])); | ||
assertThat(expectedPK.get(0, javaClasses[0])) | ||
.as("Partition with column " + column + " should have the expected values") | ||
.isEqualTo(pk.get(0, javaClasses[0])); | ||
} | ||
} | ||
} | ||
|
@@ -232,19 +233,18 @@ public void testNestedPartitionValues() { | |
pk.partition(rowWrapper.wrap(rows.get(j))); | ||
expectedPK.partition(recordWrapper.wrap(records.get(j))); | ||
|
||
Assert.assertEquals( | ||
"Partition with nested column " + column + " should have one field.", 1, pk.size()); | ||
assertThat(pk.size()) | ||
.as("Partition with nested column " + column + " should have one field.") | ||
.isEqualTo(1); | ||
|
||
if (column.equals("nested.timeType")) { | ||
Assert.assertEquals( | ||
"Partition with nested column " + column + " should have the expected values.", | ||
expectedPK.get(0, Long.class) / 1000, | ||
pk.get(0, Long.class) / 1000); | ||
assertThat(expectedPK.get(0, Long.class) / 1000) | ||
.as("Partition with nested column " + column + " should have the expected values.") | ||
.isEqualTo(pk.get(0, Long.class) / 1000); | ||
} else { | ||
Assert.assertEquals( | ||
"Partition with nested column " + column + " should have the expected values.", | ||
expectedPK.get(0, javaClasses[0]), | ||
pk.get(0, javaClasses[0])); | ||
assertThat(expectedPK.get(0, javaClasses[0])) | ||
.as("Partition with nested column " + column + " should have the expected values.") | ||
.isEqualTo(pk.get(0, javaClasses[0])); | ||
} | ||
} | ||
} | ||
|
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 is already set in L127, so it's not needed here