[HUDI-780] Migrate test cases to Junit 5 (#1504)
This commit is contained in:
@@ -21,11 +21,15 @@ package org.apache.hudi.avro;
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.avro.generic.GenericData;
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests hoodie avro utilities.
|
||||
*/
|
||||
@@ -59,18 +63,18 @@ public class TestHoodieAvroUtils {
|
||||
continue;
|
||||
}
|
||||
|
||||
Assert.assertNotNull("field name is null", field.name());
|
||||
assertNotNull(field.name(), "field name is null");
|
||||
Map<String, Object> props = field.getObjectProps();
|
||||
Assert.assertNotNull("The property is null", props);
|
||||
assertNotNull(props, "The property is null");
|
||||
|
||||
if (field.name().equals("pii_col")) {
|
||||
piiPresent = true;
|
||||
Assert.assertTrue("sensitivity_level is removed in field 'pii_col'", props.containsKey("column_category"));
|
||||
assertTrue(props.containsKey("column_category"), "sensitivity_level is removed in field 'pii_col'");
|
||||
} else {
|
||||
Assert.assertEquals("The property shows up but not set", 0, props.size());
|
||||
assertEquals(0, props.size(), "The property shows up but not set");
|
||||
}
|
||||
}
|
||||
Assert.assertTrue("column pii_col doesn't show up", piiPresent);
|
||||
assertTrue(piiPresent, "column pii_col doesn't show up");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,8 +85,8 @@ public class TestHoodieAvroUtils {
|
||||
rec.put("pii_col", "val2");
|
||||
rec.put("timestamp", 3.5);
|
||||
GenericRecord rec1 = HoodieAvroUtils.rewriteRecord(rec, new Schema.Parser().parse(EVOLVED_SCHEMA));
|
||||
Assert.assertEquals(rec1.get("new_col1"), "dummy_val");
|
||||
Assert.assertNull(rec1.get("new_col2"));
|
||||
assertEquals(rec1.get("new_col1"), "dummy_val");
|
||||
assertNull(rec1.get("new_col2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,8 +97,8 @@ public class TestHoodieAvroUtils {
|
||||
rec.put("pii_col", "val2");
|
||||
rec.put("timestamp", 3.5);
|
||||
GenericRecord rec1 = HoodieAvroUtils.rewriteRecord(rec, new Schema.Parser().parse(EVOLVED_SCHEMA));
|
||||
Assert.assertEquals(rec1.get("new_col1"), "dummy_val");
|
||||
Assert.assertNull(rec1.get("new_col2"));
|
||||
assertEquals(rec1.get("new_col1"), "dummy_val");
|
||||
assertNull(rec1.get("new_col2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,6 +109,6 @@ public class TestHoodieAvroUtils {
|
||||
rec.put("pii_col", "val2");
|
||||
rec.put("timestamp", 3.5);
|
||||
GenericRecord rec1 = HoodieAvroUtils.rewriteRecord(rec, new Schema.Parser().parse(SCHEMA_WITH_METADATA_FIELD));
|
||||
Assert.assertNull(rec1.get("_hoodie_commit_time"));
|
||||
assertNull(rec1.get("_hoodie_commit_time"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,20 @@
|
||||
|
||||
package org.apache.hudi.avro;
|
||||
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.avro.generic.GenericData;
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hudi.common.bloom.BloomFilter;
|
||||
import org.apache.hudi.common.bloom.BloomFilterFactory;
|
||||
import org.apache.hudi.common.bloom.BloomFilterTypeCode;
|
||||
import org.apache.hudi.common.model.HoodieRecord;
|
||||
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.avro.generic.GenericData;
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.parquet.avro.AvroSchemaConverter;
|
||||
import org.apache.parquet.hadoop.ParquetWriter;
|
||||
import org.apache.parquet.hadoop.metadata.CompressionCodecName;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -40,16 +40,13 @@ import java.util.UUID;
|
||||
|
||||
public class TestHoodieAvroWriteSupport {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void testAddKey() throws IOException {
|
||||
public void testAddKey(@TempDir java.nio.file.Path tempDir) throws IOException {
|
||||
List<String> rowKeys = new ArrayList<>();
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
rowKeys.add(UUID.randomUUID().toString());
|
||||
}
|
||||
String filePath = folder.getRoot() + "/test.parquet";
|
||||
String filePath = tempDir.resolve("test.parquet").toAbsolutePath().toString();
|
||||
Schema schema = HoodieAvroUtils.getRecordKeySchema();
|
||||
BloomFilter filter = BloomFilterFactory.createBloomFilter(
|
||||
1000, 0.0001, 10000,
|
||||
|
||||
Reference in New Issue
Block a user