Notebook { @VisibleForTesting public List<Note> getAllNotes(Function<Note, Boolean> func){ return getAllNotes().stream() .filter(note -> func.apply(note)) .collect(Collectors.toList()); } Notebook(
      ZeppelinConfiguration conf,
      AuthorizationService authorizationService,
      NotebookRepo notebookRepo,
      NoteManager noteManager,
      InterpreterFactory replFactory,
      InterpreterSettingManager interpreterSettingManager,
      SearchService noteSearchService,
      Credentials credentials); @Inject  Notebook(
      ZeppelinConfiguration conf,
      AuthorizationService authorizationService,
      NotebookRepo notebookRepo,
      NoteManager noteManager,
      InterpreterFactory replFactory,
      InterpreterSettingManager interpreterSettingManager,
      SearchService noteSearchService,
      Credentials credentials,
      NoteEventListener noteEventListener); void recoveryIfNecessary(); NoteManager getNoteManager(); void setParagraphJobListener(ParagraphJobListener paragraphJobListener); Note createNote(String notePath,
                         AuthenticationInfo subject); Note createNote(String notePath,
                         AuthenticationInfo subject,
                         boolean save); Note createNote(String notePath,
                         String defaultInterpreterGroup,
                         AuthenticationInfo subject); Note createNote(String notePath,
                         String defaultInterpreterGroup,
                         AuthenticationInfo subject,
                         boolean save); String exportNote(String noteId); Note importNote(String sourceJson, String notePath, AuthenticationInfo subject); Note cloneNote(String sourceNoteId, String newNotePath, AuthenticationInfo subject); void removeNote(Note note, AuthenticationInfo subject); Note getNote(String noteId); Note getNote(String noteId, boolean reload); void saveNote(Note note, AuthenticationInfo subject); boolean containsNote(String notePath); boolean containsFolder(String folderPath); void moveNote(String noteId, String newNotePath, AuthenticationInfo subject); void moveFolder(String folderPath, String newFolderPath, AuthenticationInfo subject); void removeFolder(String folderPath, AuthenticationInfo subject); void emptyTrash(AuthenticationInfo subject); void restoreAll(AuthenticationInfo subject); Revision checkpointNote(String noteId, String notePath, String checkpointMessage,
      AuthenticationInfo subject); List<Revision> listRevisionHistory(String noteId,
                                            String notePath,
                                            AuthenticationInfo subject); Note setNoteRevision(String noteId, String notePath, String revisionId, AuthenticationInfo subject); Note getNoteByRevision(String noteId, String noteName,
                                String revisionId, AuthenticationInfo subject); @SuppressWarnings("rawtypes") Note loadNoteFromRepo(String id, AuthenticationInfo subject); void reloadAllNotes(AuthenticationInfo subject); List<NoteInfo> getNotesInfo(); Stream<Note> getNoteStream(); @VisibleForTesting List<Note> getAllNotes(Function<Note, Boolean> func); @VisibleForTesting List<Note> getAllNotes(); List<NoteInfo> getNotesInfo(Function<String, Boolean> func); List<InterpreterSetting> getBindedInterpreterSettings(String noteId); InterpreterFactory getInterpreterFactory(); InterpreterSettingManager getInterpreterSettingManager(); ZeppelinConfiguration getConf(); void close(); void addNotebookEventListener(NoteEventListener listener); Boolean isRevisionSupported();  }
@Test public void testGetAllNotes() throws Exception { Note note1 = notebook.createNote("note1", anonymous); Note note2 = notebook.createNote("note2", anonymous); assertEquals(2, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("anonymous"))).size()); authorizationService.setOwners(note1.getId(), Sets.newHashSet("user1")); authorizationService.setWriters(note1.getId(), Sets.newHashSet("user1")); authorizationService.setRunners(note1.getId(), Sets.newHashSet("user1")); authorizationService.setReaders(note1.getId(), Sets.newHashSet("user1")); assertEquals(1, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("anonymous"))).size()); assertEquals(2, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1"))).size()); authorizationService.setOwners(note2.getId(), Sets.newHashSet("user2")); authorizationService.setWriters(note2.getId(), Sets.newHashSet("user2")); authorizationService.setReaders(note2.getId(), Sets.newHashSet("user2")); authorizationService.setRunners(note2.getId(), Sets.newHashSet("user2")); assertEquals(0, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("anonymous"))).size()); assertEquals(1, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user1"))).size()); assertEquals(1, notebook.getAllNotes(note -> authorizationService.isReader(note.getId(), Sets.newHashSet("user2"))).size()); notebook.removeNote(note1, AuthenticationInfo.ANONYMOUS); notebook.removeNote(note2, AuthenticationInfo.ANONYMOUS); }