### Question:
HiveCatalog extends BaseMetastoreCatalog implements Closeable, SupportsNamespaces { @Override public void createNamespace(Namespace namespace, Map<String, String> meta) { Preconditions.checkArgument( !namespace.isEmpty(), "Cannot create namespace with invalid name: %s", namespace); Preconditions.checkArgument(isValidateNamespace(namespace), "Cannot support multi part namespace in Hive MetaStore: %s", namespace); try { clients.run(client -> { client.createDatabase(convertToDatabase(namespace, meta)); return null; }); } catch (AlreadyExistsException e) { throw new org.apache.iceberg.exceptions.AlreadyExistsException(e, "Namespace '%s' already exists!", namespace); } catch (TException e) { throw new RuntimeException("Failed to create namespace " + namespace + " in Hive MataStore", e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException( "Interrupted in call to createDatabase(name) " + namespace + " in Hive MataStore", e); } } HiveCatalog(Configuration conf);  HiveCatalog(String name, String uri, int clientPoolSize, Configuration conf); @Override List<TableIdentifier> listTables(Namespace namespace); @Override boolean dropTable(TableIdentifier identifier, boolean purge); @Override void renameTable(TableIdentifier from, TableIdentifier originalTo); @Override void createNamespace(Namespace namespace, Map<String, String> meta); @Override List<Namespace> listNamespaces(Namespace namespace); @Override boolean dropNamespace(Namespace namespace); @Override boolean setProperties(Namespace namespace,  Map<String, String> properties); @Override boolean removeProperties(Namespace namespace,  Set<String> properties); @Override Map<String, String> loadNamespaceMetadata(Namespace namespace); @Override TableOperations newTableOps(TableIdentifier tableIdentifier); @Override void close();  }### Answer:
@Test public void testCreateNamespace() throws TException { Namespace namespace1 = Namespace.of("noLocation"); catalog.createNamespace(namespace1, meta); Database database1 = metastoreClient.getDatabase(namespace1.toString()); Assert.assertTrue(database1.getParameters().get("owner").equals("apache")); Assert.assertTrue(database1.getParameters().get("group").equals("iceberg")); Assert.assertEquals("There no same location for db and namespace", database1.getLocationUri(), defaultUri(namespace1)); AssertHelpers.assertThrows("Should fail to create when namespace already exist " + namespace1, AlreadyExistsException.class, "Namespace '" + namespace1 + "' already exists!", () -> { catalog.createNamespace(namespace1); }); ImmutableMap newMeta = ImmutableMap.<String, String>builder() .putAll(meta) .put("location", hiveLocalDir) .build(); Namespace namespace2 = Namespace.of("haveLocation"); catalog.createNamespace(namespace2, newMeta); Database database2 = metastoreClient.getDatabase(namespace2.toString()); Assert.assertEquals("There no same location for db and namespace", database2.getLocationUri(), hiveLocalDir); }
@Test public void testNamespaceExists() throws TException { Namespace namespace = Namespace.of("dbname_exists"); catalog.createNamespace(namespace, meta); Assert.assertTrue("Should true to namespace exist", catalog.namespaceExists(namespace)); Assert.assertTrue("Should false to namespace doesn't exist", !catalog.namespaceExists(Namespace.of("db2", "db2", "ns2"))); }