nastra commented on code in PR #9401:
URL: https://github.com/apache/iceberg/pull/9401#discussion_r1445272797
##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestNamespaceSQL.java:
##########
@@ -18,90 +18,131 @@
*/
package org.apache.iceberg.spark.sql;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assumptions.assumeThat;
+
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
+import org.apache.iceberg.Parameter;
+import org.apache.iceberg.Parameters;
import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableSet;
import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
-import org.apache.iceberg.spark.SparkCatalogTestBase;
+import org.apache.iceberg.spark.CatalogTestBase;
+import org.apache.iceberg.spark.SparkCatalogConfig;
import org.assertj.core.api.Assertions;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.TestTemplate;
-public class TestNamespaceSQL extends SparkCatalogTestBase {
+public class TestNamespaceSQL extends CatalogTestBase {
private static final Namespace NS = Namespace.of("db");
- private final String fullNamespace;
- private final boolean isHadoopCatalog;
-
- public TestNamespaceSQL(String catalogName, String implementation,
Map<String, String> config) {
- super(catalogName, implementation, config);
- this.fullNamespace = ("spark_catalog".equals(catalogName) ? "" :
catalogName + ".") + NS;
- this.isHadoopCatalog = "testhadoop".equals(catalogName);
+ @Parameter(index = 3)
+ private String fullNamespace;
+
+ @Parameter(index = 4)
+ private boolean isHadoopCatalog;
+
+ @Parameters(
+ name =
+ "catalogName = {0}, implementation = {1}, config = {2},
fullNameSpace = {3}, isHadoopCatalog = {4}")
+ protected static Object[][] parameters() {
+ return new Object[][] {
+ {
+ SparkCatalogConfig.HIVE.catalogName(),
+ SparkCatalogConfig.HIVE.implementation(),
+ SparkCatalogConfig.HIVE.properties(),
+ SparkCatalogConfig.HIVE.catalogName() + "." + NS.toString(),
+ false
+ },
+ {
+ SparkCatalogConfig.HADOOP.catalogName(),
+ SparkCatalogConfig.HADOOP.implementation(),
+ SparkCatalogConfig.HADOOP.properties(),
+ SparkCatalogConfig.HADOOP.catalogName() + "." + NS.toString(),
+ true
+ },
+ {
+ SparkCatalogConfig.SPARK.catalogName(),
+ SparkCatalogConfig.SPARK.implementation(),
+ SparkCatalogConfig.SPARK.properties(),
+ NS.toString(),
+ false
+ }
+ };
}
- @After
+ @AfterEach
public void cleanNamespaces() {
sql("DROP TABLE IF EXISTS %s.table", fullNamespace);
sql("DROP NAMESPACE IF EXISTS %s", fullNamespace);
}
- @Test
+ @TestTemplate
public void testCreateNamespace() {
- Assert.assertFalse(
- "Namespace should not already exist",
validationNamespaceCatalog.namespaceExists(NS));
+ assertThat(validationNamespaceCatalog.namespaceExists(NS))
+ .as("Namespace should not already exist")
+ .isFalse();
sql("CREATE NAMESPACE %s", fullNamespace);
- Assert.assertTrue("Namespace should exist",
validationNamespaceCatalog.namespaceExists(NS));
+ assertThat(validationNamespaceCatalog.namespaceExists(NS))
+ .as("Namespace should exist")
+ .isTrue();
}
- @Test
+ @TestTemplate
public void testDefaultNamespace() {
- Assume.assumeFalse("Hadoop has no default namespace configured",
isHadoopCatalog);
+ assumeThat(isHadoopCatalog).as("Hadoop has no default namespace
configured").isFalse();
sql("USE %s", catalogName);
Object[] current = Iterables.getOnlyElement(sql("SHOW CURRENT NAMESPACE"));
- Assert.assertEquals("Should use the current catalog", current[0],
catalogName);
- Assert.assertEquals("Should use the configured default namespace",
current[1], "default");
+ assertThat(catalogName).as("Should use the current
catalog").isEqualTo(current[0]);
Review Comment:
```suggestion
assertThat(current[0]).as("Should use the current
catalog").isEqualTo(catalogName);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]