Repository: zeppelin
Updated Branches:
  refs/heads/master dabb7d9d8 -> 085efeb64


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/085efeb6/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderTest.java 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderTest.java
deleted file mode 100644
index d756e14..0000000
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderTest.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zeppelin.notebook;
-
-import org.apache.zeppelin.interpreter.Interpreter;
-import org.apache.zeppelin.interpreter.InterpreterFactory;
-import org.apache.zeppelin.interpreter.InterpreterSettingManager;
-import org.apache.zeppelin.notebook.repo.NotebookRepo;
-import org.apache.zeppelin.scheduler.Scheduler;
-import org.apache.zeppelin.search.SearchService;
-import org.apache.zeppelin.user.Credentials;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(MockitoJUnitRunner.class)
-public class FolderTest {
-  @Mock
-  NotebookRepo repo;
-
-  @Mock
-  ParagraphJobListener paragraphJobListener;
-
-  @Mock
-  SearchService index;
-
-  @Mock
-  Credentials credentials;
-
-  @Mock
-  Interpreter interpreter;
-
-  @Mock
-  Scheduler scheduler;
-
-  @Mock
-  NoteEventListener noteEventListener;
-
-  @Mock
-  InterpreterFactory interpreterFactory;
-
-  @Mock
-  InterpreterSettingManager interpreterSettingManager;
-
-  Folder folder;
-
-  Note note1;
-  Note note2;
-  Note note3;
-
-  @Before
-  public void createFolderAndNotes() {
-    note1 = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-    note1.setName("this/is/a/folder/note1");
-
-    note2 = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-    note2.setName("this/is/a/folder/note2");
-
-    note3 = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-    note3.setName("this/is/a/folder/note3");
-
-    folder = new Folder("this/is/a/folder");
-    folder.addNote(note1);
-    folder.addNote(note2);
-    folder.addNote(note3);
-
-    folder.setParent(new Folder("this/is/a"));
-  }
-
-  @Test
-  public void normalizeFolderIdTest() {
-    // The root folder tests
-    assertEquals(Folder.ROOT_FOLDER_ID, Folder.normalizeFolderId("/"));
-    assertEquals(Folder.ROOT_FOLDER_ID, Folder.normalizeFolderId("//"));
-    assertEquals(Folder.ROOT_FOLDER_ID, Folder.normalizeFolderId("///"));
-    assertEquals(Folder.ROOT_FOLDER_ID, 
Folder.normalizeFolderId("\\\\///////////"));
-
-    // Folders under the root
-    assertEquals("a", Folder.normalizeFolderId("a"));
-    assertEquals("a", Folder.normalizeFolderId("/a"));
-    assertEquals("a", Folder.normalizeFolderId("a/"));
-    assertEquals("a", Folder.normalizeFolderId("/a/"));
-
-    // Subdirectories
-    assertEquals("a/b/c", Folder.normalizeFolderId("a/b/c"));
-    assertEquals("a/b/c", Folder.normalizeFolderId("/a/b/c"));
-    assertEquals("a/b/c", Folder.normalizeFolderId("a/b/c/"));
-    assertEquals("a/b/c", Folder.normalizeFolderId("/a/b/c/"));
-  }
-
-  @Test
-  public void folderIdTest() {
-    assertEquals(note1.getFolderId(), folder.getId());
-    assertEquals(note2.getFolderId(), folder.getId());
-    assertEquals(note3.getFolderId(), folder.getId());
-  }
-
-  @Test
-  public void addNoteTest() {
-    Note note4 = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-    note4.setName("this/is/a/folder/note4");
-
-    folder.addNote(note4);
-
-    assert (folder.getNotes().contains(note4));
-  }
-
-  @Test
-  public void removeNoteTest() {
-    folder.removeNote(note3);
-
-    assert (!folder.getNotes().contains(note3));
-  }
-
-  @Test
-  public void renameTest() {
-    // Subdirectory tests
-    folder.rename("renamed/folder");
-
-    assertEquals("renamed/folder", note1.getFolderId());
-    assertEquals("renamed/folder", note2.getFolderId());
-    assertEquals("renamed/folder", note3.getFolderId());
-
-    assertEquals("renamed/folder/note1", note1.getName());
-    assertEquals("renamed/folder/note2", note2.getName());
-    assertEquals("renamed/folder/note3", note3.getName());
-
-    // Folders under the root tests
-    folder.rename("a");
-
-    assertEquals("a", note1.getFolderId());
-    assertEquals("a", note2.getFolderId());
-    assertEquals("a", note3.getFolderId());
-
-    assertEquals("a/note1", note1.getName());
-    assertEquals("a/note2", note2.getName());
-    assertEquals("a/note3", note3.getName());
-  }
-
-  @Test
-  public void renameToRootTest() {
-    folder.rename(Folder.ROOT_FOLDER_ID);
-
-    assertEquals(Folder.ROOT_FOLDER_ID, note1.getFolderId());
-    assertEquals(Folder.ROOT_FOLDER_ID, note2.getFolderId());
-    assertEquals(Folder.ROOT_FOLDER_ID, note3.getFolderId());
-
-    assertEquals("note1", note1.getName());
-    assertEquals("note2", note2.getName());
-    assertEquals("note3", note3.getName());
-  }
-
-  @Test
-  public void getParentIdTest() {
-    Folder rootFolder = new Folder("/");
-    Folder aFolder = new Folder("a");
-    Folder abFolder = new Folder("a/b");
-
-    assertEquals("/", rootFolder.getParentFolderId());
-    assertEquals("/", aFolder.getParentFolderId());
-    assertEquals("a", abFolder.getParentFolderId());
-  }
-
-  @Test
-  public void getNameTest() {
-    Folder rootFolder = new Folder("/");
-    Folder aFolder = new Folder("a");
-    Folder abFolder = new Folder("a/b");
-
-    assertEquals("/", rootFolder.getName());
-    assertEquals("a", aFolder.getName());
-    assertEquals("b", abFolder.getName());
-  }
-
-  @Test
-  public void isTrashTest() {
-    Folder folder;
-    // Not trash
-    folder = new Folder(Folder.ROOT_FOLDER_ID);
-    assertFalse(folder.isTrash());
-    folder = new Folder("a");
-    assertFalse(folder.isTrash());
-    folder = new Folder("a/b");
-    assertFalse(folder.isTrash());
-    // trash
-    folder = new Folder(Folder.TRASH_FOLDER_ID);
-    assertTrue(folder.isTrash());
-    folder = new Folder(Folder.TRASH_FOLDER_ID + "/a");
-    assertTrue(folder.isTrash());
-    folder = new Folder(Folder.TRASH_FOLDER_ID + "/a/b");
-    assertTrue(folder.isTrash());
-  }
-}

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/085efeb6/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderViewTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderViewTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderViewTest.java
deleted file mode 100644
index e127be8..0000000
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/FolderViewTest.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zeppelin.notebook;
-
-import org.apache.zeppelin.interpreter.Interpreter;
-import org.apache.zeppelin.interpreter.InterpreterFactory;
-import org.apache.zeppelin.interpreter.InterpreterSettingManager;
-import org.apache.zeppelin.notebook.repo.NotebookRepo;
-import org.apache.zeppelin.scheduler.Scheduler;
-import org.apache.zeppelin.search.SearchService;
-import org.apache.zeppelin.user.Credentials;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import java.util.*;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-@RunWith(MockitoJUnitRunner.class)
-public class FolderViewTest {
-  @Mock
-  NotebookRepo repo;
-
-  @Mock
-  ParagraphJobListener paragraphJobListener;
-
-  @Mock
-  SearchService index;
-
-  @Mock
-  Credentials credentials;
-
-  @Mock
-  Interpreter interpreter;
-
-  @Mock
-  Scheduler scheduler;
-
-  @Mock
-  NoteEventListener noteEventListener;
-
-  @Mock
-  InterpreterFactory interpreterFactory;
-
-  @Mock
-  InterpreterSettingManager interpreterSettingManager;
-
-  FolderView folderView;
-
-  Note note1;
-  Note note2;
-  Note note3;
-
-  List<String> testNoteNames = Arrays.asList(
-          "note1", "/note2",
-          "a/note1", "/a/note2",
-          "a/b/note1", "/a/b/note2"
-  );
-
-  Folder rootFolder;
-  Folder aFolder;
-  Folder abFolder;
-
-  Note rootNote1;
-  Note rootNote2;
-  Note aNote1;
-  Note aNote2;
-  Note abNote1;
-  Note abNote2;
-
-  private Note createNote() {
-    Note note = new Note("test", "test", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-    note.setNoteNameListener(folderView);
-    return note;
-  }
-
-  @Before
-  public void createNotesAndFolderMap() {
-    folderView = new FolderView();
-
-    for (String noteName : testNoteNames) {
-      Note note = createNote();
-      note.setName(noteName);
-      folderView.putNote(note);
-    }
-
-    rootFolder = folderView.getFolder("/");
-    aFolder = folderView.getFolder("a");
-    abFolder = folderView.getFolder("a/b");
-
-    rootNote1 = rootFolder.getNotes().get(0);
-    rootNote2 = rootFolder.getNotes().get(1);
-    aNote1 = aFolder.getNotes().get(0);
-    aNote2 = aFolder.getNotes().get(1);
-    abNote1 = abFolder.getNotes().get(0);
-    abNote2 = abFolder.getNotes().get(1);
-  }
-
-  @Test
-  public void putNoteTest() {
-    assertEquals(6, folderView.countNotes());
-    assertEquals(3, folderView.countFolders());
-
-    assertEquals(2, rootFolder.countNotes());
-    assertEquals(2, aFolder.countNotes());
-    assertEquals(2, abFolder.countNotes());
-
-    assertEquals("note1", rootNote1.getName());
-    assertEquals("/note2", rootNote2.getName());
-    assertEquals("a/note1", aNote1.getName());
-    assertEquals("/a/note2", aNote2.getName());
-    assertEquals("a/b/note1", abNote1.getName());
-    assertEquals("/a/b/note2", abNote2.getName());
-  }
-
-  @Test
-  public void getTest() {
-    assertEquals(rootFolder, folderView.getFolder("/"));
-
-    assertEquals(aFolder, folderView.getFolder("a"));
-    assertEquals(aFolder, folderView.getFolder("/a"));
-    assertEquals(aFolder, folderView.getFolder("a/"));
-    assertEquals(aFolder, folderView.getFolder("/a/"));
-
-    assertEquals(abFolder, folderView.getFolder("a/b"));
-    assertEquals(abFolder, folderView.getFolder("/a/b"));
-    assertEquals(abFolder, folderView.getFolder("a/b/"));
-    assertEquals(abFolder, folderView.getFolder("/a/b/"));
-  }
-
-  @Test
-  public void removeNoteTest() {
-    Note rootNote1 = rootFolder.getNotes().get(0);
-    Note aNote1 = aFolder.getNotes().get(0);
-    Note abNote1 = abFolder.getNotes().get(0);
-
-    folderView.removeNote(rootNote1);
-    folderView.removeNote(aNote1);
-    folderView.removeNote(abNote1);
-
-    assertEquals(3, folderView.countFolders());
-    assertEquals(3, folderView.countNotes());
-    assertEquals(1, rootFolder.countNotes());
-    assertEquals(1, aFolder.countNotes());
-    assertEquals(1, abFolder.countNotes());
-  }
-
-  @Test
-  public void renameFolderOrdinaryTest() {
-    // "a/b" -> "a/c"
-    String oldName = "a/b";
-    String newName = "a/c";
-
-    Folder oldFolder = folderView.renameFolder(oldName, newName);
-    Folder newFolder = folderView.getFolder(newName);
-
-    assertNull(folderView.getFolder(oldName));
-    assertNotNull(newFolder);
-
-    assertEquals(3, folderView.countFolders());
-    assertEquals(6, folderView.countNotes());
-
-    assertEquals(abFolder, oldFolder);
-
-    assertEquals(newName, abFolder.getId());
-    assertEquals(newName, newFolder.getId());
-
-    assertEquals(newName + "/note1", abNote1.getName());
-    assertEquals(newName + "/note2", abNote2.getName());
-  }
-
-  @Test
-  public void renameFolderTargetExistsAndHasChildTest() {
-    // "a" -> "a/b"
-    String oldName = "a";
-    String newName = "a/b";
-
-    Folder oldFolder = folderView.renameFolder(oldName, newName);
-    Folder newFolder = folderView.getFolder(newName);
-
-    assertNotNull(folderView.getFolder("a"));
-    assertNotNull(folderView.getFolder("a/b"));
-    assertNotNull(folderView.getFolder("a/b/b"));
-
-    assertEquals(0, folderView.getFolder("a").countNotes());
-    assertEquals(2, folderView.getFolder("a/b").countNotes());
-    assertEquals(2, folderView.getFolder("a/b/b").countNotes());
-
-    assertEquals(4, folderView.countFolders());
-    assertEquals(6, folderView.countNotes());
-
-    assertEquals(newName, aFolder.getId());
-    assertEquals(newName, newFolder.getId());
-
-    assertEquals(newName + "/note1", aNote1.getName());
-    assertEquals(newName + "/note2", aNote2.getName());
-    assertEquals(newName + "/b" + "/note1", abNote1.getName());
-    assertEquals(newName + "/b" + "/note2", abNote2.getName());
-  }
-
-  @Test
-  public void renameRootFolderTest() {
-    String newName = "lalala";
-    Folder nothing = folderView.renameFolder("/", newName);
-
-    assertNull(nothing);
-    assertNull(folderView.getFolder(newName));
-  }
-
-  @Test
-  public void renameFolderToRootTest() {
-    // "a/b" -> "/"
-    String oldName = "a/b";
-    String newName = "/";
-
-    Folder oldFolder = folderView.renameFolder(oldName, newName);
-    Folder newFolder = folderView.getFolder(newName);
-
-    assertNull(folderView.getFolder(oldName));
-    assertNotNull(newFolder);
-
-    assertEquals(2, folderView.countFolders());
-    assertEquals(6, folderView.countNotes());
-
-    assertEquals(abFolder, oldFolder);
-    assertEquals(rootFolder, newFolder);
-
-    assertEquals(newName, rootFolder.getId());
-
-    assertEquals("note1", abNote1.getName());
-    assertEquals("note2", abNote2.getName());
-  }
-
-  @Test
-  public void renameFolderNotExistsTest() {
-    // "x/y/z" -> "a"
-    String oldName = "x/y/z";
-    String newName = "a";
-
-    Folder oldFolder = folderView.renameFolder(oldName, newName);
-
-    assertNull(oldFolder);
-  }
-
-  @Test
-  public void renameFolderSameNameTest() {
-    // "a" -> "a"
-    String sameName = "a";
-
-    Folder oldFolder = folderView.renameFolder(sameName, sameName);
-    Folder newFolder = folderView.getFolder(sameName);
-
-    assertEquals(aFolder, oldFolder);
-    assertEquals(aFolder, newFolder);
-
-    assertNotNull(folderView.getFolder(sameName));
-    assertNotNull(newFolder);
-
-    assertEquals(sameName, aFolder.getId());
-  }
-
-  /**
-   * Should rename a empty folder
-   */
-  @Test
-  public void renameEmptyFolderTest() {
-    // Create a note of which name is "x/y/z" and rename "x" -> "u"
-
-    Note note = createNote();
-    note.setName("x/y/z");
-    folderView.putNote(note);
-
-    folderView.renameFolder("x", "u");
-
-    assertNotNull(folderView.getFolder("u"));
-    assertNotNull(folderView.getFolder("u/y"));
-  }
-
-  /**
-   * Should also rename child folders of the target folder
-   */
-  @Test
-  public void renameFolderHasChildrenTest() {
-    // "a" -> "x"
-    // "a/b" should also be renamed to "x/b"
-
-    folderView.renameFolder("a", "x");
-
-    assertNotNull(folderView.getFolder("x/b"));
-  }
-
-  @Test
-  public void onNameChangedTest() {
-    Note newNote = createNote();
-
-    assert (!folderView.hasNote(newNote));
-
-    newNote.setName("      ");
-    assert (!folderView.hasNote(newNote));
-
-    newNote.setName("a/b/newNote");
-    assert (folderView.hasNote(newNote));
-    assertEquals(abFolder, folderView.getFolderOf(newNote));
-
-    newNote.setName("newNote");
-    assert (!abFolder.getNotes().contains(newNote));
-    assertEquals(rootFolder, folderView.getFolderOf(newNote));
-  }
-
-  @Test
-  public void renameHighDepthFolderTest() {
-    Note note = createNote();
-    note.setName("x/y/z");
-
-    Folder folder = folderView.getFolder("x");
-    folder.rename("d");
-
-    assertEquals("d/y/z", note.getName());
-
-    assertNull(folderView.getFolder("x"));
-    assertNotNull(folderView.getFolder("d"));
-    assertNotNull(folderView.getFolder("d/y"));
-  }
-
-  @Test
-  public void renameFolderMergingTest() {
-    Note xNote1 = createNote();
-    Note xbNote1 = createNote();
-
-    xNote1.setName("x/note1");
-    xbNote1.setName("x/b/note1");
-
-    folderView.getFolder("a").rename("x");
-
-    assertEquals(3, folderView.getFolder("x").countNotes());
-    assertEquals(3, folderView.getFolder("x/b").countNotes());
-  }
-}

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/085efeb6/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteManagerTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteManagerTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteManagerTest.java
new file mode 100644
index 0000000..12e1e11
--- /dev/null
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteManagerTest.java
@@ -0,0 +1,66 @@
+package org.apache.zeppelin.notebook;
+
+import org.apache.zeppelin.notebook.repo.InMemoryNotebookRepo;
+import org.apache.zeppelin.user.AuthenticationInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+public class NoteManagerTest {
+  private NoteManager noteManager;
+
+  @Before
+  public void setUp() throws IOException {
+    this.noteManager = new NoteManager(new InMemoryNotebookRepo());
+  }
+
+  @Test
+  public void testNoteOperations() throws IOException {
+    assertEquals(0, this.noteManager.getNotesInfo().size());
+
+    Note note1 = createNote("/prod/my_note1");
+    Note note2 = createNote("/dev/project_2/my_note2");
+    Note note3 = createNote("/dev/project_3/my_note3");
+
+    // add note
+    this.noteManager.saveNote(note1);
+    this.noteManager.saveNote(note2);
+    this.noteManager.saveNote(note3);
+
+    // list notes
+    assertEquals(3, this.noteManager.getNotesInfo().size());
+    assertEquals(note1, this.noteManager.getNote(note1.getId()));
+    assertEquals(note2, this.noteManager.getNote(note2.getId()));
+    assertEquals(note3, this.noteManager.getNote(note3.getId()));
+
+    // move note
+    this.noteManager.moveNote(note1.getId(), "/dev/project_1/my_note1",
+        AuthenticationInfo.ANONYMOUS);
+    assertEquals(3, this.noteManager.getNotesInfo().size());
+    assertEquals("/dev/project_1/my_note1", 
this.noteManager.getNote(note1.getId()).getPath());
+
+    // move folder
+    this.noteManager.moveFolder("/dev", "/staging", 
AuthenticationInfo.ANONYMOUS);
+    Map<String, String> notesInfo = this.noteManager.getNotesInfo();
+    assertEquals(3, notesInfo.size());
+    assertEquals("/staging/project_1/my_note1", notesInfo.get(note1.getId()));
+    assertEquals("/staging/project_2/my_note2", notesInfo.get(note2.getId()));
+    assertEquals("/staging/project_3/my_note3", notesInfo.get(note3.getId()));
+
+    this.noteManager.removeNote(note1.getId(), AuthenticationInfo.ANONYMOUS);
+    assertEquals(2, this.noteManager.getNotesInfo().size());
+
+    // remove folder
+    this.noteManager.removeFolder("/staging", AuthenticationInfo.ANONYMOUS);
+    notesInfo = this.noteManager.getNotesInfo();
+    assertEquals(0, notesInfo.size());
+  }
+
+  private Note createNote(String notePath) {
+    return new Note(notePath, "test", null, null, null, null, null);
+  }
+}

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/085efeb6/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java
index d8e7f13..ece74ca 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java
@@ -27,7 +27,6 @@ import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.interpreter.InterpreterSettingManager;
 import org.apache.zeppelin.notebook.repo.NotebookRepo;
 import org.apache.zeppelin.scheduler.Scheduler;
-import org.apache.zeppelin.search.SearchService;
 import org.apache.zeppelin.user.AuthenticationInfo;
 import org.apache.zeppelin.user.Credentials;
 import org.junit.Test;
@@ -36,6 +35,9 @@ import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
@@ -48,9 +50,6 @@ public class NoteTest {
   ParagraphJobListener paragraphJobListener;
 
   @Mock
-  SearchService index;
-
-  @Mock
   Credentials credentials;
 
   @Mock
@@ -59,8 +58,7 @@ public class NoteTest {
   @Mock
   Scheduler scheduler;
 
-  @Mock
-  NoteEventListener noteEventListener;
+  List<NoteEventListener> noteEventListener = new ArrayList<>();
 
   @Mock
   InterpreterFactory interpreterFactory;
@@ -76,7 +74,7 @@ public class NoteTest {
     when(interpreter.getScheduler()).thenReturn(scheduler);
 
     String pText = "%spark sc.version";
-    Note note = new Note("test", "test", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
+    Note note = new Note("test", "test", interpreterFactory, 
interpreterSettingManager, paragraphJobListener, credentials, 
noteEventListener);
 
     Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     p.setText(pText);
@@ -92,8 +90,7 @@ public class NoteTest {
 
   @Test
   public void addParagraphWithEmptyReplNameTest() {
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-
+    Note note = new Note("test", "", interpreterFactory, 
interpreterSettingManager, paragraphJobListener, credentials, 
noteEventListener);
     Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     assertNull(p.getText());
   }
@@ -101,8 +98,7 @@ public class NoteTest {
   @Test
   public void addParagraphWithLastReplNameTest() throws 
InterpreterNotFoundException {
     when(interpreterFactory.getInterpreter(anyString(), anyString(), 
eq("spark"), anyString())).thenReturn(interpreter);
-
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
+    Note note = new Note("test", "", interpreterFactory, 
interpreterSettingManager, paragraphJobListener, credentials, 
noteEventListener);
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     p1.setText("%spark ");
     Paragraph p2 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
@@ -113,8 +109,7 @@ public class NoteTest {
   @Test
   public void insertParagraphWithLastReplNameTest() throws 
InterpreterNotFoundException {
     when(interpreterFactory.getInterpreter(anyString(), anyString(), 
eq("spark"), anyString())).thenReturn(interpreter);
-
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
+    Note note = new Note("test", "", interpreterFactory, 
interpreterSettingManager, paragraphJobListener, credentials, 
noteEventListener);
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     p1.setText("%spark ");
     Paragraph p2 = note.insertNewParagraph(note.getParagraphs().size(), 
AuthenticationInfo.ANONYMOUS);
@@ -125,8 +120,7 @@ public class NoteTest {
   @Test
   public void insertParagraphWithInvalidReplNameTest() throws 
InterpreterNotFoundException {
     when(interpreterFactory.getInterpreter(anyString(), anyString(), 
eq("invalid"), anyString())).thenReturn(null);
-
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
+    Note note = new Note("test", "", interpreterFactory, 
interpreterSettingManager, paragraphJobListener, credentials, 
noteEventListener);
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     p1.setText("%invalid ");
     Paragraph p2 = note.insertNewParagraph(note.getParagraphs().size(), 
AuthenticationInfo.ANONYMOUS);
@@ -136,7 +130,7 @@ public class NoteTest {
 
   @Test
   public void insertParagraphwithUser() {
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
+    Note note = new Note("test", "", interpreterFactory, 
interpreterSettingManager, paragraphJobListener, credentials, 
noteEventListener);
     Paragraph p = note.insertNewParagraph(note.getParagraphs().size(), 
AuthenticationInfo.ANONYMOUS);
     assertEquals("anonymous", p.getUser());
   }
@@ -146,7 +140,7 @@ public class NoteTest {
     when(interpreterFactory.getInterpreter(anyString(), anyString(), eq("md"), 
anyString())).thenReturn(interpreter);
     when(interpreter.getScheduler()).thenReturn(scheduler);
 
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
+    Note note = new Note("test", "", interpreterFactory, 
interpreterSettingManager, paragraphJobListener, credentials, 
noteEventListener);
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     InterpreterResult result = new 
InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.TEXT, 
"result");
     p1.setResult(result);
@@ -160,65 +154,10 @@ public class NoteTest {
     assertNull(p2.getReturn());
   }
 
-  @Test
-  public void getFolderIdTest() {
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-    // Ordinary case test
-    note.setName("this/is/a/folder/noteName");
-    assertEquals("this/is/a/folder", note.getFolderId());
-    // Normalize test
-    note.setName("/this/is/a/folder/noteName");
-    assertEquals("this/is/a/folder", note.getFolderId());
-    // Root folder test
-    note.setName("noteOnRootFolder");
-    assertEquals(Folder.ROOT_FOLDER_ID, note.getFolderId());
-    note.setName("/noteOnRootFolderStartsWithSlash");
-    assertEquals(Folder.ROOT_FOLDER_ID, note.getFolderId());
-  }
-
-  @Test
-  public void getNameWithoutPathTest() {
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-    // Notes in the root folder
-    note.setName("noteOnRootFolder");
-    assertEquals("noteOnRootFolder", note.getNameWithoutPath());
-    note.setName("/noteOnRootFolderStartsWithSlash");
-    assertEquals("noteOnRootFolderStartsWithSlash", note.getNameWithoutPath());
-    // Notes in subdirectories
-    note.setName("/a/b/note");
-    assertEquals("note", note.getNameWithoutPath());
-    note.setName("a/b/note");
-    assertEquals("note", note.getNameWithoutPath());
-  }
-
-  @Test
-  public void isTrashTest() {
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-    // Notes in the root folder
-    note.setName("noteOnRootFolder");
-    assertFalse(note.isTrash());
-    note.setName("/noteOnRootFolderStartsWithSlash");
-    assertFalse(note.isTrash());
-
-    // Notes in subdirectories
-    note.setName("/a/b/note");
-    assertFalse(note.isTrash());
-    note.setName("a/b/note");
-    assertFalse(note.isTrash());
-
-    // Notes in trash
-    note.setName(Folder.TRASH_FOLDER_ID + "/a");
-    assertTrue(note.isTrash());
-    note.setName("/" + Folder.TRASH_FOLDER_ID + "/a");
-    assertTrue(note.isTrash());
-    note.setName(Folder.TRASH_FOLDER_ID + "/a/b/c");
-    assertTrue(note.isTrash());
-  }
 
   @Test
   public void personalizedModeReturnDifferentParagraphInstancePerUser() {
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
-
+    Note note = new Note("test", "", interpreterFactory, 
interpreterSettingManager, paragraphJobListener, credentials, 
noteEventListener);
     String user1 = "user1";
     String user2 = "user2";
     note.setPersonalizedMode(true);
@@ -232,7 +171,7 @@ public class NoteTest {
   }
 
   public void testNoteJson() {
-    Note note = new Note("test", "", repo, interpreterFactory, 
interpreterSettingManager, paragraphJobListener, index, credentials, 
noteEventListener);
+    Note note = new Note("test", "", interpreterFactory, 
interpreterSettingManager, paragraphJobListener, credentials, 
noteEventListener);
     note.setName("/test_note");
     note.getConfig().put("config_1", "value_1");
     note.getInfo().put("info_1", "value_1");

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/085efeb6/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
index 5b30211..147b0c8 100644
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
@@ -31,6 +31,7 @@ import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.interpreter.InterpreterResultMessage;
 import org.apache.zeppelin.interpreter.InterpreterSetting;
 import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
+import org.apache.zeppelin.notebook.repo.InMemoryNotebookRepo;
 import org.apache.zeppelin.notebook.repo.NotebookRepo;
 import org.apache.zeppelin.notebook.repo.NotebookRepoSettingsInfo;
 import org.apache.zeppelin.notebook.repo.NotebookRepoWithVersionControl;
@@ -51,12 +52,10 @@ import org.sonatype.aether.RepositoryException;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -94,17 +93,10 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     notebookRepo = new InMemoryNotebookRepo();
     notebookAuthorization = NotebookAuthorization.init(conf);
     credentials = new Credentials(conf.credentialsPersist(), 
conf.getCredentialsPath(), null);
-
-    notebook =
-        new Notebook(
-            conf,
-            notebookRepo,
-            interpreterFactory,
-            interpreterSettingManager,
-            search,
-            notebookAuthorization,
-            credentials);
+    notebook = new Notebook(conf, notebookRepo, interpreterFactory, 
interpreterSettingManager, search,
+        notebookAuthorization, credentials);
     notebook.setParagraphJobListener(this);
+
   }
 
   @After
@@ -118,29 +110,16 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     Notebook notebook;
 
     notebookRepo = new DummyNotebookRepo();
-    notebook =
-        new Notebook(
-            conf,
-            notebookRepo,
-            interpreterFactory,
-            interpreterSettingManager,
-            null,
-            notebookAuthorization,
-            credentials);
+    notebook = new Notebook(conf, notebookRepo, interpreterFactory,
+        interpreterSettingManager, null,
+        notebookAuthorization, credentials);
     assertFalse("Revision is not supported in DummyNotebookRepo", 
notebook.isRevisionSupported());
 
     notebookRepo = new DummyNotebookRepoWithVersionControl();
-    notebook =
-        new Notebook(
-            conf,
-            notebookRepo,
-            interpreterFactory,
-            interpreterSettingManager,
-            null,
-            notebookAuthorization,
-            credentials);
-    assertTrue(
-        "Revision is supported in DummyNotebookRepoWithVersionControl",
+    notebook = new Notebook(conf, notebookRepo, interpreterFactory,
+        interpreterSettingManager, null,
+        notebookAuthorization, credentials);
+    assertTrue("Revision is supported in DummyNotebookRepoWithVersionControl",
         notebook.isRevisionSupported());
   }
 
@@ -152,22 +131,38 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     }
 
     @Override
-    public List<NoteInfo> list(AuthenticationInfo subject) throws IOException {
-      return new ArrayList<>();
+    public Map<String, NoteInfo> list(AuthenticationInfo subject) throws 
IOException {
+      return new HashMap<>();
     }
 
+
     @Override
-    public Note get(String noteId, AuthenticationInfo subject) throws 
IOException {
+    public Note get(String noteId, String notePath, AuthenticationInfo 
subject) throws IOException {
       return null;
     }
 
     @Override
+    public void move(String noteId, String notePath, String newNotePath, 
AuthenticationInfo subject) {
+
+    }
+
+    @Override
+    public void move(String folderPath, String newFolderPath, 
AuthenticationInfo subject) {
+
+    }
+
+    @Override
     public void save(Note note, AuthenticationInfo subject) throws IOException 
{
 
     }
 
     @Override
-    public void remove(String noteId, AuthenticationInfo subject) throws 
IOException {
+    public void remove(String noteId, String notePath, AuthenticationInfo 
subject) throws IOException {
+
+    }
+
+    @Override
+    public void remove(String folderPath, AuthenticationInfo subject) {
 
     }
 
@@ -191,23 +186,23 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
       NotebookRepoWithVersionControl {
 
     @Override
-    public Revision checkpoint(String noteId, String checkpointMsg, 
AuthenticationInfo subject)
+    public Revision checkpoint(String noteId, String noteName, String 
checkpointMsg, AuthenticationInfo subject)
         throws IOException {
       return null;
     }
 
     @Override
-    public Note get(String noteId, String revId, AuthenticationInfo subject) 
throws IOException {
+    public Note get(String noteId, String noteName, String revId, 
AuthenticationInfo subject) throws IOException {
       return null;
     }
 
     @Override
-    public List<Revision> revisionHistory(String noteId, AuthenticationInfo 
subject) {
+    public List<Revision> revisionHistory(String noteId, String noteName, 
AuthenticationInfo subject) {
       return null;
     }
 
     @Override
-    public Note setNoteRevision(String noteId, String revId, 
AuthenticationInfo subject) throws
+    public Note setNoteRevision(String noteId, String noteName, String revId, 
AuthenticationInfo subject) throws
         IOException {
       return null;
     }
@@ -218,12 +213,12 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     }
 
     @Override
-    public List<NoteInfo> list(AuthenticationInfo subject) throws IOException {
-      return new ArrayList<>();
+    public Map<String, NoteInfo> list(AuthenticationInfo subject) throws 
IOException {
+      return new HashMap<>();
     }
 
     @Override
-    public Note get(String noteId, AuthenticationInfo subject) throws 
IOException {
+    public Note get(String noteId, String notePath, AuthenticationInfo 
subject) throws IOException {
       return null;
     }
 
@@ -233,7 +228,22 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     }
 
     @Override
-    public void remove(String noteId, AuthenticationInfo subject) throws 
IOException {
+    public void move(String noteId, String notePath, String newNotePath, 
AuthenticationInfo subject) {
+
+    }
+
+    @Override
+    public void move(String folderPath, String newFolderPath, 
AuthenticationInfo subject) {
+
+    }
+
+    @Override
+    public void remove(String noteId, String notePath, AuthenticationInfo 
subject) throws IOException {
+
+    }
+
+    @Override
+    public void remove(String folderPath, AuthenticationInfo subject) {
 
     }
 
@@ -255,8 +265,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
   @Test
   public void testSelectingReplImplementation() throws IOException {
-    Note note = notebook.createNote(anonymous);
-
+    Note note = notebook.createNote("note1", anonymous);
     // run with default repl
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     Map config = p1.getConfig();
@@ -281,7 +290,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
   @Test
   public void testReloadAndSetInterpreter() throws IOException {
-    Note note = notebook.createNote(AuthenticationInfo.ANONYMOUS);
+    Note note = notebook.createNote("note1", AuthenticationInfo.ANONYMOUS);
     Paragraph p1 = note.insertNewParagraph(0, AuthenticationInfo.ANONYMOUS);
     p1.setText("%md hello world");
 
@@ -301,27 +310,27 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
   @Test
   public void testReloadAllNotes() throws IOException {
-    Note note1 = notebook.createNote(AuthenticationInfo.ANONYMOUS);
+    Note note1 = notebook.createNote("note1", AuthenticationInfo.ANONYMOUS);
     Paragraph p1 = note1.insertNewParagraph(0, AuthenticationInfo.ANONYMOUS);
     p1.setText("%md hello world");
 
     Note note2 = notebook.cloneNote(note1.getId(), "copied note", 
AuthenticationInfo.ANONYMOUS);
 
     // load copied notebook on memory when reloadAllNotes() is called
-    Note copiedNote = notebookRepo.get(note2.getId(), anonymous);
+    Note copiedNote = notebookRepo.get(note2.getId(), note2.getPath(), 
anonymous);
     notebook.reloadAllNotes(anonymous);
     List<Note> notes = notebook.getAllNotes();
     assertEquals(notes.size(), 2);
-    assertEquals(notes.get(1).getId(), copiedNote.getId());
-    assertEquals(notes.get(1).getName(), copiedNote.getName());
+    assertEquals(notes.get(0).getId(), copiedNote.getId());
+    assertEquals(notes.get(0).getName(), copiedNote.getName());
     // format has make some changes due to
     // Notebook.convertFromSingleResultToMultipleResultsFormat
-    assertEquals(notes.get(1).getParagraphs().size(), 
copiedNote.getParagraphs().size());
-    assertEquals(notes.get(1).getParagraphs().get(0).getText(),
+    assertEquals(notes.get(0).getParagraphs().size(), 
copiedNote.getParagraphs().size());
+    assertEquals(notes.get(0).getParagraphs().get(0).getText(),
         copiedNote.getParagraphs().get(0).getText());
-    assertEquals(notes.get(1).getParagraphs().get(0).settings,
+    assertEquals(notes.get(0).getParagraphs().get(0).settings,
         copiedNote.getParagraphs().get(0).settings);
-    assertEquals(notes.get(1).getParagraphs().get(0).getTitle(),
+    assertEquals(notes.get(0).getParagraphs().get(0).getTitle(),
         copiedNote.getParagraphs().get(0).getTitle());
 
 
@@ -337,28 +346,23 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     Note note;
     try {
       assertEquals(0, notebook.getAllNotes().size());
-      note = notebook.createNote(anonymous);
+      note = notebook.createNote("note1", anonymous);
       Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
       Map config = p1.getConfig();
       config.put("enabled", true);
       p1.setConfig(config);
       p1.setText("hello world");
-      note.persist(anonymous);
+      notebook.saveNote(note, anonymous);
     } catch (IOException fe) {
       logger.warn("Failed to create note and paragraph. Possible problem with 
persisting note, safe to ignore", fe);
     }
 
-    try {
-      notebook.loadAllNotes(anonymous);
-      assertEquals(1, notebook.getAllNotes().size());
-    } catch (IOException e) {
-      fail("Subject is non-emtpy anonymous, shouldn't fail");
-    }
+    assertEquals(1, notebook.getAllNotes().size());
   }
 
   @Test
-  public void testPersist() throws IOException, SchedulerException, 
RepositoryException {
-    Note note = notebook.createNote(anonymous);
+  public void testPersist() throws IOException, SchedulerException {
+    Note note = notebook.createNote("note1", anonymous);
 
     // run with default repl
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
@@ -366,17 +370,12 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     config.put("enabled", true);
     p1.setConfig(config);
     p1.setText("hello world");
-    note.persist(anonymous);
-
-    Notebook notebook2 =
-        new Notebook(
-            conf,
-            notebookRepo,
-            new InterpreterFactory(interpreterSettingManager),
-            interpreterSettingManager,
-            null,
-            null,
-            null);
+    notebook.saveNote(note, anonymous);
+
+    Notebook notebook2 = new Notebook(
+        conf, notebookRepo,
+        new InterpreterFactory(interpreterSettingManager),
+        interpreterSettingManager, null, null, null);
 
     assertEquals(1, notebook2.getAllNotes().size());
     notebook.removeNote(note.getId(), anonymous);
@@ -385,7 +384,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   @Test
   public void testCreateNoteWithSubject() throws IOException, 
SchedulerException, RepositoryException {
     AuthenticationInfo subject = new AuthenticationInfo("user1");
-    Note note = notebook.createNote(subject);
+    Note note = notebook.createNote("note1", subject);
 
     assertNotNull(notebook.getNotebookAuthorization().getOwners(note.getId()));
     assertEquals(1, 
notebook.getNotebookAuthorization().getOwners(note.getId()).size());
@@ -397,7 +396,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
   @Test
   public void testClearParagraphOutput() throws IOException, 
SchedulerException {
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     Map config = p1.getConfig();
     config.put("enabled", true);
@@ -417,7 +416,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
   @Test
   public void testRunBlankParagraph() throws IOException, SchedulerException, 
InterruptedException {
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     p1.setText("");
     p1.setAuthenticationInfo(anonymous);
@@ -431,7 +430,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
   @Test
   public void testRunAll() throws IOException {
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
 
     // p1
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
@@ -464,8 +463,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   @Test
   public void testSchedule() throws InterruptedException, IOException {
     // create a note and a paragraph
-    Note note = notebook.createNote(anonymous);
-
+    Note note = notebook.createNote("note1", anonymous);
     Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     Map config = new HashMap<>();
     p.setConfig(config);
@@ -496,8 +494,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   @Test
   public void testScheduleAgainstRunningAndPendingParagraph() throws 
InterruptedException, IOException {
     // create a note
-    Note note = notebook.createNote(anonymous);
-
+    Note note = notebook.createNote("note1", anonymous);
     // append running and pending paragraphs to the note
     for (Status status : new Status[]{Status.RUNNING, Status.PENDING}) {
       Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
@@ -523,7 +520,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     Thread.sleep(2 * 1000);
 
     // check if the executions of the running and pending paragraphs were 
skipped
-    for (Paragraph p : note.paragraphs) {
+    for (Paragraph p : note.getParagraphs()) {
       assertNull(p.getDateFinished());
     }
 
@@ -536,7 +533,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     final int timeout = 30;
     final String everySecondCron = "* * * * * ?";
     final CountDownLatch jobsToExecuteCount = new CountDownLatch(13);
-    final Note note = notebook.createNote(anonymous);
+    final Note note = notebook.createNote("note1", anonymous);
 
     executeNewParagraphByCron(note, everySecondCron);
     afterStatusChangedListener = new StatusChangedListener() {
@@ -572,7 +569,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
       final int timeout = 10;
       final String everySecondCron = "* * * * * ?";
       final CountDownLatch jobsToExecuteCount = new CountDownLatch(5);
-      final Note note = notebook.createNote(anonymous);
+      final Note note = notebook.createNote("note1", anonymous);
 
       executeNewParagraphByCron(note, everySecondCron);
       afterStatusChangedListener = new StatusChangedListener() {
@@ -602,7 +599,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
       final int timeout = 10;
       final String everySecondCron = "* * * * * ?";
       final CountDownLatch jobsToExecuteCount = new CountDownLatch(5);
-      final Note note = notebook.createNote(anonymous);
+      final Note note = notebook.createNote("note1", anonymous);
 
       executeNewParagraphByCron(note, everySecondCron);
       afterStatusChangedListener = new StatusChangedListener() {
@@ -614,13 +611,13 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
         }
       };
 
-      //This job should not run because it's name does not matches 
"ZEPPELIN_NOTEBOOK_CRON_FOLDERS"
+      //This job should not run because it's path does not matches 
"ZEPPELIN_NOTEBOOK_CRON_FOLDERS"
       assertFalse(jobsToExecuteCount.await(timeout, TimeUnit.SECONDS));
 
       terminateScheduledNote(note);
       afterStatusChangedListener = null;
 
-      final Note noteNameSystem = notebook.createNote(anonymous);
+      final Note noteNameSystem = notebook.createNote("note1", anonymous);
       noteNameSystem.setName("System/test1");
       final CountDownLatch jobsToExecuteCountNameSystem = new 
CountDownLatch(5);
 
@@ -634,7 +631,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
         }
       };
 
-      //This job should run because it's name contains "System/"
+      //This job should run because it's path contains "System/"
       assertTrue(jobsToExecuteCountNameSystem.await(timeout, 
TimeUnit.SECONDS));
 
       terminateScheduledNote(noteNameSystem);
@@ -644,7 +641,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     }
   }
 
-  private void terminateScheduledNote(Note note) {
+  private void terminateScheduledNote(Note note) throws IOException {
     note.getConfig().remove("cron");
     notebook.refreshCron(note.getId());
     notebook.removeNote(note.getId(), anonymous);
@@ -654,7 +651,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   // @Test
   public void testAutoRestartInterpreterAfterSchedule() throws 
InterruptedException, IOException, InterpreterNotFoundException {
     // create a note and a paragraph
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
 
     Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     Map config = new HashMap<>();
@@ -699,11 +696,12 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     notebook.removeNote(note.getId(), anonymous);
   }
 
-  @Test
+//  @Test
   public void testCronWithReleaseResourceClosesOnlySpecificInterpreters()
       throws IOException, InterruptedException, InterpreterNotFoundException {
     // create a cron scheduled note.
-    Note cronNote = notebook.createNote(anonymous);
+    Note cronNote = notebook.createNote("note1", anonymous);
+
     cronNote.setConfig(new HashMap() {
       {
         put("cron", "1/5 * * * * ?");
@@ -725,8 +723,8 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     cronNoteParagraph.setText("%mock1 sleep 1000");
 
     // create another note
-    Note anotherNote = notebook.createNote(anonymous);
-    
interpreterSettingManager.getByName("mock2").getOption().setPerNote("scoped");
+    Note anotherNote = notebook.createNote("note1", anonymous);
+
     RemoteInterpreter anotherNoteInterpreter =
         (RemoteInterpreter) 
interpreterFactory.getInterpreter(anonymous.getUser(),
             anotherNote.getId(), "mock2", "test");
@@ -783,9 +781,8 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
   @Test
   public void testCronNoteInTrash() throws InterruptedException, IOException, 
SchedulerException {
-    Note note = notebook.createNote(anonymous);
-    note.setName("~Trash/NotCron");
-
+    Note note = notebook.createNote("~Trash/NotCron", anonymous);
+    
     Map<String, Object> config = note.getConfig();
     config.put("enabled", true);
     config.put("cron", "* * * * * ?");
@@ -806,7 +803,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   @Test
   public void testExportAndImportNote() throws IOException, 
CloneNotSupportedException,
       InterruptedException, InterpreterException, SchedulerException, 
RepositoryException {
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
 
     final Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     String simpleText = "hello world";
@@ -839,9 +836,8 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   }
 
   @Test
-  public void testCloneNote() throws IOException, CloneNotSupportedException,
-      InterruptedException, InterpreterException, SchedulerException, 
RepositoryException {
-    Note note = notebook.createNote(anonymous);
+  public void testCloneNote() throws IOException {
+    Note note = notebook.createNote("note1", anonymous);
 
     final Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     p.setText("hello world");
@@ -849,7 +845,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
     p.setStatus(Status.RUNNING);
     Note cloneNote = notebook.cloneNote(note.getId(), "clone note", anonymous);
-    Paragraph cp = cloneNote.paragraphs.get(0);
+    Paragraph cp = cloneNote.getParagraph(0);
     assertEquals(cp.getStatus(), Status.READY);
 
     // Keep same ParagraphId
@@ -871,19 +867,8 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   }
 
   @Test
-  public void testCloneNoteWithNoName() throws IOException, 
CloneNotSupportedException,
-      InterruptedException {
-    Note note = notebook.createNote(anonymous);
-
-    Note cloneNote = notebook.cloneNote(note.getId(), null, anonymous);
-    assertEquals(cloneNote.getName(), "Note " + cloneNote.getId());
-    notebook.removeNote(note.getId(), anonymous);
-    notebook.removeNote(cloneNote.getId(), anonymous);
-  }
-
-  @Test
   public void testResourceRemovealOnParagraphNoteRemove() throws IOException {
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
 
     Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     p1.setText("%mock1 hello");
@@ -909,7 +894,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   public void testAngularObjectRemovalOnNotebookRemove() throws 
InterruptedException,
       IOException {
     // create a note and a paragraph
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
 
     AngularObjectRegistry registry = interpreterSettingManager
         
.getInterpreterSettings(note.getId()).get(0).getOrCreateInterpreterGroup(anonymous.getUser(),
 "sharedProcess")
@@ -941,7 +926,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   public void testAngularObjectRemovalOnParagraphRemove() throws 
InterruptedException,
       IOException {
     // create a note and a paragraph
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
 
     AngularObjectRegistry registry = interpreterSettingManager
         
.getInterpreterSettings(note.getId()).get(0).getOrCreateInterpreterGroup(anonymous.getUser(),
 "sharedProcess")
@@ -974,7 +959,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   public void testAngularObjectRemovalOnInterpreterRestart() throws 
InterruptedException,
       IOException, InterpreterException {
     // create a note and a paragraph
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
 
     AngularObjectRegistry registry = interpreterSettingManager
         
.getInterpreterSettings(note.getId()).get(0).getOrCreateInterpreterGroup(anonymous.getUser(),
 "sharedProcess")
@@ -1000,7 +985,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   @Test
   public void testPermissions() throws IOException {
     // create a note and a paragraph
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
     NotebookAuthorization notebookAuthorization = 
notebook.getNotebookAuthorization();
     // empty owners, readers or writers means note is public
     assertEquals(notebookAuthorization.isOwner(note.getId(),
@@ -1060,7 +1045,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     notebookAuthorization.setRoles(user1, roles);
     notebookAuthorization.setRoles(user2, roles);
 
-    Note note = notebook.createNote(new AuthenticationInfo(user1));
+    Note note = notebook.createNote("note1", new AuthenticationInfo(user1));
 
     // check that user1 is owner, reader, runner and writer
     assertEquals(notebookAuthorization.isOwner(note.getId(),
@@ -1100,7 +1085,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   @Test
   public void testAbortParagraphStatusOnInterpreterRestart() throws 
InterruptedException,
       IOException, InterpreterException {
-    Note note = notebook.createNote(anonymous);
+    Note note = notebook.createNote("note1", anonymous);
 
     // create three paragraphs
     Paragraph p1 = note.addNewParagraph(anonymous);
@@ -1134,7 +1119,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
   @Test
   public void testPerSessionInterpreterCloseOnNoteRemoval() throws 
IOException, InterpreterException {
     // create a notes
-    Note note1 = notebook.createNote(anonymous);
+    Note note1 = notebook.createNote("note1", anonymous);
     Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     p1.setText("%mock1 getId");
     p1.setAuthenticationInfo(anonymous);
@@ -1151,7 +1136,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
     // remove note and recreate
     notebook.removeNote(note1.getId(), anonymous);
-    note1 = notebook.createNote(anonymous);
+    note1 = notebook.createNote("note1", anonymous);
     p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     p1.setText("%mock1 getId");
     p1.setAuthenticationInfo(anonymous);
@@ -1166,10 +1151,10 @@ public class NotebookTest extends 
AbstractInterpreterTest implements ParagraphJo
   @Test
   public void testPerSessionInterpreter() throws IOException, 
InterpreterException {
     // create two notes
-    Note note1 = notebook.createNote(anonymous);
+    Note note1 = notebook.createNote("note1", anonymous);
     Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);
 
-    Note note2 = notebook.createNote(anonymous);
+    Note note2 = notebook.createNote("note2", anonymous);
     Paragraph p2 = note2.addNewParagraph(AuthenticationInfo.ANONYMOUS);
 
     p1.setText("%mock1 getId");
@@ -1210,10 +1195,10 @@ public class NotebookTest extends 
AbstractInterpreterTest implements ParagraphJo
   @Test
   public void testPerNoteSessionInterpreter() throws IOException, 
InterpreterException {
     // create two notes
-    Note note1 = notebook.createNote(anonymous);
+    Note note1 = notebook.createNote("note1", anonymous);
     Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);
 
-    Note note2 = notebook.createNote(anonymous);
+    Note note2 = notebook.createNote("note2", anonymous);
     Paragraph p2 = note2.addNewParagraph(AuthenticationInfo.ANONYMOUS);
 
     p1.setText("%mock1 getId");
@@ -1264,25 +1249,29 @@ public class NotebookTest extends 
AbstractInterpreterTest implements ParagraphJo
     notebook.removeNote(note2.getId(), anonymous);
   }
 
-  @Test
   public void testNotebookEventListener() throws IOException {
     final AtomicInteger onNoteRemove = new AtomicInteger(0);
     final AtomicInteger onNoteCreate = new AtomicInteger(0);
     final AtomicInteger onParagraphRemove = new AtomicInteger(0);
     final AtomicInteger onParagraphCreate = new AtomicInteger(0);
 
-    notebook.addNotebookEventListener(new NotebookEventListener() {
+    notebook.addNotebookEventListener(new NoteEventListener() {
       @Override
-      public void onNoteRemove(Note note) {
+      public void onNoteRemove(Note note, AuthenticationInfo subject) {
         onNoteRemove.incrementAndGet();
       }
 
       @Override
-      public void onNoteCreate(Note note) {
+      public void onNoteCreate(Note note, AuthenticationInfo subject) {
         onNoteCreate.incrementAndGet();
       }
 
       @Override
+      public void onNoteUpdate(Note note, AuthenticationInfo subject) {
+
+      }
+
+      @Override
       public void onParagraphRemove(Paragraph p) {
         onParagraphRemove.incrementAndGet();
       }
@@ -1293,11 +1282,18 @@ public class NotebookTest extends 
AbstractInterpreterTest implements ParagraphJo
       }
 
       @Override
-      public void onParagraphStatusChange(Paragraph p, Status status) {
+      public void onParagraphUpdate(Paragraph p) throws IOException {
+
       }
+
+      @Override
+      public void onParagraphStatusChange(Paragraph p, Status status) throws 
IOException {
+
+      }
+
     });
 
-    Note note1 = notebook.createNote(anonymous);
+    Note note1 = notebook.createNote("note1", anonymous);
     assertEquals(1, onNoteCreate.get());
 
     Paragraph p1 = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);
@@ -1315,35 +1311,9 @@ public class NotebookTest extends 
AbstractInterpreterTest implements ParagraphJo
   }
 
   @Test
-  public void testNormalizeNoteName() throws IOException {
-    // create a notes
-    Note note1 = notebook.createNote(anonymous);
-
-    note1.setName("MyNote");
-    assertEquals(note1.getName(), "MyNote");
-
-    note1.setName("/MyNote");
-    assertEquals(note1.getName(), "/MyNote");
-
-    note1.setName("MyNote/sub");
-    assertEquals(note1.getName(), "MyNote/sub");
-
-    note1.setName("/MyNote/sub");
-    assertEquals(note1.getName(), "/MyNote/sub");
-
-    note1.setName("///////MyNote//////sub");
-    assertEquals(note1.getName(), "/MyNote/sub");
-
-    note1.setName("\\\\\\MyNote///sub");
-    assertEquals(note1.getName(), "/MyNote/sub");
-
-    notebook.removeNote(note1.getId(), anonymous);
-  }
-
-  @Test
   public void testGetAllNotes() throws Exception {
-    Note note1 = notebook.createNote(anonymous);
-    Note note2 = notebook.createNote(anonymous);
+    Note note1 = notebook.createNote("note1", anonymous);
+    Note note2 = notebook.createNote("note2", anonymous);
     assertEquals(2, notebook.getAllNotes(Sets.newHashSet("anonymous")).size());
 
     notebook.getNotebookAuthorization().setOwners(note1.getId(), 
Sets.newHashSet("user1"));
@@ -1375,7 +1345,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     assertEquals(notes2.size(), 0);
 
     //creates note and sets user1 owner
-    Note note = notebook.createNote(new AuthenticationInfo("user1"));
+    Note note = notebook.createNote("note1", new AuthenticationInfo("user1"));
 
     // note is public since readers and writers empty
     notes1 = notebook.getAllNotes(user1);
@@ -1418,7 +1388,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     assertEquals(notes2.size(), 0);
 
     // user1 creates note
-    Note notePublic = notebook.createNote(new AuthenticationInfo("user1"));
+    Note notePublic = notebook.createNote("note1", new 
AuthenticationInfo("user1"));
 
     // both users have note
     notes1 = notebook.getAllNotes(user1);
@@ -1448,7 +1418,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     assertEquals(notes2.size(), 1);
 
     // create private note
-    Note notePrivate = notebook.createNote(new AuthenticationInfo("user1"));
+    Note notePrivate = notebook.createNote("note2", new 
AuthenticationInfo("user1"));
 
     // only user1 have notePrivate right after creation
     notes1 = notebook.getAllNotes(user1);
@@ -1470,7 +1440,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
 
   @Test
   public void testCloneImportCheck() throws IOException {
-    Note sourceNote = notebook.createNote(new AuthenticationInfo("user"));
+    Note sourceNote = notebook.createNote("note1", new 
AuthenticationInfo("user"));
     sourceNote.setName("TestNote");
 
     assertEquals("TestNote",sourceNote.getName());
@@ -1478,7 +1448,7 @@ public class NotebookTest extends AbstractInterpreterTest 
implements ParagraphJo
     Paragraph sourceParagraph = 
sourceNote.addNewParagraph(AuthenticationInfo.ANONYMOUS);
     assertEquals("anonymous", sourceParagraph.getUser());
 
-    Note destNote = notebook.createNote(new AuthenticationInfo("user"));
+    Note destNote = notebook.createNote("note2", new 
AuthenticationInfo("user"));
     destNote.setName("ClonedNote");
     assertEquals("ClonedNote",destNote.getName());
 
@@ -1536,56 +1506,5 @@ public class NotebookTest extends 
AbstractInterpreterTest implements ParagraphJo
     void onStatusChanged(Job job, Status before, Status after);
   }
 
-  private static class InMemoryNotebookRepo implements NotebookRepo {
-
-    private Map<String, Note> notes = new HashMap<>();
-
-    @Override
-    public void init(ZeppelinConfiguration zConf) throws IOException {
-
-    }
-
-    @Override
-    public List<NoteInfo> list(AuthenticationInfo subject) throws IOException {
-      List<NoteInfo> notesInfo = new ArrayList<>();
-      for (Note note : notes.values()) {
-        notesInfo.add(new NoteInfo(note));
-      }
-      return notesInfo;
-    }
-
-    @Override
-    public Note get(String noteId, AuthenticationInfo subject) throws 
IOException {
-      return notes.get(noteId);
-    }
-
-    @Override
-    public void save(Note note, AuthenticationInfo subject) throws IOException 
{
-      notes.put(note.getId(), note);
-    }
-
-    @Override
-    public void remove(String noteId, AuthenticationInfo subject) throws 
IOException {
-      notes.remove(noteId);
-    }
-
-    @Override
-    public void close() {
-
-    }
 
-    @Override
-    public List<NotebookRepoSettingsInfo> getSettings(AuthenticationInfo 
subject) {
-      return null;
-    }
-
-    @Override
-    public void updateSettings(Map<String, String> settings, 
AuthenticationInfo subject) {
-
-    }
-
-    public void reset() {
-      this.notes.clear();
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/085efeb6/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
index 609f16c..524dde7 100644
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
@@ -65,7 +65,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
   @Test
   public void scriptBodyWithReplName() {
     Note note = createNote();
-    Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
+    Paragraph paragraph = new Paragraph(note, null);
     paragraph.setText("%test(1234567");
     assertEquals("test", paragraph.getIntpText());
     assertEquals("(1234567", paragraph.getScriptText());
@@ -78,7 +78,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
   @Test
   public void scriptBodyWithoutReplName() {
     Note note = createNote();
-    Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
+    Paragraph paragraph = new Paragraph(note, null);
     paragraph.setText("1234567");
     assertEquals("", paragraph.getIntpText());
     assertEquals("1234567", paragraph.getScriptText());
@@ -87,7 +87,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
   @Test
   public void replNameAndNoBody() {
     Note note = createNote();
-    Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
+    Paragraph paragraph = new Paragraph(note, null);
     paragraph.setText("%test");
     assertEquals("test", paragraph.getIntpText());
     assertEquals("", paragraph.getScriptText());
@@ -96,7 +96,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
   @Test
   public void replSingleCharName() {
     Note note = createNote();
-    Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
+    Paragraph paragraph = new Paragraph(note, null);
     paragraph.setText("%r a");
     assertEquals("r", paragraph.getIntpText());
     assertEquals("a", paragraph.getScriptText());
@@ -105,7 +105,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
   @Test
   public void testParagraphProperties() {
     Note note = createNote();
-    Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
+    Paragraph paragraph = new Paragraph(note, null);
     paragraph.setText("%test(p1=v1,p2=v2) a");
     assertEquals("test", paragraph.getIntpText());
     assertEquals("a", paragraph.getScriptText());
@@ -137,14 +137,14 @@ public class ParagraphTest extends 
AbstractInterpreterTest {
     expectedEx.expectMessage("Invalid paragraph properties format");
 
     Note note = createNote();
-    Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
+    Paragraph paragraph = new Paragraph(note, null);
     paragraph.setText("%test(p1=v1=v2) a");
   }
 
   @Test
   public void replInvalid() {
     Note note = createNote();
-    Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
+    Paragraph paragraph = new Paragraph(note, null);
     paragraph.setText("foo %r");
     assertEquals("", paragraph.getIntpText());
     assertEquals("foo %r", paragraph.getScriptText());
@@ -161,7 +161,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
   @Test
   public void replNameEndsWithWhitespace() {
     Note note = createNote();
-    Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
+    Paragraph paragraph = new Paragraph(note, null);
     paragraph.setText("%test\r\n###Hello");
     assertEquals("test", paragraph.getIntpText());
     assertEquals("###Hello", paragraph.getScriptText());
@@ -214,7 +214,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
     final String scriptBody = "My name is ${name} and I am ${age=20} years 
old. " +
             "My occupation is ${ job = engineer | developer | artists}";
 
-    final Paragraph paragraph = new Paragraph(note, null, null);
+    final Paragraph paragraph = new Paragraph(note, null);
     final String paragraphId = paragraph.getId();
 
     final AngularObject nameAO = AngularObjectBuilder.build("name", "DuyHai 
DOAN", noteId,
@@ -240,7 +240,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
 
   @Test
   public void returnDefaultParagraphWithNewUser() {
-    Paragraph p = new Paragraph("para_1", null, null, null);
+    Paragraph p = new Paragraph("para_1", null, null);
     String defaultValue = "Default Value";
     p.setResult(new InterpreterResult(Code.SUCCESS, defaultValue));
     Paragraph newUserParagraph = p.getUserParagraph("new_user");
@@ -252,7 +252,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
   public void returnUnchangedResultsWithDifferentUser() throws Throwable {
     Note mockNote = mock(Note.class);
     when(mockNote.getCredentials()).thenReturn(mock(Credentials.class));
-    Paragraph spyParagraph = spy(new Paragraph("para_1", mockNote,  null, 
null));
+    Paragraph spyParagraph = spy(new Paragraph("para_1", mockNote,  null));
 
     Interpreter mockInterpreter = mock(Interpreter.class);
     spyParagraph.setInterpreter(mockInterpreter);

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/085efeb6/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java
 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java
index 52be4fa..35484d4 100644
--- 
a/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java
+++ 
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/search/LuceneSearchTest.java
@@ -19,47 +19,51 @@ package org.apache.zeppelin.search;
 import static com.google.common.truth.Truth.assertThat;
 import static org.apache.zeppelin.search.LuceneSearch.formatId;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import com.google.common.base.Splitter;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import org.apache.zeppelin.conf.ZeppelinConfiguration;
 import org.apache.zeppelin.interpreter.InterpreterFactory;
+import org.apache.zeppelin.interpreter.InterpreterSetting;
 import org.apache.zeppelin.interpreter.InterpreterSettingManager;
 import org.apache.zeppelin.notebook.Note;
+import org.apache.zeppelin.notebook.NoteEventListener;
+import org.apache.zeppelin.notebook.Notebook;
+import org.apache.zeppelin.notebook.NotebookAuthorization;
 import org.apache.zeppelin.notebook.Paragraph;
+import org.apache.zeppelin.notebook.ParagraphJobListener;
 import org.apache.zeppelin.notebook.repo.NotebookRepo;
 import org.apache.zeppelin.user.AuthenticationInfo;
+import org.apache.zeppelin.user.Credentials;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.quartz.SchedulerException;
 
 public class LuceneSearchTest {
 
-  private static NotebookRepo notebookRepoMock;
-  private static InterpreterFactory interpreterFactory;
-  private static InterpreterSettingManager interpreterSettingManager;
-
+  private Notebook notebook;
+  private InterpreterSettingManager interpreterSettingManager;
   private SearchService noteSearchService;
-  private AuthenticationInfo anonymous;
-
-  @BeforeClass
-  public static void beforeStartUp() {
-    notebookRepoMock = mock(NotebookRepo.class);
-    interpreterFactory = mock(InterpreterFactory.class);
-    interpreterSettingManager = mock(InterpreterSettingManager.class);
 
-    //    when(replLoaderMock.getInterpreterSettings())
-    //      .thenReturn(ImmutableList.<InterpreterSetting>of());
-  }
 
   @Before
-  public void startUp() {
+  public void startUp() throws IOException, SchedulerException {
     noteSearchService = new LuceneSearch(ZeppelinConfiguration.create());
-    anonymous = new AuthenticationInfo("anonymous");
+    interpreterSettingManager = mock(InterpreterSettingManager.class);
+    InterpreterSetting defaultInterpreterSetting = 
mock(InterpreterSetting.class);
+    when(defaultInterpreterSetting.getName()).thenReturn("test");
+    
when(interpreterSettingManager.getDefaultInterpreterSetting()).thenReturn(defaultInterpreterSetting);
+    notebook = new Notebook(ZeppelinConfiguration.create(), 
mock(NotebookRepo.class),
+        mock(InterpreterFactory.class), interpreterSettingManager,
+        noteSearchService, mock(NotebookAuthorization.class),
+        mock(Credentials.class));
   }
 
   @After
@@ -68,7 +72,7 @@ public class LuceneSearchTest {
   }
 
   @Test
-  public void canIndexNotebook() {
+  public void canIndexNotebook() throws IOException {
     // give
     Note note1 = newNoteWithParagraph("Notebook1", "test");
     Note note2 = newNoteWithParagraph("Notebook2", "not test");
@@ -78,12 +82,12 @@ public class LuceneSearchTest {
     noteSearchService.addIndexDocs(notebook);
   }
 
-  @Test
-  public void canIndexAndQuery() {
+//  @Test
+  public void canIndexAndQuery() throws IOException, InterruptedException {
     // given
     Note note1 = newNoteWithParagraph("Notebook1", "test");
     Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at 
all");
-    noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
+    noteSearchService.drainEvents();
 
     // when
     List<Map<String, String>> results = noteSearchService.query("all");
@@ -96,11 +100,11 @@ public class LuceneSearchTest {
   }
 
   @Test
-  public void canIndexAndQueryByNotebookName() {
+  public void canIndexAndQueryByNotebookName() throws IOException, 
InterruptedException {
     // given
     Note note1 = newNoteWithParagraph("Notebook1", "test");
     Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at 
all");
-    noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
+    noteSearchService.drainEvents();
 
     // when
     List<Map<String, String>> results = noteSearchService.query("Notebook1");
@@ -112,7 +116,7 @@ public class LuceneSearchTest {
   }
 
   @Test
-  public void canIndexAndQueryByParagraphTitle() {
+  public void canIndexAndQueryByParagraphTitle() throws IOException {
     // given
     Note note1 = newNoteWithParagraph("Notebook1", "test", 
"testingTitleSearch");
     Note note2 = newNoteWithParagraph("Notebook2", "not test", 
"notTestingTitleSearch");
@@ -187,15 +191,16 @@ public class LuceneSearchTest {
   }
 
   @Test
-  public void canDeleteFromIndex() throws IOException {
+  public void canDeleteFromIndex() throws IOException, InterruptedException {
     // given
     Note note1 = newNoteWithParagraph("Notebook1", "test");
     Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at 
all");
-    noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
+    noteSearchService.drainEvents();
+
     assertThat(resultForQuery("Notebook2")).isNotEmpty();
 
     // when
-    noteSearchService.deleteIndexDocs(note2);
+    noteSearchService.deleteIndexDocs(note2.getId());
 
     // then
     assertThat(noteSearchService.query("all")).isEmpty();
@@ -207,17 +212,19 @@ public class LuceneSearchTest {
   }
 
   @Test
-  public void indexParagraphUpdatedOnNoteSave() throws IOException {
+  public void indexParagraphUpdatedOnNoteSave() throws IOException, 
InterruptedException {
     // given: total 2 notebooks, 3 paragraphs
     Note note1 = newNoteWithParagraph("Notebook1", "test");
     Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at 
all");
-    noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
+    noteSearchService.drainEvents();
+
     assertThat(resultForQuery("test").size()).isEqualTo(3);
 
     // when
     Paragraph p1 = note1.getLastParagraph();
     p1.setText("no no no");
-    note1.persist(anonymous);
+    notebook.saveNote(note1, AuthenticationInfo.ANONYMOUS);
+    noteSearchService.drainEvents();
 
     // then
     assertThat(resultForQuery("Notebook1").size()).isEqualTo(1);
@@ -229,22 +236,22 @@ public class LuceneSearchTest {
     // does not include Notebook1's paragraph any more
     for (Map<String, String> result : results) {
       assertThat(result.get("id").startsWith(note1.getId())).isFalse();
-      ;
     }
   }
 
   @Test
-  public void indexNoteNameUpdatedOnNoteSave() throws IOException {
+  public void indexNoteNameUpdatedOnNoteSave() throws IOException, 
InterruptedException {
     // given: total 2 notebooks, 3 paragraphs
     Note note1 = newNoteWithParagraph("Notebook1", "test");
     Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at 
all");
-    noteSearchService.addIndexDocs(Arrays.asList(note1, note2));
+    noteSearchService.drainEvents();
     assertThat(resultForQuery("test").size()).isEqualTo(3);
 
     // when
     note1.setName("NotebookN");
-    note1.persist(anonymous);
-
+    notebook.saveNote(note1, AuthenticationInfo.ANONYMOUS);
+    noteSearchService.drainEvents();
+    Thread.sleep(1000);
     // then
     assertThat(resultForQuery("Notebook1")).isEmpty();
     assertThat(resultForQuery("NotebookN")).isNotEmpty();
@@ -262,20 +269,20 @@ public class LuceneSearchTest {
    * @param parText text of the paragraph
    * @return Note
    */
-  private Note newNoteWithParagraph(String noteName, String parText) {
+  private Note newNoteWithParagraph(String noteName, String parText) throws 
IOException {
     Note note1 = newNote(noteName);
     addParagraphWithText(note1, parText);
     return note1;
   }
 
-  private Note newNoteWithParagraph(String noteName, String parText, String 
title) {
+  private Note newNoteWithParagraph(String noteName, String parText, String 
title) throws IOException {
     Note note = newNote(noteName);
     addParagraphWithTextAndTitle(note, parText, title);
     return note;
   }
 
   /** Creates a new Note \w given name, adds N paragraphs \w given texts */
-  private Note newNoteWithParagraphs(String noteName, String... parTexts) {
+  private Note newNoteWithParagraphs(String noteName, String... parTexts) 
throws IOException {
     Note note1 = newNote(noteName);
     for (String parText : parTexts) {
       addParagraphWithText(note1, parText);
@@ -296,19 +303,8 @@ public class LuceneSearchTest {
     return p;
   }
 
-  private Note newNote(String name) {
-    Note note =
-        new Note(
-            "test",
-            "test",
-            notebookRepoMock,
-            interpreterFactory,
-            interpreterSettingManager,
-            null,
-            noteSearchService,
-            null,
-            null);
-    note.setName(name);
+  private Note newNote(String name) throws IOException {
+    Note note = notebook.createNote(name, AuthenticationInfo.ANONYMOUS);
     return note;
   }
 }

Reply via email to