|  | 
| 123 | 123 | import org.apache.polaris.service.types.NotificationType; | 
| 124 | 124 | import org.apache.polaris.service.types.TableUpdateNotification; | 
| 125 | 125 | import org.assertj.core.api.Assertions; | 
|  | 126 | +import org.assertj.core.api.ThrowableAssert.ThrowingCallable; | 
| 126 | 127 | import org.junit.jupiter.api.AfterEach; | 
| 127 | 128 | import org.junit.jupiter.api.Assumptions; | 
| 128 | 129 | import org.junit.jupiter.api.BeforeAll; | 
| 129 | 130 | import org.junit.jupiter.api.BeforeEach; | 
| 130 |  | -import org.junit.jupiter.api.Disabled; | 
| 131 | 131 | import org.junit.jupiter.api.Test; | 
| 132 | 132 | import org.junit.jupiter.api.TestInfo; | 
| 133 | 133 | import org.junit.jupiter.params.ParameterizedTest; | 
| @@ -164,6 +164,7 @@ public Map<String, String> getConfigOverrides() { | 
| 164 | 164 |       new Schema( | 
| 165 | 165 |           required(3, "id", Types.IntegerType.get(), "unique ID 🤪"), | 
| 166 | 166 |           required(4, "data", Types.StringType.get())); | 
|  | 167 | +  private static final String VIEW_QUERY = "select * from ns1.layer1_table"; | 
| 167 | 168 |   public static final String CATALOG_NAME = "polaris-catalog"; | 
| 168 | 169 |   public static final String TEST_ACCESS_KEY = "test_access_key"; | 
| 169 | 170 |   public static final String SECRET_ACCESS_KEY = "secret_access_key"; | 
| @@ -386,18 +387,48 @@ public Map<String, BaseResult> purgeRealms(Iterable<String> realms) { | 
| 386 | 387 |     }; | 
| 387 | 388 |   } | 
| 388 | 389 | 
 | 
| 389 |  | -  /** TODO: Unblock this test, see: https://github.com/apache/polaris/issues/1272 */ | 
| 390 |  | -  @Override | 
| 391 | 390 |   @Test | 
| 392 |  | -  @Disabled( | 
| 393 |  | -      """ | 
| 394 |  | -      Disabled because the behavior is not applicable to Polaris. | 
| 395 |  | -      To unblock: | 
| 396 |  | -      1) Align Polaris behavior with the superclass by handling empty namespaces the same way, or | 
| 397 |  | -      2) Modify this test to expect an exception and add a Polaris-specific version. | 
| 398 |  | -      """) | 
| 399 |  | -  public void listNamespacesWithEmptyNamespace() { | 
| 400 |  | -    super.listNamespacesWithEmptyNamespace(); | 
|  | 391 | +  public void testEmptyNamespace() { | 
|  | 392 | +    IcebergCatalog catalog = catalog(); | 
|  | 393 | +    TableIdentifier tableInRootNs = TableIdentifier.of("table"); | 
|  | 394 | +    String expectedMessage = "Namespace does not exist: ''"; | 
|  | 395 | + | 
|  | 396 | +    ThrowingCallable createEmptyNamespace = () -> catalog.createNamespace(Namespace.empty()); | 
|  | 397 | +    Assertions.assertThatThrownBy(createEmptyNamespace) | 
|  | 398 | +        .isInstanceOf(AlreadyExistsException.class) | 
|  | 399 | +        .hasMessage("Cannot create root namespace, as it already exists implicitly."); | 
|  | 400 | + | 
|  | 401 | +    ThrowingCallable dropEmptyNamespace = () -> catalog.dropNamespace(Namespace.empty()); | 
|  | 402 | +    Assertions.assertThatThrownBy(dropEmptyNamespace) | 
|  | 403 | +        .isInstanceOf(IllegalArgumentException.class) | 
|  | 404 | +        .hasMessage("Cannot drop root namespace"); | 
|  | 405 | + | 
|  | 406 | +    ThrowingCallable createTable = () -> catalog.createTable(tableInRootNs, SCHEMA); | 
|  | 407 | +    Assertions.assertThatThrownBy(createTable) | 
|  | 408 | +        .isInstanceOf(NoSuchNamespaceException.class) | 
|  | 409 | +        .hasMessageContaining(expectedMessage); | 
|  | 410 | + | 
|  | 411 | +    ThrowingCallable createView = | 
|  | 412 | +        () -> | 
|  | 413 | +            catalog | 
|  | 414 | +                .buildView(tableInRootNs) | 
|  | 415 | +                .withSchema(SCHEMA) | 
|  | 416 | +                .withDefaultNamespace(Namespace.empty()) | 
|  | 417 | +                .withQuery("spark", VIEW_QUERY) | 
|  | 418 | +                .create(); | 
|  | 419 | +    Assertions.assertThatThrownBy(createView) | 
|  | 420 | +        .isInstanceOf(NoSuchNamespaceException.class) | 
|  | 421 | +        .hasMessageContaining(expectedMessage); | 
|  | 422 | + | 
|  | 423 | +    ThrowingCallable listTables = () -> catalog.listTables(Namespace.empty()); | 
|  | 424 | +    Assertions.assertThatThrownBy(listTables) | 
|  | 425 | +        .isInstanceOf(NoSuchNamespaceException.class) | 
|  | 426 | +        .hasMessageContaining(expectedMessage); | 
|  | 427 | + | 
|  | 428 | +    ThrowingCallable listViews = () -> catalog.listViews(Namespace.empty()); | 
|  | 429 | +    Assertions.assertThatThrownBy(listViews) | 
|  | 430 | +        .isInstanceOf(NoSuchNamespaceException.class) | 
|  | 431 | +        .hasMessageContaining(expectedMessage); | 
| 401 | 432 |   } | 
| 402 | 433 | 
 | 
| 403 | 434 |   @Test | 
|  | 
0 commit comments