Notebook { public Note cloneNote(String sourceNoteID, String newNoteName, AuthenticationInfo subject) throws IOException, CloneNotSupportedException, IllegalArgumentException { Note sourceNote = getNote(sourceNoteID); if (sourceNote == null) { throw new IllegalArgumentException(sourceNoteID + "not found"); } Note newNote = createNote(subject); if (newNoteName != null) { newNote.setName(newNoteName); } List<String> boundInterpreterSettingsIds = getBindedInterpreterSettingsIds(sourceNote.id()); bindInterpretersToNote(newNote.id(), boundInterpreterSettingsIds); List<Paragraph> paragraphs = sourceNote.getParagraphs(); for (Paragraph p : paragraphs) { newNote.addCloneParagraph(p); } notebookIndex.addIndexDoc(newNote); newNote.persist(subject); return newNote; } Notebook(ZeppelinConfiguration conf, NotebookRepo notebookRepo,
      SchedulerFactory schedulerFactory,
      InterpreterFactory replFactory, JobListenerFactory jobListenerFactory,
      SearchService notebookIndex,
      NotebookAuthorization notebookAuthorization,
      Credentials credentials); Note createNote(AuthenticationInfo subject); Note createNote(List<String> interpreterIds, AuthenticationInfo subject); String exportNote(String noteId); Note importNote(String sourceJson, String noteName, AuthenticationInfo subject); Note cloneNote(String sourceNoteID, String newNoteName, AuthenticationInfo subject); void bindInterpretersToNote(String id,
      List<String> interpreterSettingIds); List<String> getBindedInterpreterSettingsIds(String id); List<InterpreterSetting> getBindedInterpreterSettings(String id); Note getNote(String id); void removeNote(String id, AuthenticationInfo subject); void checkpointNote(String noteId, String checkpointMessage, AuthenticationInfo subject); void reloadAllNotes(AuthenticationInfo subject); List<Note> getAllNotes(); JobListenerFactory getJobListenerFactory(); void setJobListenerFactory(JobListenerFactory jobListenerFactory); List<Map<String, Object>> getJobListforNotebook(boolean needsReload,
      long lastUpdateServerUnixTime, AuthenticationInfo subject); void refreshCron(String id); InterpreterFactory getInterpreterFactory(); NotebookAuthorization getNotebookAuthorization(); ZeppelinConfiguration getConf(); void close();  }
@Test public void testCloneNote() throws IOException, CloneNotSupportedException, InterruptedException { Note note = notebook.createNote(null); note.getNoteReplLoader().setInterpreters(factory.getDefaultInterpreterSettingList()); final Paragraph p = note.addParagraph(); p.setText("hello world"); note.runAll(); while(p.isTerminated()==false || p.getResult()==null) Thread.yield(); p.setStatus(Status.RUNNING); Note cloneNote = notebook.cloneNote(note.getId(), "clone note", null); Paragraph cp = cloneNote.paragraphs.get(0); assertEquals(cp.getStatus(), Status.READY); assertEquals(cp.getId(), p.getId()); assertEquals(cp.text, p.text); assertEquals(cp.getResult().message(), p.getResult().message()); }