@Override
  public void createNamespace(Namespace namespace, Map<String, String> metadata) {
    if (namespaceExists(namespace)) {
      throw new AlreadyExistsException("Namespace already exists: %s", namespace);
    }

    Map<String, String> createMetadata;
    if (metadata == null || metadata.isEmpty()) {
      createMetadata = ImmutableMap.of(NAMESPACE_EXISTS_PROPERTY, "true");
    } else {
      createMetadata =
          ImmutableMap.<String, String>builder()
              .putAll(metadata)
              .put(NAMESPACE_EXISTS_PROPERTY, "true")
              .buildOrThrow();
    }

    insertProperties(namespace, createMetadata);
  }
@Test
  public void testCreateNamespace() {
    Namespace testNamespace = Namespace.of("testDb", "ns1", "ns2");
    assertThat(catalog.namespaceExists(testNamespace)).isFalse();
    assertThat(catalog.namespaceExists(Namespace.of("testDb", "ns1"))).isFalse();
    catalog.createNamespace(testNamespace);
    assertThat(catalog.namespaceExists(testNamespace)).isTrue();
    assertThat(catalog.namespaceExists(Namespace.of("testDb"))).isTrue();
    assertThat(catalog.namespaceExists(Namespace.of("testDb", "ns1"))).isTrue();
    assertThat(catalog.namespaceExists(Namespace.of("testDb", "ns1", "ns2"))).isTrue();
    assertThat(catalog.namespaceExists(Namespace.of("ns1", "ns2"))).isFalse();
    assertThat(catalog.namespaceExists(Namespace.of("testDb", "ns%"))).isFalse();
    assertThat(catalog.namespaceExists(Namespace.of("testDb", "ns_"))).isFalse();
    assertThat(catalog.namespaceExists(Namespace.of("testDb", "ns1", "ns2", "ns3"))).isFalse();
  }