zjffdu commented on a change in pull request #4299: URL: https://github.com/apache/zeppelin/pull/4299#discussion_r815616023
########## File path: zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java ########## @@ -693,39 +691,55 @@ public void testRunAllParagraph_FirstFailed() throws IOException { @Test public void testCloneNote() throws IOException { - LOG.info("Running testCloneNote"); - String note1Id = null; - String clonedNoteId = null; - 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(); - - 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"); - - // assertEquals(resp2Body.get("name"), "Note " + clonedNoteId); - get.close(); - } finally { - // cleanup - if (null != note1Id) { - TestUtils.getInstance(Notebook.class).removeNote(note1Id, anonymous); - } - if (null != clonedNoteId) { - TestUtils.getInstance(Notebook.class).removeNote(clonedNoteId, anonymous); + LOG.info("Running testCloneNote"); + String note1Id = null; + List<String> clonedNoteIds = new ArrayList<>(); + try { + Notebook notebook = TestUtils.getInstance(Notebook.class); + note1Id = notebook.createNote("note1", anonymous); + NotebookRepoWithVersionControl.Revision first_commit = + notebook.processNote(note1Id, note -> + notebook.checkpointNote(note.getId(), note.getPath(), "first commit", anonymous)); + + // Clone a note + CloseableHttpResponse post1 = httpPost("/notebook/" + note1Id, ""); + // Clone a revision of note + CloseableHttpResponse post2 = + httpPost("/notebook/" + note1Id, "{ revisionId: " + first_commit.id + "}" ); + + // Verify the responses + for (CloseableHttpResponse post: Arrays.asList(post1, post2)) { Review comment: Should also verify whether the note is cloned correctly, e.g. if you clone a note with revisionId, is the content of the cloned note correct? -- 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