EricGao888 commented on a change in pull request #4134:
URL: https://github.com/apache/zeppelin/pull/4134#discussion_r669327349



##########
File path: 
zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
##########
@@ -470,6 +471,29 @@ public void testRemoveNote() throws IOException, 
InterruptedException {
     }
   }
 
+  @Test
+  public void testRemoveCorruptedNote() throws IOException, 
InterruptedException {
+    try {
+      LOGGER.info("--------------- Test testRemoveCorruptedNote 
---------------");
+      // create a note and a paragraph
+      Note corruptedNote = notebook.createNote("note1", anonymous);
+      String corruptedNotePath = notebookDir.getAbsolutePath() + 
corruptedNote.getPath() + "_" + corruptedNote.getId() + ".zpln";
+      // corrupt note
+      try (FileWriter myWriter = new FileWriter(corruptedNotePath)) {
+        myWriter.write("{{{I'm corrupted;;;");
+      } catch (IOException e) {
+        e.printStackTrace();
+      }
+      LOGGER.info("--------------- Finish Test testRemoveCorruptedNote 
---------------");
+      int numberOfNotes = notebook.getAllNotes().size();
+      notebook.removeNote(corruptedNote, anonymous);
+      assertEquals(numberOfNotes - 1, notebook.getAllNotes().size());
+      LOGGER.info("--------------- Finish Test testRemoveCorruptedNote 
---------------");
+    } catch (Exception e) {
+      e.printStackTrace();

Review comment:
       It didn't fail, which was kind of wired. Anyway I've fixed it. THX for 
the comment.

##########
File path: 
zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
##########
@@ -470,6 +471,29 @@ public void testRemoveNote() throws IOException, 
InterruptedException {
     }
   }
 
+  @Test
+  public void testRemoveCorruptedNote() throws IOException, 
InterruptedException {
+    try {
+      LOGGER.info("--------------- Test testRemoveCorruptedNote 
---------------");
+      // create a note and a paragraph
+      Note corruptedNote = notebook.createNote("note1", anonymous);
+      String corruptedNotePath = notebookDir.getAbsolutePath() + 
corruptedNote.getPath() + "_" + corruptedNote.getId() + ".zpln";
+      // corrupt note
+      try (FileWriter myWriter = new FileWriter(corruptedNotePath)) {
+        myWriter.write("{{{I'm corrupted;;;");
+      } catch (IOException e) {

Review comment:
       Done

##########
File path: 
zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java
##########
@@ -263,6 +264,22 @@ public void testNoteOperations() throws IOException {
     assertEquals(2, notesInfo.size());
     verify(callback).onSuccess(notesInfo, context);
 
+    // test moving corrupted note to trash
+    Note corruptedNote = notebookService.createNote("/folder_1/corruptedNote", 
"test", true, context, callback);
+    String corruptedNotePath = notebookDir.getAbsolutePath() + 
corruptedNote.getPath() + "_" + corruptedNote.getId() + ".zpln";
+    // corrupt note
+    try (FileWriter myWriter = new FileWriter(corruptedNotePath)) {
+      myWriter.write("{{{I'm corrupted;;;");
+    } catch (IOException e) {

Review comment:
       Done, thx for the comment




-- 
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