zjffdu commented on a change in pull request #4299:
URL: https://github.com/apache/zeppelin/pull/4299#discussion_r816615868



##########
File path: 
zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
##########
@@ -695,33 +693,69 @@ public void testRunAllParagraph_FirstFailed() throws 
IOException {
   public void testCloneNote() throws IOException {
     LOG.info("Running testCloneNote");
     String note1Id = null;
-    String clonedNoteId = null;
+    List<String> clonedNoteIds = new ArrayList<>();
+    String text1 = "%text clone note";
+    String text2 = "%text clone revision of note";
     try {
-      note1Id = TestUtils.getInstance(Notebook.class).createNote("note1", 
anonymous);
-      CloseableHttpResponse post = httpPost("/notebook/" + note1Id, "");
-      String postResponse = EntityUtils.toString(post.getEntity(), 
StandardCharsets.UTF_8);
-      LOG.info("testCloneNote response\n" + postResponse);
-      assertThat(post, isAllowed());
-      Map<String, Object> resp = gson.fromJson(postResponse,
-              new TypeToken<Map<String, Object>>() {}.getType());
-      clonedNoteId = (String) resp.get("body");
-      post.close();
+      Notebook notebook = TestUtils.getInstance(Notebook.class);
+      note1Id = notebook.createNote("note1", anonymous);
+
+      // add text and commit note
+      NotebookRepoWithVersionControl.Revision first_commit =
+              notebook.processNote(note1Id, note -> {
+                Paragraph p1 = note.addNewParagraph(anonymous);
+                p1.setText(text2);
+                notebook.saveNote(note, AuthenticationInfo.ANONYMOUS);
+                return notebook.checkpointNote(note.getId(), note.getPath(), 
"first commit", anonymous);
+              });
+
+      // change the text of note
+      notebook.processNote(note1Id, note -> {
+        note.getParagraph(0).setText(text1);
+        return null;
+      });
 
-      CloseableHttpResponse get = httpGet("/notebook/" + clonedNoteId);
-      assertThat(get, isAllowed());
-      Map<String, Object> resp2 = 
gson.fromJson(EntityUtils.toString(get.getEntity(), StandardCharsets.UTF_8),
-              new TypeToken<Map<String, Object>>() {}.getType());
-      Map<String, Object> resp2Body = (Map<String, Object>) resp2.get("body");
+      // Clone a note
+      CloseableHttpResponse post1 = httpPost("/notebook/" + note1Id, "");
+      // Clone a revision of note
+      CloseableHttpResponse post2 =
+              httpPost("/notebook/" + note1Id, "{ revisionId: " + 
first_commit.id + "}");
 
-      //    assertEquals(resp2Body.get("name"), "Note " + clonedNoteId);
-      get.close();
+      // Verify the responses
+      for (int i = 0; i < 2; i++) {
+        CloseableHttpResponse post = Arrays.asList(post1, post2).get(i);
+        String text = Arrays.asList(text1, text2).get(i);
+
+        String postResponse = EntityUtils.toString(post.getEntity(), 
StandardCharsets.UTF_8);
+        LOG.info("testCloneNote response\n" + postResponse);

Review comment:
       use placeholder of log4j: `LOG.info("testCloneNote response: {}", 
postResponse);`




-- 
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: dev-unsubscr...@zeppelin.apache.org

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


Reply via email to