From 10a0099520665385bdb837372f27f17f1a41c50f Mon Sep 17 00:00:00 2001 From: lschetanrao Date: Fri, 8 Dec 2023 23:25:10 +0530 Subject: [PATCH] Fixed review comments --- .../org/apache/iceberg/mr/TestCatalogs.java | 73 ++++----- .../iceberg/mr/hive/HiveIcebergTestUtils.java | 18 +-- .../iceberg/mr/hive/TestDeserializer.java | 20 +-- .../mr/hive/TestHiveIcebergFilterFactory.java | 52 +++--- .../hive/TestHiveIcebergOutputCommitter.java | 17 +- .../iceberg/mr/hive/TestHiveIcebergSerDe.java | 11 +- .../TestIcebergBinaryObjectInspector.java | 41 +++-- .../TestIcebergDateObjectInspector.java | 31 ++-- .../TestIcebergDecimalObjectInspector.java | 41 ++--- .../TestIcebergFixedObjectInspector.java | 35 ++-- .../TestIcebergObjectInspector.java | 153 +++++++++--------- .../TestIcebergRecordObjectInspector.java | 17 +- .../TestIcebergTimeObjectInspector.java | 35 ++-- .../TestIcebergTimestampObjectInspector.java | 37 +++-- ...ebergTimestampWithZoneObjectInspector.java | 39 +++-- .../TestIcebergUUIDObjectInspector.java | 35 ++-- 16 files changed, 320 insertions(+), 335 deletions(-) diff --git a/mr/src/test/java/org/apache/iceberg/mr/TestCatalogs.java b/mr/src/test/java/org/apache/iceberg/mr/TestCatalogs.java index 1f79dc34f755..012ad2350224 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/TestCatalogs.java +++ b/mr/src/test/java/org/apache/iceberg/mr/TestCatalogs.java @@ -20,6 +20,7 @@ import static org.apache.iceberg.types.Types.NestedField.required; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.io.IOException; import java.nio.file.Path; @@ -40,7 +41,6 @@ import org.apache.iceberg.hadoop.HadoopTables; import org.apache.iceberg.hive.HiveCatalog; import org.apache.iceberg.types.Types; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -53,7 +53,7 @@ public class TestCatalogs { private Configuration conf; - @TempDir public Path temp; + @TempDir private Path temp; @BeforeEach public void before() { @@ -64,7 +64,7 @@ public void before() { public void testLoadTableFromLocation() throws IOException { conf.set(CatalogUtil.ICEBERG_CATALOG_TYPE, Catalogs.LOCATION); - Assertions.assertThatThrownBy(() -> Catalogs.loadTable(conf)) + assertThatThrownBy(() -> Catalogs.loadTable(conf)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Table location not set"); @@ -73,7 +73,7 @@ public void testLoadTableFromLocation() throws IOException { conf.set(InputFormatConfig.TABLE_LOCATION, hadoopTable.location()); - Assertions.assertThat(Catalogs.loadTable(conf).location()).isEqualTo(hadoopTable.location()); + assertThat(Catalogs.loadTable(conf).location()).isEqualTo(hadoopTable.location()); } @Test @@ -82,7 +82,7 @@ public void testLoadTableFromCatalog() throws IOException { String warehouseLocation = temp.resolve("hadoop").resolve("warehouse").toString(); setCustomCatalogProperties(defaultCatalogName, warehouseLocation); - Assertions.assertThatThrownBy(() -> Catalogs.loadTable(conf)) + assertThatThrownBy(() -> Catalogs.loadTable(conf)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Table identifier not set"); @@ -91,8 +91,7 @@ public void testLoadTableFromCatalog() throws IOException { conf.set(InputFormatConfig.TABLE_IDENTIFIER, "table"); - Assertions.assertThat(Catalogs.loadTable(conf).location()) - .isEqualTo(hadoopCatalogTable.location()); + assertThat(Catalogs.loadTable(conf).location()).isEqualTo(hadoopCatalogTable.location()); } @Test @@ -100,7 +99,7 @@ public void testCreateDropTableToLocation() throws IOException { Properties missingSchema = new Properties(); missingSchema.put("location", temp.resolve("hadoop_tables").toString()); - Assertions.assertThatThrownBy(() -> Catalogs.createTable(conf, missingSchema)) + assertThatThrownBy(() -> Catalogs.createTable(conf, missingSchema)) .isInstanceOf(NullPointerException.class) .hasMessage("Table schema not set"); @@ -108,7 +107,7 @@ public void testCreateDropTableToLocation() throws IOException { Properties missingLocation = new Properties(); missingLocation.put(InputFormatConfig.TABLE_SCHEMA, SchemaParser.toJson(SCHEMA)); - Assertions.assertThatThrownBy(() -> Catalogs.createTable(conf, missingLocation)) + assertThatThrownBy(() -> Catalogs.createTable(conf, missingLocation)) .isInstanceOf(NullPointerException.class) .hasMessage("Table location not set"); @@ -123,14 +122,13 @@ public void testCreateDropTableToLocation() throws IOException { HadoopTables tables = new HadoopTables(); Table table = tables.load(properties.getProperty("location")); - Assertions.assertThat(table.location()).isEqualTo(properties.getProperty("location")); - Assertions.assertThat(SchemaParser.toJson(table.schema())) - .isEqualTo(SchemaParser.toJson(SCHEMA)); - Assertions.assertThat(PartitionSpecParser.toJson(table.spec())) + assertThat(table.location()).isEqualTo(properties.getProperty("location")); + assertThat(SchemaParser.toJson(table.schema())).isEqualTo(SchemaParser.toJson(SCHEMA)); + assertThat(PartitionSpecParser.toJson(table.spec())) .isEqualTo(PartitionSpecParser.toJson(SPEC)); assertThat(table.properties()).containsEntry("dummy", "test"); - Assertions.assertThatThrownBy(() -> Catalogs.dropTable(conf, new Properties())) + assertThatThrownBy(() -> Catalogs.dropTable(conf, new Properties())) .isInstanceOf(NullPointerException.class) .hasMessage("Table location not set"); @@ -138,7 +136,7 @@ public void testCreateDropTableToLocation() throws IOException { dropProperties.put("location", temp.toFile() + "/hadoop_tables"); Catalogs.dropTable(conf, dropProperties); - Assertions.assertThatThrownBy(() -> Catalogs.loadTable(conf, dropProperties)) + assertThatThrownBy(() -> Catalogs.loadTable(conf, dropProperties)) .isInstanceOf(NoSuchTableException.class) .hasMessage("Table does not exist at location: " + properties.getProperty("location")); } @@ -155,14 +153,14 @@ public void testCreateDropTableToCatalog() throws IOException { missingSchema.put("name", identifier.toString()); missingSchema.put(InputFormatConfig.CATALOG_NAME, defaultCatalogName); - Assertions.assertThatThrownBy(() -> Catalogs.createTable(conf, missingSchema)) + assertThatThrownBy(() -> Catalogs.createTable(conf, missingSchema)) .isInstanceOf(NullPointerException.class) .hasMessage("Table schema not set"); Properties missingIdentifier = new Properties(); missingIdentifier.put(InputFormatConfig.TABLE_SCHEMA, SchemaParser.toJson(SCHEMA)); missingIdentifier.put(InputFormatConfig.CATALOG_NAME, defaultCatalogName); - Assertions.assertThatThrownBy(() -> Catalogs.createTable(conf, missingIdentifier)) + assertThatThrownBy(() -> Catalogs.createTable(conf, missingIdentifier)) .isInstanceOf(NullPointerException.class) .hasMessage("Table identifier not set"); @@ -178,13 +176,12 @@ public void testCreateDropTableToCatalog() throws IOException { HadoopCatalog catalog = new CustomHadoopCatalog(conf, warehouseLocation); Table table = catalog.loadTable(identifier); - Assertions.assertThat(SchemaParser.toJson(table.schema())) - .isEqualTo(SchemaParser.toJson(SCHEMA)); - Assertions.assertThat(PartitionSpecParser.toJson(table.spec())) + assertThat(SchemaParser.toJson(table.schema())).isEqualTo(SchemaParser.toJson(SCHEMA)); + assertThat(PartitionSpecParser.toJson(table.spec())) .isEqualTo(PartitionSpecParser.toJson(SPEC)); assertThat(table.properties()).containsEntry("dummy", "test"); - Assertions.assertThatThrownBy(() -> Catalogs.dropTable(conf, new Properties())) + assertThatThrownBy(() -> Catalogs.dropTable(conf, new Properties())) .isInstanceOf(NullPointerException.class) .hasMessage("Table identifier not set"); @@ -193,7 +190,7 @@ public void testCreateDropTableToCatalog() throws IOException { dropProperties.put(InputFormatConfig.CATALOG_NAME, defaultCatalogName); Catalogs.dropTable(conf, dropProperties); - Assertions.assertThatThrownBy(() -> Catalogs.loadTable(conf, dropProperties)) + assertThatThrownBy(() -> Catalogs.loadTable(conf, dropProperties)) .isInstanceOf(NoSuchTableException.class) .hasMessage("Table does not exist: test.table"); } @@ -202,11 +199,11 @@ public void testCreateDropTableToCatalog() throws IOException { public void testLoadCatalogDefault() { String catalogName = "barCatalog"; Optional defaultCatalog = Catalogs.loadCatalog(conf, catalogName); - Assertions.assertThat(defaultCatalog.isPresent()).isTrue(); - Assertions.assertThat(defaultCatalog.get()).isInstanceOf(HiveCatalog.class); + assertThat(defaultCatalog).isPresent(); + assertThat(defaultCatalog.get()).isInstanceOf(HiveCatalog.class); Properties properties = new Properties(); properties.put(InputFormatConfig.CATALOG_NAME, catalogName); - Assertions.assertThat(Catalogs.hiveCatalog(conf, properties)).isTrue(); + assertThat(Catalogs.hiveCatalog(conf, properties)).isTrue(); } @Test @@ -216,11 +213,11 @@ public void testLoadCatalogHive() { InputFormatConfig.catalogPropertyConfigKey(catalogName, CatalogUtil.ICEBERG_CATALOG_TYPE), CatalogUtil.ICEBERG_CATALOG_TYPE_HIVE); Optional hiveCatalog = Catalogs.loadCatalog(conf, catalogName); - Assertions.assertThat(hiveCatalog.isPresent()).isTrue(); - Assertions.assertThat(hiveCatalog.get()).isInstanceOf(HiveCatalog.class); + assertThat(hiveCatalog).isPresent(); + assertThat(hiveCatalog.get()).isInstanceOf(HiveCatalog.class); Properties properties = new Properties(); properties.put(InputFormatConfig.CATALOG_NAME, catalogName); - Assertions.assertThat(Catalogs.hiveCatalog(conf, properties)).isTrue(); + assertThat(Catalogs.hiveCatalog(conf, properties)).isTrue(); } @Test @@ -234,13 +231,13 @@ public void testLoadCatalogHadoop() { catalogName, CatalogProperties.WAREHOUSE_LOCATION), "/tmp/mylocation"); Optional hadoopCatalog = Catalogs.loadCatalog(conf, catalogName); - Assertions.assertThat(hadoopCatalog.isPresent()).isTrue(); - Assertions.assertThat(hadoopCatalog.get()).isInstanceOf(HadoopCatalog.class); - Assertions.assertThat(hadoopCatalog.get().toString()) + assertThat(hadoopCatalog).isPresent(); + assertThat(hadoopCatalog.get()).isInstanceOf(HadoopCatalog.class); + assertThat(hadoopCatalog.get().toString()) .isEqualTo("HadoopCatalog{name=barCatalog, location=/tmp/mylocation}"); Properties properties = new Properties(); properties.put(InputFormatConfig.CATALOG_NAME, catalogName); - Assertions.assertThat(Catalogs.hiveCatalog(conf, properties)).isFalse(); + assertThat(Catalogs.hiveCatalog(conf, properties)).isFalse(); } @Test @@ -254,18 +251,16 @@ public void testLoadCatalogCustom() { catalogName, CatalogProperties.WAREHOUSE_LOCATION), "/tmp/mylocation"); Optional customHadoopCatalog = Catalogs.loadCatalog(conf, catalogName); - Assertions.assertThat(customHadoopCatalog.isPresent()).isTrue(); - Assertions.assertThat(customHadoopCatalog.get()).isInstanceOf(CustomHadoopCatalog.class); + assertThat(customHadoopCatalog).isPresent(); + assertThat(customHadoopCatalog.get()).isInstanceOf(CustomHadoopCatalog.class); Properties properties = new Properties(); properties.put(InputFormatConfig.CATALOG_NAME, catalogName); - Assertions.assertThat(Catalogs.hiveCatalog(conf, properties)).isFalse(); + assertThat(Catalogs.hiveCatalog(conf, properties)).isFalse(); } @Test public void testLoadCatalogLocation() { - Assertions.assertThat( - Catalogs.loadCatalog(conf, Catalogs.ICEBERG_HADOOP_TABLE_NAME).isPresent()) - .isFalse(); + assertThat(Catalogs.loadCatalog(conf, Catalogs.ICEBERG_HADOOP_TABLE_NAME)).isNotPresent(); } @Test @@ -275,7 +270,7 @@ public void testLoadCatalogUnknown() { InputFormatConfig.catalogPropertyConfigKey(catalogName, CatalogUtil.ICEBERG_CATALOG_TYPE), "fooType"); - Assertions.assertThatThrownBy(() -> Catalogs.loadCatalog(conf, catalogName)) + assertThatThrownBy(() -> Catalogs.loadCatalog(conf, catalogName)) .isInstanceOf(UnsupportedOperationException.class) .hasMessage("Unknown catalog type: fooType"); } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/HiveIcebergTestUtils.java b/mr/src/test/java/org/apache/iceberg/mr/hive/HiveIcebergTestUtils.java index 00d21fe357b3..2dc36c0a92ec 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/HiveIcebergTestUtils.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/HiveIcebergTestUtils.java @@ -19,6 +19,7 @@ package org.apache.iceberg.mr.hive; import static org.apache.iceberg.types.Types.NestedField.optional; +import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; @@ -63,7 +64,6 @@ import org.apache.iceberg.relocated.com.google.common.collect.Lists; import org.apache.iceberg.types.Types; import org.apache.iceberg.util.ByteBuffers; -import org.assertj.core.api.Assertions; public class HiveIcebergTestUtils { // TODO: Can this be a constant all around the Iceberg tests? @@ -218,12 +218,10 @@ public static void assertEquals(Record expected, Record actual) { for (int i = 0; i < expected.size(); ++i) { if (expected.get(i) instanceof OffsetDateTime) { // For OffsetDateTime we just compare the actual instant - Assertions.assertThat(((OffsetDateTime) actual.get(i)).toInstant()) + assertThat(((OffsetDateTime) actual.get(i)).toInstant()) .isEqualTo(((OffsetDateTime) expected.get(i)).toInstant()); - } else if (expected.get(i) instanceof byte[]) { - Assertions.assertThat((byte[]) actual.get(i)).isEqualTo((byte[]) expected.get(i)); } else { - Assertions.assertThat(actual.get(i)).isEqualTo(expected.get(i)); + assertThat(actual.get(i)).isEqualTo(expected.get(i)); } } } @@ -264,7 +262,7 @@ public static void validateData(List expected, List actual, int sortedExpected.sort(Comparator.comparingLong(record -> (Long) record.get(sortBy))); sortedActual.sort(Comparator.comparingLong(record -> (Long) record.get(sortBy))); - Assertions.assertThat(sortedActual.size()).isEqualTo(sortedExpected.size()); + assertThat(sortedActual).hasSize(sortedExpected.size()); for (int i = 0; i < sortedExpected.size(); ++i) { assertEquals(sortedExpected.get(i), sortedActual.get(i)); } @@ -287,10 +285,8 @@ public static void validateFiles(Table table, Configuration conf, JobID jobId, i .filter(path -> !path.getFileName().toString().startsWith(".")) .collect(Collectors.toList()); - Assertions.assertThat(dataFiles.size()).isEqualTo(dataFileNum); - Assertions.assertThat( - new File(HiveIcebergOutputCommitter.generateJobLocation(table.location(), conf, jobId)) - .exists()) - .isFalse(); + assertThat(dataFiles).hasSize(dataFileNum); + assertThat(new File(HiveIcebergOutputCommitter.generateJobLocation(table.location(), conf, jobId))) + .doesNotExist(); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/TestDeserializer.java b/mr/src/test/java/org/apache/iceberg/mr/hive/TestDeserializer.java index 71fa5689de6a..cc193457f66f 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/TestDeserializer.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/TestDeserializer.java @@ -19,6 +19,8 @@ package org.apache.iceberg.mr.hive; import static org.apache.iceberg.types.Types.NestedField.optional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assumptions.assumeThat; import java.util.Arrays; import java.util.Collections; @@ -35,8 +37,6 @@ import org.apache.iceberg.hive.HiveVersion; import org.apache.iceberg.mr.hive.serde.objectinspector.IcebergObjectInspector; import org.apache.iceberg.types.Types; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; public class TestDeserializer { @@ -74,7 +74,7 @@ public void testSchemaDeserialize() { Record actual = deserializer.deserialize(new Object[] {new LongWritable(1L), new Text("Bob")}); - Assertions.assertThat(actual).isEqualTo(expected); + assertThat(actual).isEqualTo(expected); } @Test @@ -92,7 +92,7 @@ public void testStructDeserialize() { Record actual = deserializer.deserialize(new Object[] {new LongWritable(1L), new Text("Bob")}); - Assertions.assertThat(actual).isEqualTo(expected); + assertThat(actual).isEqualTo(expected); } @Test @@ -127,7 +127,7 @@ public void testMapDeserialize() { Object[] data = new Object[] {map}; Record actual = deserializer.deserialize(data); - Assertions.assertThat(actual).isEqualTo(expected); + assertThat(actual).isEqualTo(expected); } @Test @@ -155,13 +155,13 @@ public void testListDeserialize() { Object[] data = new Object[] {new Object[] {new LongWritable(1L)}}; Record actual = deserializer.deserialize(data); - Assertions.assertThat(actual).isEqualTo(expected); + assertThat(actual).isEqualTo(expected); } @Test public void testDeserializeEverySupportedType() { - Assumptions.assumeFalse( - HiveVersion.min(HiveVersion.HIVE_3), "No test yet for Hive3 (Date/Timestamp creation)"); + assumeThat(HiveVersion.min(HiveVersion.HIVE_3)) + .as("No test yet for Hive3 (Date/Timestamp creation)"); Deserializer deserializer = new Deserializer.Builder() @@ -196,9 +196,9 @@ public void testNullDeserialize() { Record actual = deserializer.deserialize(nulls); - Assertions.assertThat(actual).isEqualTo(expected); + assertThat(actual).isEqualTo(expected); // Check null record as well - Assertions.assertThat(deserializer.deserialize(null)).isNull(); + assertThat(deserializer.deserialize(null)).isNull(); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergFilterFactory.java b/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergFilterFactory.java index f05a2a806c6c..121e2c8b6d8a 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergFilterFactory.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergFilterFactory.java @@ -18,6 +18,8 @@ */ package org.apache.iceberg.mr.hive; +import static org.assertj.core.api.Assertions.assertThat; + import java.math.BigDecimal; import java.sql.Date; import java.sql.Timestamp; @@ -80,12 +82,10 @@ public void testNotEqualsOperand() { UnboundPredicate childExpressionActual = (UnboundPredicate) actual.child(); UnboundPredicate childExpressionExpected = Expressions.equal("salary", 3000L); - Assertions.assertThat(expected.op()).isEqualTo(actual.op()); - Assertions.assertThat(expected.child().op()).isEqualTo(actual.child().op()); - Assertions.assertThat(childExpressionExpected.ref().name()) - .isEqualTo(childExpressionActual.ref().name()); - Assertions.assertThat(childExpressionExpected.literal()) - .isEqualTo(childExpressionActual.literal()); + assertThat(expected.op()).isEqualTo(actual.op()); + assertThat(expected.child().op()).isEqualTo(actual.child().op()); + assertThat(childExpressionExpected.ref().name()).isEqualTo(childExpressionActual.ref().name()); + assertThat(childExpressionExpected.literal()).isEqualTo(childExpressionActual.literal()); } @Test @@ -98,9 +98,9 @@ public void testLessThanOperand() { UnboundPredicate actual = (UnboundPredicate) HiveIcebergFilterFactory.generateFilterExpression(arg); - Assertions.assertThat(expected.op()).isEqualTo(actual.op()); - Assertions.assertThat(expected.literal()).isEqualTo(actual.literal()); - Assertions.assertThat(expected.ref().name()).isEqualTo(actual.ref().name()); + assertThat(expected.op()).isEqualTo(actual.op()); + assertThat(expected.literal()).isEqualTo(actual.literal()); + assertThat(expected.ref().name()).isEqualTo(actual.ref().name()); } @Test @@ -126,9 +126,9 @@ public void testInOperand() { UnboundPredicate actual = (UnboundPredicate) HiveIcebergFilterFactory.generateFilterExpression(arg); - Assertions.assertThat(expected.op()).isEqualTo(actual.op()); - Assertions.assertThat(expected.literals()).isEqualTo(actual.literals()); - Assertions.assertThat(expected.ref().name()).isEqualTo(actual.ref().name()); + assertThat(expected.op()).isEqualTo(actual.op()); + assertThat(expected.literals()).isEqualTo(actual.literals()); + assertThat(expected.ref().name()).isEqualTo(actual.ref().name()); } @Test @@ -144,9 +144,9 @@ public void testBetweenOperand() { Expressions.lessThanOrEqual("salary", 3000L)); And actual = (And) HiveIcebergFilterFactory.generateFilterExpression(arg); - Assertions.assertThat(expected.op()).isEqualTo(actual.op()); - Assertions.assertThat(expected.left().op()).isEqualTo(actual.left().op()); - Assertions.assertThat(expected.right().op()).isEqualTo(actual.right().op()); + assertThat(expected.op()).isEqualTo(actual.op()); + assertThat(expected.left().op()).isEqualTo(actual.left().op()); + assertThat(expected.right().op()).isEqualTo(actual.right().op()); } @Test @@ -173,8 +173,8 @@ public void testIsNullOperand() { UnboundPredicate actual = (UnboundPredicate) HiveIcebergFilterFactory.generateFilterExpression(arg); - Assertions.assertThat(expected.op()).isEqualTo(actual.op()); - Assertions.assertThat(expected.ref().name()).isEqualTo(actual.ref().name()); + assertThat(expected.op()).isEqualTo(actual.op()); + assertThat(expected.ref().name()).isEqualTo(actual.ref().name()); } @Test @@ -193,9 +193,9 @@ public void testAndOperand() { Expressions.and(Expressions.equal("salary", 3000L), Expressions.equal("salary", 4000L)); And actual = (And) HiveIcebergFilterFactory.generateFilterExpression(arg); - Assertions.assertThat(expected.op()).isEqualTo(actual.op()); - Assertions.assertThat(expected.left().op()).isEqualTo(actual.left().op()); - Assertions.assertThat(expected.right().op()).isEqualTo(actual.right().op()); + assertThat(expected.op()).isEqualTo(actual.op()); + assertThat(expected.left().op()).isEqualTo(actual.left().op()); + assertThat(expected.right().op()).isEqualTo(actual.right().op()); } @Test @@ -213,9 +213,9 @@ public void testOrOperand() { (Or) Expressions.or(Expressions.equal("salary", 3000L), Expressions.equal("salary", 4000L)); Or actual = (Or) HiveIcebergFilterFactory.generateFilterExpression(arg); - Assertions.assertThat(expected.op()).isEqualTo(actual.op()); - Assertions.assertThat(expected.left().op()).isEqualTo(actual.left().op()); - Assertions.assertThat(expected.right().op()).isEqualTo(actual.right().op()); + assertThat(expected.op()).isEqualTo(actual.op()); + assertThat(expected.left().op()).isEqualTo(actual.left().op()); + assertThat(expected.right().op()).isEqualTo(actual.right().op()); } @Test @@ -308,9 +308,9 @@ public void testDecimalType() { } private void assertPredicatesMatch(UnboundPredicate expected, UnboundPredicate actual) { - Assertions.assertThat(actual.op()).isEqualTo(expected.op()); - Assertions.assertThat(actual.literal()).isEqualTo(expected.literal()); - Assertions.assertThat(actual.ref().name()).isEqualTo(expected.ref().name()); + assertThat(actual.op()).isEqualTo(expected.op()); + assertThat(actual.literal()).isEqualTo(expected.literal()); + assertThat(actual.ref().name()).isEqualTo(expected.ref().name()); } private static class MockSearchArgument implements SearchArgument { diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergOutputCommitter.java b/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergOutputCommitter.java index 1b79aa9af1d1..8b8e209144fa 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergOutputCommitter.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergOutputCommitter.java @@ -20,6 +20,7 @@ import static org.apache.iceberg.mr.hive.HiveIcebergRecordWriter.getWriters; import static org.apache.iceberg.types.Types.NestedField.required; +import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import java.nio.file.Path; @@ -79,7 +80,7 @@ public class TestHiveIcebergOutputCommitter { private static final PartitionSpec PARTITIONED_SPEC = PartitionSpec.builderFor(CUSTOMER_SCHEMA).bucket("customer_id", 3).build(); - @TempDir public Path temp; + @TempDir private Path temp; @Test public void testNeedsTaskCommit() { @@ -90,8 +91,7 @@ public void testNeedsTaskCommit() { mapOnlyJobConf.setNumReduceTasks(0); // Map only job should commit map tasks - Assertions.assertThat( - committer.needsTaskCommit(new TaskAttemptContextImpl(mapOnlyJobConf, MAP_TASK_ID))) + assertThat(committer.needsTaskCommit(new TaskAttemptContextImpl(mapOnlyJobConf, MAP_TASK_ID))) .isTrue(); JobConf mapReduceJobConf = new JobConf(); @@ -99,10 +99,9 @@ public void testNeedsTaskCommit() { mapReduceJobConf.setNumReduceTasks(10); // MapReduce job should not commit map tasks, but should commit reduce tasks - Assertions.assertThat( - committer.needsTaskCommit(new TaskAttemptContextImpl(mapReduceJobConf, MAP_TASK_ID))) + assertThat(committer.needsTaskCommit(new TaskAttemptContextImpl(mapReduceJobConf, MAP_TASK_ID))) .isFalse(); - Assertions.assertThat( + assertThat( committer.needsTaskCommit(new TaskAttemptContextImpl(mapReduceJobConf, REDUCE_TASK_ID))) .isTrue(); } @@ -211,14 +210,14 @@ public void writerIsClosedAfterTaskCommitFailure() throws IOException { .isInstanceOf(RuntimeException.class) .hasMessage(exceptionMessage); - Assertions.assertThat(argumentCaptor.getAllValues().size()).isEqualTo(1); + assertThat(argumentCaptor.getAllValues()).hasSize(1); TaskAttemptID capturedId = TezUtil.taskAttemptWrapper(argumentCaptor.getValue().getTaskAttemptID()); // writer is still in the map after commitTask failure - Assertions.assertThat(getWriters(capturedId)).isNotNull(); + assertThat(getWriters(capturedId)).isNotNull(); failingCommitter.abortTask(new TaskAttemptContextImpl(conf, capturedId)); // abortTask succeeds and removes writer - Assertions.assertThat(getWriters(capturedId)).isNull(); + assertThat(getWriters(capturedId)).isNull(); } private Table table(String location, boolean partitioned) { diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergSerDe.java b/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergSerDe.java index d78ef5f3d820..919230a9fbd9 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergSerDe.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergSerDe.java @@ -19,6 +19,7 @@ package org.apache.iceberg.mr.hive; import static org.apache.iceberg.types.Types.NestedField.required; +import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; @@ -35,7 +36,6 @@ import org.apache.iceberg.mr.hive.serde.objectinspector.IcebergObjectInspector; import org.apache.iceberg.mr.mapred.Container; import org.apache.iceberg.types.Types; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -44,12 +44,12 @@ public class TestHiveIcebergSerDe { private static final Schema schema = new Schema(required(1, "string_field", Types.StringType.get())); - @TempDir public Path tmp; + @TempDir private Path tmp; @Test public void testInitialize() throws IOException, SerDeException { File location = tmp.toFile(); - Assertions.assertThat(location.delete()).isTrue(); + assertThat(location.delete()).isTrue(); Configuration conf = new Configuration(); @@ -63,8 +63,7 @@ public void testInitialize() throws IOException, SerDeException { HiveIcebergSerDe serDe = new HiveIcebergSerDe(); serDe.initialize(conf, properties); - Assertions.assertThat(serDe.getObjectInspector()) - .isEqualTo(IcebergObjectInspector.create(schema)); + assertThat(serDe.getObjectInspector()).isEqualTo(IcebergObjectInspector.create(schema)); } @Test @@ -75,6 +74,6 @@ public void testDeserialize() { Container container = new Container<>(); container.set(record); - Assertions.assertThat(serDe.deserialize(container)).isEqualTo(record); + assertThat(serDe.deserialize(container)).isEqualTo(record); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergBinaryObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergBinaryObjectInspector.java index d6873f25cb11..87fe4208c964 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergBinaryObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergBinaryObjectInspector.java @@ -18,13 +18,14 @@ */ package org.apache.iceberg.mr.hive.serde.objectinspector; +import static org.assertj.core.api.Assertions.assertThat; + import java.nio.ByteBuffer; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.BinaryObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; import org.apache.hadoop.io.BytesWritable; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergBinaryObjectInspector { @@ -33,42 +34,40 @@ public class TestIcebergBinaryObjectInspector { public void testIcebergByteBufferObjectInspector() { BinaryObjectInspector oi = IcebergBinaryObjectInspector.get(); - Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); - Assertions.assertThat(oi.getPrimitiveCategory()) + assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); + assertThat(oi.getPrimitiveCategory()) .isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.BINARY); - Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.binaryTypeInfo); - Assertions.assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.binaryTypeInfo.getTypeName()); + assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.binaryTypeInfo); + assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.binaryTypeInfo.getTypeName()); - Assertions.assertThat(oi.getJavaPrimitiveClass()).isEqualTo(byte[].class); - Assertions.assertThat(oi.getPrimitiveWritableClass()).isEqualTo(BytesWritable.class); + assertThat(oi.getJavaPrimitiveClass()).isEqualTo(byte[].class); + assertThat(oi.getPrimitiveWritableClass()).isEqualTo(BytesWritable.class); - Assertions.assertThat(oi.copyObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveJavaObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveWritableObject(null)).isNull(); + assertThat(oi.copyObject(null)).isNull(); + assertThat(oi.getPrimitiveJavaObject(null)).isNull(); + assertThat(oi.getPrimitiveWritableObject(null)).isNull(); byte[] bytes = new byte[] {0, 1, 2, 3}; ByteBuffer buffer = ByteBuffer.wrap(bytes); - Assertions.assertThat(oi.getPrimitiveJavaObject(buffer)).isEqualTo(bytes); - Assertions.assertThat(oi.getPrimitiveWritableObject(buffer)) - .isEqualTo(new BytesWritable(bytes)); + assertThat(oi.getPrimitiveJavaObject(buffer)).isEqualTo(bytes); + assertThat(oi.getPrimitiveWritableObject(buffer)).isEqualTo(new BytesWritable(bytes)); ByteBuffer slice = ByteBuffer.wrap(bytes, 1, 2).slice(); - Assertions.assertThat(oi.getPrimitiveJavaObject(slice)).isEqualTo(new byte[] {1, 2}); - Assertions.assertThat(oi.getPrimitiveWritableObject(slice)) + assertThat(oi.getPrimitiveJavaObject(slice)).isEqualTo(new byte[] {1, 2}); + assertThat(oi.getPrimitiveWritableObject(slice)) .isEqualTo(new BytesWritable(new byte[] {1, 2})); slice.position(1); - Assertions.assertThat(oi.getPrimitiveJavaObject(slice)).isEqualTo(new byte[] {2}); - Assertions.assertThat(oi.getPrimitiveWritableObject(slice)) - .isEqualTo(new BytesWritable(new byte[] {2})); + assertThat(oi.getPrimitiveJavaObject(slice)).isEqualTo(new byte[] {2}); + assertThat(oi.getPrimitiveWritableObject(slice)).isEqualTo(new BytesWritable(new byte[] {2})); byte[] copy = (byte[]) oi.copyObject(bytes); - Assertions.assertThat(copy).isEqualTo(bytes); - Assertions.assertThat(copy).isNotSameAs(bytes); + assertThat(copy).isEqualTo(bytes); + assertThat(copy).isNotSameAs(bytes); - Assertions.assertThat(oi.preferWritable()).isFalse(); + assertThat(oi.preferWritable()).isFalse(); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergDateObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergDateObjectInspector.java index e620165d9a36..6e03fae861f9 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergDateObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergDateObjectInspector.java @@ -18,6 +18,8 @@ */ package org.apache.iceberg.mr.hive.serde.objectinspector; +import static org.assertj.core.api.Assertions.assertThat; + import java.sql.Date; import java.time.LocalDate; import org.apache.hadoop.hive.serde2.io.DateWritable; @@ -25,7 +27,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.DateObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergDateObjectInspector { @@ -34,31 +35,31 @@ public class TestIcebergDateObjectInspector { public void testIcebergDateObjectInspector() { DateObjectInspector oi = IcebergDateObjectInspector.get(); - Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); - Assertions.assertThat(oi.getPrimitiveCategory()) + assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); + assertThat(oi.getPrimitiveCategory()) .isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.DATE); - Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.dateTypeInfo); - Assertions.assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.dateTypeInfo.getTypeName()); + assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.dateTypeInfo); + assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.dateTypeInfo.getTypeName()); - Assertions.assertThat(oi.getJavaPrimitiveClass()).isEqualTo(Date.class); - Assertions.assertThat(oi.getPrimitiveWritableClass()).isEqualTo(DateWritable.class); + assertThat(oi.getJavaPrimitiveClass()).isEqualTo(Date.class); + assertThat(oi.getPrimitiveWritableClass()).isEqualTo(DateWritable.class); - Assertions.assertThat(oi.copyObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveJavaObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveWritableObject(null)).isNull(); + assertThat(oi.copyObject(null)).isNull(); + assertThat(oi.getPrimitiveJavaObject(null)).isNull(); + assertThat(oi.getPrimitiveWritableObject(null)).isNull(); LocalDate local = LocalDate.of(2020, 1, 1); Date date = Date.valueOf("2020-01-01"); - Assertions.assertThat(oi.getPrimitiveJavaObject(local)).isEqualTo(date); - Assertions.assertThat(oi.getPrimitiveWritableObject(local)).isEqualTo(new DateWritable(date)); + assertThat(oi.getPrimitiveJavaObject(local)).isEqualTo(date); + assertThat(oi.getPrimitiveWritableObject(local)).isEqualTo(new DateWritable(date)); Date copy = (Date) oi.copyObject(date); - Assertions.assertThat(copy).isEqualTo(date); - Assertions.assertThat(copy).isNotSameAs(date); + assertThat(copy).isEqualTo(date); + assertThat(copy).isNotSameAs(date); - Assertions.assertThat(oi.preferWritable()).isFalse(); + assertThat(oi.preferWritable()).isFalse(); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergDecimalObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergDecimalObjectInspector.java index 27e1e0088f9d..58d43e3d7047 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergDecimalObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergDecimalObjectInspector.java @@ -18,6 +18,8 @@ */ package org.apache.iceberg.mr.hive.serde.objectinspector; +import static org.assertj.core.api.Assertions.assertThat; + import java.math.BigDecimal; import org.apache.hadoop.hive.common.type.HiveDecimal; import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; @@ -26,7 +28,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveDecimalObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergDecimalObjectInspector { @@ -35,44 +36,44 @@ public class TestIcebergDecimalObjectInspector { public void testCache() { HiveDecimalObjectInspector oi = IcebergDecimalObjectInspector.get(38, 18); - Assertions.assertThat(IcebergDecimalObjectInspector.get(38, 18)).isSameAs(oi); - Assertions.assertThat(IcebergDecimalObjectInspector.get(28, 18)).isNotSameAs(oi); - Assertions.assertThat(IcebergDecimalObjectInspector.get(38, 28)).isNotSameAs(oi); + assertThat(IcebergDecimalObjectInspector.get(38, 18)).isSameAs(oi); + assertThat(IcebergDecimalObjectInspector.get(28, 18)).isNotSameAs(oi); + assertThat(IcebergDecimalObjectInspector.get(38, 28)).isNotSameAs(oi); } @Test public void testIcebergDecimalObjectInspector() { HiveDecimalObjectInspector oi = IcebergDecimalObjectInspector.get(38, 18); - Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); - Assertions.assertThat(oi.getPrimitiveCategory()) + assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); + assertThat(oi.getPrimitiveCategory()) .isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.DECIMAL); - Assertions.assertThat(oi.getTypeInfo()).isEqualTo(new DecimalTypeInfo(38, 18)); - Assertions.assertThat(oi.getTypeName()) + assertThat(oi.getTypeInfo()).isEqualTo(new DecimalTypeInfo(38, 18)); + assertThat(oi.getTypeName()) .isEqualTo(TypeInfoFactory.decimalTypeInfo.getTypeName(), oi.getTypeName()); - Assertions.assertThat(oi.precision()).isEqualTo(38); - Assertions.assertThat(oi.scale()).isEqualTo(18); + assertThat(oi.precision()).isEqualTo(38); + assertThat(oi.scale()).isEqualTo(18); - Assertions.assertThat(oi.getJavaPrimitiveClass()).isEqualTo(HiveDecimal.class); - Assertions.assertThat(oi.getPrimitiveWritableClass()).isEqualTo(HiveDecimalWritable.class); + assertThat(oi.getJavaPrimitiveClass()).isEqualTo(HiveDecimal.class); + assertThat(oi.getPrimitiveWritableClass()).isEqualTo(HiveDecimalWritable.class); - Assertions.assertThat(oi.copyObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveJavaObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveWritableObject(null)).isNull(); + assertThat(oi.copyObject(null)).isNull(); + assertThat(oi.getPrimitiveJavaObject(null)).isNull(); + assertThat(oi.getPrimitiveWritableObject(null)).isNull(); HiveDecimal one = HiveDecimal.create(BigDecimal.ONE); - Assertions.assertThat(oi.getPrimitiveJavaObject(BigDecimal.ONE)).isEqualTo(one); - Assertions.assertThat(oi.getPrimitiveWritableObject(BigDecimal.ONE)) + assertThat(oi.getPrimitiveJavaObject(BigDecimal.ONE)).isEqualTo(one); + assertThat(oi.getPrimitiveWritableObject(BigDecimal.ONE)) .isEqualTo(new HiveDecimalWritable(one)); HiveDecimal copy = (HiveDecimal) oi.copyObject(one); - Assertions.assertThat(copy).isEqualTo(one); - Assertions.assertThat(copy).isNotSameAs(one); + assertThat(copy).isEqualTo(one); + assertThat(copy).isNotSameAs(one); - Assertions.assertThat(oi.preferWritable()).isFalse(); + assertThat(oi.preferWritable()).isFalse(); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergFixedObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergFixedObjectInspector.java index 0c98bbd6b089..7a8450f6852f 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergFixedObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergFixedObjectInspector.java @@ -18,11 +18,12 @@ */ package org.apache.iceberg.mr.hive.serde.objectinspector; +import static org.assertj.core.api.Assertions.assertThat; + import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; import org.apache.hadoop.io.BytesWritable; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergFixedObjectInspector { @@ -31,33 +32,33 @@ public class TestIcebergFixedObjectInspector { public void testIcebergFixedObjectInspector() { IcebergFixedObjectInspector oi = IcebergFixedObjectInspector.get(); - Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); - Assertions.assertThat(oi.getPrimitiveCategory()) + assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); + assertThat(oi.getPrimitiveCategory()) .isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.BINARY); - Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.binaryTypeInfo); - Assertions.assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.binaryTypeInfo.getTypeName()); + assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.binaryTypeInfo); + assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.binaryTypeInfo.getTypeName()); - Assertions.assertThat(oi.getJavaPrimitiveClass()).isEqualTo(byte[].class); - Assertions.assertThat(oi.getPrimitiveWritableClass()).isEqualTo(BytesWritable.class); + assertThat(oi.getJavaPrimitiveClass()).isEqualTo(byte[].class); + assertThat(oi.getPrimitiveWritableClass()).isEqualTo(BytesWritable.class); - Assertions.assertThat(oi.copyObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveJavaObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveWritableObject(null)).isNull(); - Assertions.assertThat(oi.convert(null)).isNull(); + assertThat(oi.copyObject(null)).isNull(); + assertThat(oi.getPrimitiveJavaObject(null)).isNull(); + assertThat(oi.getPrimitiveWritableObject(null)).isNull(); + assertThat(oi.convert(null)).isNull(); byte[] bytes = new byte[] {0, 1}; BytesWritable bytesWritable = new BytesWritable(bytes); - Assertions.assertThat(oi.getPrimitiveJavaObject(bytes)).isEqualTo(bytes); - Assertions.assertThat(oi.getPrimitiveWritableObject(bytes)).isEqualTo(bytesWritable); - Assertions.assertThat(oi.convert(bytes)).isEqualTo(bytes); + assertThat(oi.getPrimitiveJavaObject(bytes)).isEqualTo(bytes); + assertThat(oi.getPrimitiveWritableObject(bytes)).isEqualTo(bytesWritable); + assertThat(oi.convert(bytes)).isEqualTo(bytes); byte[] copy = (byte[]) oi.copyObject(bytes); - Assertions.assertThat(copy).isEqualTo(bytes); - Assertions.assertThat(copy).isNotSameAs(bytes); + assertThat(copy).isEqualTo(bytes); + assertThat(copy).isNotSameAs(bytes); - Assertions.assertThat(oi.preferWritable()).isFalse(); + assertThat(oi.preferWritable()).isFalse(); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergObjectInspector.java index f05cd4af6f5a..c2646376890c 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergObjectInspector.java @@ -19,6 +19,7 @@ package org.apache.iceberg.mr.hive.serde.objectinspector; import static org.apache.iceberg.types.Types.NestedField.required; +import static org.assertj.core.api.Assertions.assertThat; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory; @@ -31,7 +32,6 @@ import org.apache.iceberg.hive.HiveVersion; import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; import org.apache.iceberg.types.Types; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergObjectInspector { @@ -74,166 +74,161 @@ public class TestIcebergObjectInspector { @Test public void testIcebergObjectInspector() { ObjectInspector oi = IcebergObjectInspector.create(schema); - Assertions.assertThat(oi).isNotNull(); - Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.STRUCT); + assertThat(oi).isNotNull(); + assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.STRUCT); StructObjectInspector soi = (StructObjectInspector) oi; // binary StructField binaryField = soi.getStructFieldRef("binary_field"); - Assertions.assertThat(binaryField.getFieldID()).isEqualTo(1); - Assertions.assertThat(binaryField.getFieldName()).isEqualTo("binary_field"); - Assertions.assertThat(binaryField.getFieldComment()).isEqualTo("binary comment"); - Assertions.assertThat(binaryField.getFieldObjectInspector()) - .isEqualTo(IcebergBinaryObjectInspector.get()); + assertThat(binaryField.getFieldID()).isEqualTo(1); + assertThat(binaryField.getFieldName()).isEqualTo("binary_field"); + assertThat(binaryField.getFieldComment()).isEqualTo("binary comment"); + assertThat(binaryField.getFieldObjectInspector()).isEqualTo(IcebergBinaryObjectInspector.get()); // boolean StructField booleanField = soi.getStructFieldRef("boolean_field"); - Assertions.assertThat(booleanField.getFieldID()).isEqualTo(2); - Assertions.assertThat(booleanField.getFieldName()).isEqualTo("boolean_field"); - Assertions.assertThat(booleanField.getFieldComment()).isEqualTo("boolean comment"); - Assertions.assertThat(booleanField.getFieldObjectInspector()) + assertThat(booleanField.getFieldID()).isEqualTo(2); + assertThat(booleanField.getFieldName()).isEqualTo("boolean_field"); + assertThat(booleanField.getFieldComment()).isEqualTo("boolean comment"); + assertThat(booleanField.getFieldObjectInspector()) .isEqualTo(getPrimitiveObjectInspector(boolean.class)); // date StructField dateField = soi.getStructFieldRef("date_field"); - Assertions.assertThat(dateField.getFieldID()).isEqualTo(3); - Assertions.assertThat(dateField.getFieldName()).isEqualTo("date_field"); - Assertions.assertThat(dateField.getFieldComment()).isEqualTo("date comment"); + assertThat(dateField.getFieldID()).isEqualTo(3); + assertThat(dateField.getFieldName()).isEqualTo("date_field"); + assertThat(dateField.getFieldComment()).isEqualTo("date comment"); if (HiveVersion.min(HiveVersion.HIVE_3)) { - Assertions.assertThat(dateField.getFieldObjectInspector().getClass().getName()) + assertThat(dateField.getFieldObjectInspector().getClass().getName()) .isEqualTo( "org.apache.iceberg.mr.hive.serde.objectinspector.IcebergDateObjectInspectorHive3"); } else { - Assertions.assertThat(dateField.getFieldObjectInspector().getClass().getName()) + assertThat(dateField.getFieldObjectInspector().getClass().getName()) .isEqualTo("org.apache.iceberg.mr.hive.serde.objectinspector.IcebergDateObjectInspector"); } // decimal StructField decimalField = soi.getStructFieldRef("decimal_field"); - Assertions.assertThat(decimalField.getFieldID()).isEqualTo(4); - Assertions.assertThat(decimalField.getFieldName()).isEqualTo("decimal_field"); - Assertions.assertThat(decimalField.getFieldComment()).isEqualTo("decimal comment"); - Assertions.assertThat(decimalField.getFieldObjectInspector()) + assertThat(decimalField.getFieldID()).isEqualTo(4); + assertThat(decimalField.getFieldName()).isEqualTo("decimal_field"); + assertThat(decimalField.getFieldComment()).isEqualTo("decimal comment"); + assertThat(decimalField.getFieldObjectInspector()) .isEqualTo(IcebergDecimalObjectInspector.get(38, 18)); // double StructField doubleField = soi.getStructFieldRef("double_field"); - Assertions.assertThat(doubleField.getFieldID()).isEqualTo(5); - Assertions.assertThat(doubleField.getFieldName()).isEqualTo("double_field"); - Assertions.assertThat(doubleField.getFieldComment()).isEqualTo("double comment"); - Assertions.assertThat(doubleField.getFieldObjectInspector()) + assertThat(doubleField.getFieldID()).isEqualTo(5); + assertThat(doubleField.getFieldName()).isEqualTo("double_field"); + assertThat(doubleField.getFieldComment()).isEqualTo("double comment"); + assertThat(doubleField.getFieldObjectInspector()) .isEqualTo(getPrimitiveObjectInspector(double.class)); // fixed StructField fixedField = soi.getStructFieldRef("fixed_field"); - Assertions.assertThat(fixedField.getFieldID()).isEqualTo(6); - Assertions.assertThat(fixedField.getFieldName()).isEqualTo("fixed_field"); - Assertions.assertThat(fixedField.getFieldComment()).isEqualTo("fixed comment"); - Assertions.assertThat(fixedField.getFieldObjectInspector()) - .isEqualTo(IcebergFixedObjectInspector.get()); + assertThat(fixedField.getFieldID()).isEqualTo(6); + assertThat(fixedField.getFieldName()).isEqualTo("fixed_field"); + assertThat(fixedField.getFieldComment()).isEqualTo("fixed comment"); + assertThat(fixedField.getFieldObjectInspector()).isEqualTo(IcebergFixedObjectInspector.get()); // float StructField floatField = soi.getStructFieldRef("float_field"); - Assertions.assertThat(floatField.getFieldID()).isEqualTo(7); - Assertions.assertThat(floatField.getFieldName()).isEqualTo("float_field"); - Assertions.assertThat(floatField.getFieldComment()).isEqualTo("float comment"); - Assertions.assertThat(floatField.getFieldObjectInspector()) + assertThat(floatField.getFieldID()).isEqualTo(7); + assertThat(floatField.getFieldName()).isEqualTo("float_field"); + assertThat(floatField.getFieldComment()).isEqualTo("float comment"); + assertThat(floatField.getFieldObjectInspector()) .isEqualTo(getPrimitiveObjectInspector(float.class)); // integer StructField integerField = soi.getStructFieldRef("integer_field"); - Assertions.assertThat(integerField.getFieldID()).isEqualTo(8); - Assertions.assertThat(integerField.getFieldName()).isEqualTo("integer_field"); - Assertions.assertThat(integerField.getFieldComment()).isEqualTo("integer comment"); - Assertions.assertThat(integerField.getFieldObjectInspector()) + assertThat(integerField.getFieldID()).isEqualTo(8); + assertThat(integerField.getFieldName()).isEqualTo("integer_field"); + assertThat(integerField.getFieldComment()).isEqualTo("integer comment"); + assertThat(integerField.getFieldObjectInspector()) .isEqualTo(getPrimitiveObjectInspector(int.class)); // long StructField longField = soi.getStructFieldRef("long_field"); - Assertions.assertThat(longField.getFieldID()).isEqualTo(9); - Assertions.assertThat(longField.getFieldName()).isEqualTo("long_field"); - Assertions.assertThat(longField.getFieldComment()).isEqualTo("long comment"); - Assertions.assertThat(longField.getFieldObjectInspector()) + assertThat(longField.getFieldID()).isEqualTo(9); + assertThat(longField.getFieldName()).isEqualTo("long_field"); + assertThat(longField.getFieldComment()).isEqualTo("long comment"); + assertThat(longField.getFieldObjectInspector()) .isEqualTo(getPrimitiveObjectInspector(long.class)); // string StructField stringField = soi.getStructFieldRef("string_field"); - Assertions.assertThat(stringField.getFieldID()).isEqualTo(10); - Assertions.assertThat(stringField.getFieldName()).isEqualTo("string_field"); - Assertions.assertThat(stringField.getFieldComment()).isEqualTo("string comment"); - Assertions.assertThat(stringField.getFieldObjectInspector()) + assertThat(stringField.getFieldID()).isEqualTo(10); + assertThat(stringField.getFieldName()).isEqualTo("string_field"); + assertThat(stringField.getFieldComment()).isEqualTo("string comment"); + assertThat(stringField.getFieldObjectInspector()) .isEqualTo(getPrimitiveObjectInspector(String.class)); // timestamp without tz StructField timestampField = soi.getStructFieldRef("timestamp_field"); - Assertions.assertThat(timestampField.getFieldID()).isEqualTo(11); - Assertions.assertThat(timestampField.getFieldName()).isEqualTo("timestamp_field"); - Assertions.assertThat(timestampField.getFieldComment()).isEqualTo("timestamp comment"); + assertThat(timestampField.getFieldID()).isEqualTo(11); + assertThat(timestampField.getFieldName()).isEqualTo("timestamp_field"); + assertThat(timestampField.getFieldComment()).isEqualTo("timestamp comment"); if (HiveVersion.min(HiveVersion.HIVE_3)) { - Assertions.assertThat(timestampField.getFieldObjectInspector().getClass().getSimpleName()) + assertThat(timestampField.getFieldObjectInspector().getClass().getSimpleName()) .isEqualTo("IcebergTimestampObjectInspectorHive3"); } else { - Assertions.assertThat(timestampField.getFieldObjectInspector()) + assertThat(timestampField.getFieldObjectInspector()) .isEqualTo(IcebergTimestampObjectInspector.get()); } // timestamp with tz StructField timestampTzField = soi.getStructFieldRef("timestamptz_field"); - Assertions.assertThat(timestampTzField.getFieldID()).isEqualTo(12); - Assertions.assertThat(timestampTzField.getFieldName()).isEqualTo("timestamptz_field"); - Assertions.assertThat(timestampTzField.getFieldComment()).isEqualTo("timestamptz comment"); + assertThat(timestampTzField.getFieldID()).isEqualTo(12); + assertThat(timestampTzField.getFieldName()).isEqualTo("timestamptz_field"); + assertThat(timestampTzField.getFieldComment()).isEqualTo("timestamptz comment"); if (HiveVersion.min(HiveVersion.HIVE_3)) { - Assertions.assertThat(timestampTzField.getFieldObjectInspector().getClass().getSimpleName()) + assertThat(timestampTzField.getFieldObjectInspector().getClass().getSimpleName()) .isEqualTo("IcebergTimestampWithZoneObjectInspectorHive3"); } else { - Assertions.assertThat(timestampTzField.getFieldObjectInspector()) + assertThat(timestampTzField.getFieldObjectInspector()) .isEqualTo(IcebergTimestampWithZoneObjectInspector.get()); } // UUID StructField uuidField = soi.getStructFieldRef("uuid_field"); - Assertions.assertThat(uuidField.getFieldID()).isEqualTo(13); - Assertions.assertThat(uuidField.getFieldName()).isEqualTo("uuid_field"); - Assertions.assertThat(uuidField.getFieldComment()).isEqualTo("uuid comment"); - Assertions.assertThat(uuidField.getFieldObjectInspector()) - .isEqualTo(IcebergUUIDObjectInspector.get()); + assertThat(uuidField.getFieldID()).isEqualTo(13); + assertThat(uuidField.getFieldName()).isEqualTo("uuid_field"); + assertThat(uuidField.getFieldComment()).isEqualTo("uuid comment"); + assertThat(uuidField.getFieldObjectInspector()).isEqualTo(IcebergUUIDObjectInspector.get()); // list StructField listField = soi.getStructFieldRef("list_field"); - Assertions.assertThat(listField.getFieldID()).isEqualTo(14); - Assertions.assertThat(listField.getFieldName()).isEqualTo("list_field"); - Assertions.assertThat(listField.getFieldComment()).isEqualTo("list comment"); - Assertions.assertThat(listField.getFieldObjectInspector()) - .isEqualTo(getListObjectInspector(String.class)); + assertThat(listField.getFieldID()).isEqualTo(14); + assertThat(listField.getFieldName()).isEqualTo("list_field"); + assertThat(listField.getFieldComment()).isEqualTo("list comment"); + assertThat(listField.getFieldObjectInspector()).isEqualTo(getListObjectInspector(String.class)); // map StructField mapField = soi.getStructFieldRef("map_field"); - Assertions.assertThat(mapField.getFieldID()).isEqualTo(16); - Assertions.assertThat(mapField.getFieldName()).isEqualTo("map_field"); - Assertions.assertThat(mapField.getFieldComment()).isEqualTo("map comment"); - Assertions.assertThat(mapField.getFieldObjectInspector()) + assertThat(mapField.getFieldID()).isEqualTo(16); + assertThat(mapField.getFieldName()).isEqualTo("map_field"); + assertThat(mapField.getFieldComment()).isEqualTo("map comment"); + assertThat(mapField.getFieldObjectInspector()) .isEqualTo(getMapObjectInspector(String.class, int.class)); // struct StructField structField = soi.getStructFieldRef("struct_field"); - Assertions.assertThat(structField.getFieldID()).isEqualTo(19); - Assertions.assertThat(structField.getFieldName()).isEqualTo("struct_field"); - Assertions.assertThat(structField.getFieldComment()).isEqualTo("struct comment"); + assertThat(structField.getFieldID()).isEqualTo(19); + assertThat(structField.getFieldName()).isEqualTo("struct_field"); + assertThat(structField.getFieldComment()).isEqualTo("struct comment"); ObjectInspector expectedObjectInspector = new IcebergRecordObjectInspector( (Types.StructType) schema.findType(19), ImmutableList.of(getPrimitiveObjectInspector(String.class))); - Assertions.assertThat(structField.getFieldObjectInspector()).isEqualTo(expectedObjectInspector); + assertThat(structField.getFieldObjectInspector()).isEqualTo(expectedObjectInspector); // time StructField timeField = soi.getStructFieldRef("time_field"); - Assertions.assertThat(timeField.getFieldID()).isEqualTo(21); - Assertions.assertThat(timeField.getFieldName()).isEqualTo("time_field"); - Assertions.assertThat(timeField.getFieldComment()).isEqualTo("time comment"); - Assertions.assertThat(timeField.getFieldObjectInspector()) - .isEqualTo(IcebergTimeObjectInspector.get()); + assertThat(timeField.getFieldID()).isEqualTo(21); + assertThat(timeField.getFieldName()).isEqualTo("time_field"); + assertThat(timeField.getFieldComment()).isEqualTo("time comment"); + assertThat(timeField.getFieldObjectInspector()).isEqualTo(IcebergTimeObjectInspector.get()); } private static ObjectInspector getPrimitiveObjectInspector(Class clazz) { diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergRecordObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergRecordObjectInspector.java index aa37c59faed6..d5824f8bd7d8 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergRecordObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergRecordObjectInspector.java @@ -19,6 +19,7 @@ package org.apache.iceberg.mr.hive.serde.objectinspector; import static org.apache.iceberg.types.Types.NestedField.required; +import static org.assertj.core.api.Assertions.assertThat; import org.apache.hadoop.hive.serde2.objectinspector.StructField; import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector; @@ -27,7 +28,6 @@ import org.apache.iceberg.data.Record; import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; import org.apache.iceberg.types.Types; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergRecordObjectInspector { @@ -47,23 +47,22 @@ public void testIcebergRecordObjectInspector() { Record innerRecord = record.get(1, Record.class); StructObjectInspector soi = (StructObjectInspector) IcebergObjectInspector.create(schema); - Assertions.assertThat(soi.getStructFieldsDataAsList(record)) + assertThat(soi.getStructFieldsDataAsList(record)) .isEqualTo(ImmutableList.of(record.get(0), record.get(1))); StructField integerField = soi.getStructFieldRef("integer_field"); - Assertions.assertThat(soi.getStructFieldData(record, integerField)).isEqualTo(record.get(0)); + assertThat(soi.getStructFieldData(record, integerField)).isEqualTo(record.get(0)); StructField structField = soi.getStructFieldRef("struct_field"); Object innerData = soi.getStructFieldData(record, structField); - Assertions.assertThat(innerData).isEqualTo(innerRecord); + assertThat(innerData).isEqualTo(innerRecord); StructObjectInspector innerSoi = (StructObjectInspector) structField.getFieldObjectInspector(); StructField stringField = innerSoi.getStructFieldRef("string_field"); - Assertions.assertThat(innerSoi.getStructFieldsDataAsList(innerRecord)) + assertThat(innerSoi.getStructFieldsDataAsList(innerRecord)) .isEqualTo(ImmutableList.of(innerRecord.get(0))); - Assertions.assertThat(innerSoi.getStructFieldData(innerData, stringField)) - .isEqualTo(innerRecord.get(0)); + assertThat(innerSoi.getStructFieldData(innerData, stringField)).isEqualTo(innerRecord.get(0)); } @Test @@ -77,8 +76,8 @@ public void testIcebergRecordObjectInspectorWithRowNull() { Types.StructType.of( Types.NestedField.required(3, "string_field", Types.StringType.get())))); StructObjectInspector soi = (StructObjectInspector) IcebergObjectInspector.create(schema); - Assertions.assertThat(soi.getStructFieldsDataAsList(null)).isNull(); + assertThat(soi.getStructFieldsDataAsList(null)).isNull(); StructField integerField = soi.getStructFieldRef("integer_field"); - Assertions.assertThat(soi.getStructFieldData(null, integerField)).isNull(); + assertThat(soi.getStructFieldData(null, integerField)).isNull(); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimeObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimeObjectInspector.java index e680f0ddec05..5af9ba341ebd 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimeObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimeObjectInspector.java @@ -18,12 +18,13 @@ */ package org.apache.iceberg.mr.hive.serde.objectinspector; +import static org.assertj.core.api.Assertions.assertThat; + import java.time.LocalTime; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; import org.apache.hadoop.io.Text; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergTimeObjectInspector { @@ -33,34 +34,34 @@ public void testIcebergTimeObjectInspector() { IcebergTimeObjectInspector oi = IcebergTimeObjectInspector.get(); - Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); - Assertions.assertThat(oi.getPrimitiveCategory()) + assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); + assertThat(oi.getPrimitiveCategory()) .isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.STRING); - Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.stringTypeInfo); - Assertions.assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.stringTypeInfo.getTypeName()); + assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.stringTypeInfo); + assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.stringTypeInfo.getTypeName()); - Assertions.assertThat(oi.getJavaPrimitiveClass()).isEqualTo(String.class); - Assertions.assertThat(oi.getPrimitiveWritableClass()).isEqualTo(Text.class); + assertThat(oi.getJavaPrimitiveClass()).isEqualTo(String.class); + assertThat(oi.getPrimitiveWritableClass()).isEqualTo(Text.class); - Assertions.assertThat(oi.copyObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveJavaObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveWritableObject(null)).isNull(); - Assertions.assertThat(oi.convert(null)).isNull(); + assertThat(oi.copyObject(null)).isNull(); + assertThat(oi.getPrimitiveJavaObject(null)).isNull(); + assertThat(oi.getPrimitiveWritableObject(null)).isNull(); + assertThat(oi.convert(null)).isNull(); LocalTime localTime = LocalTime.now(); String time = localTime.toString(); Text text = new Text(time); - Assertions.assertThat(oi.getPrimitiveJavaObject(text)).isEqualTo(time); - Assertions.assertThat(oi.getPrimitiveWritableObject(time)).isEqualTo(text); - Assertions.assertThat(oi.convert(time)).isEqualTo(localTime); + assertThat(oi.getPrimitiveJavaObject(text)).isEqualTo(time); + assertThat(oi.getPrimitiveWritableObject(time)).isEqualTo(text); + assertThat(oi.convert(time)).isEqualTo(localTime); Text copy = (Text) oi.copyObject(text); - Assertions.assertThat(copy).isEqualTo(text); - Assertions.assertThat(copy).isNotSameAs(text); + assertThat(copy).isEqualTo(text); + assertThat(copy).isNotSameAs(text); - Assertions.assertThat(oi.preferWritable()).isFalse(); + assertThat(oi.preferWritable()).isFalse(); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimestampObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimestampObjectInspector.java index fb89ffa91e22..ea40cc20420a 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimestampObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimestampObjectInspector.java @@ -18,13 +18,14 @@ */ package org.apache.iceberg.mr.hive.serde.objectinspector; +import static org.assertj.core.api.Assertions.assertThat; + import java.sql.Timestamp; import java.time.LocalDateTime; import org.apache.hadoop.hive.serde2.io.TimestampWritable; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergTimestampObjectInspector { @@ -33,36 +34,34 @@ public class TestIcebergTimestampObjectInspector { public void testIcebergTimestampObjectInspector() { IcebergTimestampObjectInspector oi = IcebergTimestampObjectInspector.get(); - Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); - Assertions.assertThat(oi.getPrimitiveCategory()) + assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); + assertThat(oi.getPrimitiveCategory()) .isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.TIMESTAMP); - Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.timestampTypeInfo); - Assertions.assertThat(oi.getTypeName()) - .isEqualTo(TypeInfoFactory.timestampTypeInfo.getTypeName()); + assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.timestampTypeInfo); + assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.timestampTypeInfo.getTypeName()); - Assertions.assertThat(oi.getJavaPrimitiveClass()).isEqualTo(Timestamp.class); - Assertions.assertThat(oi.getPrimitiveWritableClass()).isEqualTo(TimestampWritable.class); + assertThat(oi.getJavaPrimitiveClass()).isEqualTo(Timestamp.class); + assertThat(oi.getPrimitiveWritableClass()).isEqualTo(TimestampWritable.class); - Assertions.assertThat(oi.copyObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveJavaObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveWritableObject(null)).isNull(); - Assertions.assertThat(oi.convert(null)).isNull(); + assertThat(oi.copyObject(null)).isNull(); + assertThat(oi.getPrimitiveJavaObject(null)).isNull(); + assertThat(oi.getPrimitiveWritableObject(null)).isNull(); + assertThat(oi.convert(null)).isNull(); LocalDateTime local = LocalDateTime.of(2020, 1, 1, 12, 55, 30, 5560000); Timestamp ts = Timestamp.valueOf(local); - Assertions.assertThat(oi.getPrimitiveJavaObject(local)).isEqualTo(ts); - Assertions.assertThat(oi.getPrimitiveWritableObject(local)) - .isEqualTo(new TimestampWritable(ts)); + assertThat(oi.getPrimitiveJavaObject(local)).isEqualTo(ts); + assertThat(oi.getPrimitiveWritableObject(local)).isEqualTo(new TimestampWritable(ts)); Timestamp copy = (Timestamp) oi.copyObject(ts); - Assertions.assertThat(copy).isEqualTo(ts); - Assertions.assertThat(copy).isNotSameAs(ts); + assertThat(copy).isEqualTo(ts); + assertThat(copy).isNotSameAs(ts); - Assertions.assertThat(oi.preferWritable()).isFalse(); + assertThat(oi.preferWritable()).isFalse(); - Assertions.assertThat(oi.convert(ts)).isEqualTo(local); + assertThat(oi.convert(ts)).isEqualTo(local); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimestampWithZoneObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimestampWithZoneObjectInspector.java index 286695630ffd..1b16e6e02c0e 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimestampWithZoneObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergTimestampWithZoneObjectInspector.java @@ -18,6 +18,8 @@ */ package org.apache.iceberg.mr.hive.serde.objectinspector; +import static org.assertj.core.api.Assertions.assertThat; + import java.sql.Timestamp; import java.time.LocalDateTime; import java.time.OffsetDateTime; @@ -26,7 +28,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergTimestampWithZoneObjectInspector { @@ -35,42 +36,40 @@ public class TestIcebergTimestampWithZoneObjectInspector { public void testIcebergTimestampObjectInspectorWithUTCAdjustment() { IcebergTimestampWithZoneObjectInspector oi = IcebergTimestampWithZoneObjectInspector.get(); - Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); - Assertions.assertThat(oi.getPrimitiveCategory()) + assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); + assertThat(oi.getPrimitiveCategory()) .isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.TIMESTAMP); - Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.timestampTypeInfo); - Assertions.assertThat(oi.getTypeName()) - .isEqualTo(TypeInfoFactory.timestampTypeInfo.getTypeName()); + assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.timestampTypeInfo); + assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.timestampTypeInfo.getTypeName()); - Assertions.assertThat(oi.getJavaPrimitiveClass()).isEqualTo(Timestamp.class); - Assertions.assertThat(oi.getPrimitiveWritableClass()).isEqualTo(TimestampWritable.class); + assertThat(oi.getJavaPrimitiveClass()).isEqualTo(Timestamp.class); + assertThat(oi.getPrimitiveWritableClass()).isEqualTo(TimestampWritable.class); - Assertions.assertThat(oi.copyObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveJavaObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveWritableObject(null)).isNull(); - Assertions.assertThat(oi.convert(null)).isNull(); + assertThat(oi.copyObject(null)).isNull(); + assertThat(oi.getPrimitiveJavaObject(null)).isNull(); + assertThat(oi.getPrimitiveWritableObject(null)).isNull(); + assertThat(oi.convert(null)).isNull(); LocalDateTime local = LocalDateTime.of(2020, 1, 1, 16, 45, 33, 456000); OffsetDateTime offsetDateTime = OffsetDateTime.of(local, ZoneOffset.ofHours(-5)); Timestamp ts = Timestamp.from(offsetDateTime.toInstant()); - Assertions.assertThat(oi.getPrimitiveJavaObject(offsetDateTime)).isEqualTo(ts); - Assertions.assertThat(oi.getPrimitiveWritableObject(offsetDateTime)) - .isEqualTo(new TimestampWritable(ts)); + assertThat(oi.getPrimitiveJavaObject(offsetDateTime)).isEqualTo(ts); + assertThat(oi.getPrimitiveWritableObject(offsetDateTime)).isEqualTo(new TimestampWritable(ts)); Timestamp copy = (Timestamp) oi.copyObject(ts); - Assertions.assertThat(copy).isEqualTo(ts); - Assertions.assertThat(copy).isNotSameAs(ts); + assertThat(copy).isEqualTo(ts); + assertThat(copy).isNotSameAs(ts); - Assertions.assertThat(oi.preferWritable()).isFalse(); + assertThat(oi.preferWritable()).isFalse(); - Assertions.assertThat(oi.convert(ts)) + assertThat(oi.convert(ts)) .isEqualTo( OffsetDateTime.ofInstant(local.toInstant(ZoneOffset.ofHours(-5)), ZoneOffset.UTC)); - Assertions.assertThat(offsetDateTime.withOffsetSameInstant(ZoneOffset.UTC)) + assertThat(offsetDateTime.withOffsetSameInstant(ZoneOffset.UTC)) .isEqualTo(oi.convert(Timestamp.from(offsetDateTime.toInstant()))); } } diff --git a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergUUIDObjectInspector.java b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergUUIDObjectInspector.java index 4693d5ae6312..abc0c01ed8d1 100644 --- a/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergUUIDObjectInspector.java +++ b/mr/src/test/java/org/apache/iceberg/mr/hive/serde/objectinspector/TestIcebergUUIDObjectInspector.java @@ -18,12 +18,13 @@ */ package org.apache.iceberg.mr.hive.serde.objectinspector; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.UUID; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; import org.apache.hadoop.io.Text; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class TestIcebergUUIDObjectInspector { @@ -32,34 +33,34 @@ public class TestIcebergUUIDObjectInspector { public void testIcebergUUIDObjectInspector() { IcebergUUIDObjectInspector oi = IcebergUUIDObjectInspector.get(); - Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); - Assertions.assertThat(oi.getPrimitiveCategory()) + assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE); + assertThat(oi.getPrimitiveCategory()) .isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.STRING); - Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.stringTypeInfo); - Assertions.assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.stringTypeInfo.getTypeName()); + assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.stringTypeInfo); + assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.stringTypeInfo.getTypeName()); - Assertions.assertThat(oi.getJavaPrimitiveClass()).isEqualTo(String.class); - Assertions.assertThat(oi.getPrimitiveWritableClass()).isEqualTo(Text.class); + assertThat(oi.getJavaPrimitiveClass()).isEqualTo(String.class); + assertThat(oi.getPrimitiveWritableClass()).isEqualTo(Text.class); - Assertions.assertThat(oi.copyObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveJavaObject(null)).isNull(); - Assertions.assertThat(oi.getPrimitiveWritableObject(null)).isNull(); - Assertions.assertThat(oi.convert(null)).isNull(); + assertThat(oi.copyObject(null)).isNull(); + assertThat(oi.getPrimitiveJavaObject(null)).isNull(); + assertThat(oi.getPrimitiveWritableObject(null)).isNull(); + assertThat(oi.convert(null)).isNull(); UUID uuid = UUID.randomUUID(); String uuidStr = uuid.toString(); Text text = new Text(uuidStr); - Assertions.assertThat(oi.getPrimitiveJavaObject(text)).isEqualTo(uuidStr); - Assertions.assertThat(oi.getPrimitiveWritableObject(uuidStr)).isEqualTo(text); - Assertions.assertThat(oi.convert(uuidStr)).isEqualTo(uuid); + assertThat(oi.getPrimitiveJavaObject(text)).isEqualTo(uuidStr); + assertThat(oi.getPrimitiveWritableObject(uuidStr)).isEqualTo(text); + assertThat(oi.convert(uuidStr)).isEqualTo(uuid); Text copy = (Text) oi.copyObject(text); - Assertions.assertThat(copy).isEqualTo(text); - Assertions.assertThat(copy).isNotSameAs(text); + assertThat(copy).isEqualTo(text); + assertThat(copy).isNotSameAs(text); - Assertions.assertThat(oi.preferWritable()).isFalse(); + assertThat(oi.preferWritable()).isFalse(); } }