nastra commented on code in PR #9782: URL: https://github.com/apache/iceberg/pull/9782#discussion_r1566939950
########## core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java: ########## @@ -2329,6 +2374,57 @@ public void multipleDiffsAgainstMultipleTablesLastFails() { assertThat(schema2.columns()).hasSize(1); } + @Test + public void testInvalidRestPageSize() { + RESTCatalogAdapter adapter = Mockito.spy(new RESTCatalogAdapter(backendCatalog)); + RESTCatalog catalog = + new RESTCatalog(SessionCatalog.SessionContext.createEmpty(), (config) -> adapter); + org.assertj.core.api.Assertions.assertThatThrownBy( + () -> catalog.initialize("test", ImmutableMap.of(RESTSessionCatalog.REST_PAGE_SIZE, "-1"))) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Invalid value for pageSize, must be a positive integer"); + } + + @Test + public void testPaginationForListNamespaces() { + RESTCatalogAdapter adapter = Mockito.spy(new RESTCatalogAdapter(backendCatalog)); + RESTCatalog catalog = + new RESTCatalog(SessionCatalog.SessionContext.createEmpty(), (config) -> adapter); + catalog.initialize("test", ImmutableMap.of(RESTSessionCatalog.REST_PAGE_SIZE, "10")); + int numberOfItems = 100; + String namespaceName = "newdb"; + + // create several namespaces for listing and verify + for (int i = 0; i < numberOfItems; i++) { + String nameSpaceName = namespaceName + i; + catalog.createNamespace(Namespace.of(nameSpaceName)); + } + + List<Namespace> results = catalog.listNamespaces(); + assertThat(results).hasSize(numberOfItems); + } + + @Test + public void testPaginationForListTables() { + RESTCatalogAdapter adapter = Mockito.spy(new RESTCatalogAdapter(backendCatalog)); + RESTCatalog catalog = + new RESTCatalog(SessionCatalog.SessionContext.createEmpty(), (config) -> adapter); + catalog.initialize("test", ImmutableMap.of(RESTSessionCatalog.REST_PAGE_SIZE, "10")); + int numberOfItems = 100; + String namespaceName = "newdb"; + String tableName = "newtable"; + catalog.createNamespace(Namespace.of(namespaceName)); + + // create several tables under namespace for listing and verify + for (int i = 0; i < numberOfItems; i++) { + TableIdentifier tableIdentifier = TableIdentifier.of(namespaceName, tableName + i); + catalog.createTable(tableIdentifier, SCHEMA); + } + + List<TableIdentifier> tables = catalog.listTables(Namespace.of(namespaceName)); + assertThat(tables).hasSize(numberOfItems); Review Comment: ```suggestion assertThat(catalog.listTables(Namespace.of(namespaceName))).hasSize(numberOfItems); ``` ########## core/src/test/java/org/apache/iceberg/rest/TestRESTViewCatalog.java: ########## @@ -144,6 +151,36 @@ public void closeCatalog() throws Exception { } } + @Test + public void testPaginationForListViews() { + RESTCatalogAdapter adapter = Mockito.spy(new RESTCatalogAdapter(backendCatalog)); Review Comment: same as above -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org