XiaoHongbo-Hope commented on code in PR #5208:
URL: https://github.com/apache/paimon/pull/5208#discussion_r1980794450


##########
paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java:
##########
@@ -743,16 +860,56 @@ void testBranches() throws Exception {
         catalog.dropDatabase(databaseName, true, true);
         catalog.createDatabase(databaseName, true);
         Identifier identifier = Identifier.create(databaseName, "table");
+
         catalog.createTable(
                 identifier, Schema.newBuilder().column("col", 
DataTypes.INT()).build(), true);
-
-        RESTCatalog restCatalog = (RESTCatalog) catalog;
+        assertThrows(
+                SupportsBranches.TagNotExistException.class,
+                () -> restCatalog.createBranch(identifier, "my_branch", 
"tag"));
         restCatalog.createBranch(identifier, "my_branch", null);
+        assertThrows(
+                SupportsBranches.BranchAlreadyExistException.class,
+                () -> restCatalog.createBranch(identifier, "my_branch", null));
         
assertThat(restCatalog.listBranches(identifier)).containsOnly("my_branch");
         restCatalog.dropBranch(identifier, "my_branch");
+
+        assertThrows(
+                SupportsBranches.BranchNotExistException.class,
+                () -> restCatalog.dropBranch(identifier, "no_exist_branch"));
+        assertThrows(
+                SupportsBranches.BranchNotExistException.class,
+                () -> restCatalog.fastForward(identifier, "no_exist_branch"));
         assertThat(restCatalog.listBranches(identifier)).isEmpty();
     }
 
+    @Test
+    void testListDataFromPageApi() {
+        List<Integer> testData = ImmutableList.of(1, 2, 3, 4);
+        int maxResults = 2;
+        AtomicInteger fetchTimes = new AtomicInteger(0);
+        List<Integer> fetchData =
+                restCatalog.listDataFromPageApi(
+                        queryParams -> {
+                            String nextToken = 
queryParams.getOrDefault(PAGE_TOKEN, null);
+                            fetchTimes.incrementAndGet();
+                            if (nextToken == null) {
+                                return new TestPagedResponse(
+                                        (maxResults - 1) + "", 
testData.subList(0, maxResults));

Review Comment:
   should return data:1, 2 and nextPageToken:2



##########
paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java:
##########
@@ -743,16 +860,56 @@ void testBranches() throws Exception {
         catalog.dropDatabase(databaseName, true, true);
         catalog.createDatabase(databaseName, true);
         Identifier identifier = Identifier.create(databaseName, "table");
+
         catalog.createTable(
                 identifier, Schema.newBuilder().column("col", 
DataTypes.INT()).build(), true);
-
-        RESTCatalog restCatalog = (RESTCatalog) catalog;
+        assertThrows(
+                SupportsBranches.TagNotExistException.class,
+                () -> restCatalog.createBranch(identifier, "my_branch", 
"tag"));
         restCatalog.createBranch(identifier, "my_branch", null);
+        assertThrows(
+                SupportsBranches.BranchAlreadyExistException.class,
+                () -> restCatalog.createBranch(identifier, "my_branch", null));
         
assertThat(restCatalog.listBranches(identifier)).containsOnly("my_branch");
         restCatalog.dropBranch(identifier, "my_branch");
+
+        assertThrows(
+                SupportsBranches.BranchNotExistException.class,
+                () -> restCatalog.dropBranch(identifier, "no_exist_branch"));
+        assertThrows(
+                SupportsBranches.BranchNotExistException.class,
+                () -> restCatalog.fastForward(identifier, "no_exist_branch"));
         assertThat(restCatalog.listBranches(identifier)).isEmpty();
     }
 
+    @Test
+    void testListDataFromPageApi() {
+        List<Integer> testData = ImmutableList.of(1, 2, 3, 4);
+        int maxResults = 2;
+        AtomicInteger fetchTimes = new AtomicInteger(0);
+        List<Integer> fetchData =
+                restCatalog.listDataFromPageApi(
+                        queryParams -> {
+                            String nextToken = 
queryParams.getOrDefault(PAGE_TOKEN, null);
+                            fetchTimes.incrementAndGet();
+                            if (nextToken == null) {
+                                return new TestPagedResponse(
+                                        (maxResults - 1) + "", 
testData.subList(0, maxResults));
+                            } else {
+                                Integer index = Integer.parseInt(nextToken) + 
1;
+                                if (index >= testData.size() - 1) {
+                                    return new TestPagedResponse(null, null);

Review Comment:
   a little confused here, if nextToken = 2, then return null response back ?



##########
paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java:
##########
@@ -604,16 +731,6 @@ public void testListPartitionsPaged() throws Exception {
                 partitionSpecs.get(4),
                 partitionSpecs.get(3));
         assertNull(pagedPartitions.getNextPageToken());
-
-        // List partitions paged throws TableNotExistException when the table 
does not exist
-        final int finalMaxResults = maxResults;
-        assertThatExceptionOfType(Catalog.TableNotExistException.class)
-                .isThrownBy(
-                        () ->
-                                catalog.listPartitionsPaged(
-                                        Identifier.create(databaseName, 
"non_existing_table"),
-                                        finalMaxResults,
-                                        "dt=20250101"));
     }

Review Comment:
   we can leave this TableNotExistException case here? 



-- 
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...@paimon.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to