Search in sources :

Example 6 with Revision

use of org.apache.zeppelin.notebook.repo.NotebookRepo.Revision in project zeppelin by apache.

the class GitNotebookRepoTest method getRevisionFailTest.

@Test
public void getRevisionFailTest() throws IOException {
    // initial checks
    notebookRepo = new GitNotebookRepo(conf);
    assertThat(notebookRepo.list(null)).isNotEmpty();
    assertThat(containsNote(notebookRepo.list(null), TEST_NOTE_ID)).isTrue();
    assertThat(notebookRepo.revisionHistory(TEST_NOTE_ID, null)).isEmpty();
    // add first checkpoint
    Revision revision_1 = notebookRepo.checkpoint(TEST_NOTE_ID, "first commit", null);
    assertThat(notebookRepo.revisionHistory(TEST_NOTE_ID, null).size()).isEqualTo(1);
    int paragraphCount_1 = notebookRepo.get(TEST_NOTE_ID, null).getParagraphs().size();
    // get current note
    Note note = notebookRepo.get(TEST_NOTE_ID, null);
    assertThat(note.getParagraphs().size()).isEqualTo(paragraphCount_1);
    // add one more paragraph and save
    Paragraph p1 = note.addParagraph(AuthenticationInfo.ANONYMOUS);
    Map<String, Object> config = p1.getConfig();
    config.put("enabled", true);
    p1.setConfig(config);
    p1.setText("get revision when modified note test text");
    notebookRepo.save(note, null);
    int paragraphCount_2 = note.getParagraphs().size();
    // get note from revision 1
    Note noteRevision_1 = notebookRepo.get(TEST_NOTE_ID, revision_1.id, null);
    assertThat(noteRevision_1.getParagraphs().size()).isEqualTo(paragraphCount_1);
    // get current note
    note = notebookRepo.get(TEST_NOTE_ID, null);
    assertThat(note.getParagraphs().size()).isEqualTo(paragraphCount_2);
    // test for absent revision
    Revision absentRevision = new Revision("absentId", StringUtils.EMPTY, 0);
    note = notebookRepo.get(TEST_NOTE_ID, absentRevision.id, null);
    assertThat(note).isNull();
}
Also used : Revision(org.apache.zeppelin.notebook.repo.NotebookRepo.Revision) Note(org.apache.zeppelin.notebook.Note) Paragraph(org.apache.zeppelin.notebook.Paragraph) Test(org.junit.Test)

Aggregations

Revision (org.apache.zeppelin.notebook.repo.NotebookRepo.Revision)6 Note (org.apache.zeppelin.notebook.Note)4 Paragraph (org.apache.zeppelin.notebook.Paragraph)4 Test (org.junit.Test)4 InterpreterResultMessage (org.apache.zeppelin.interpreter.InterpreterResultMessage)2 Message (org.apache.zeppelin.notebook.socket.Message)2 WatcherMessage (org.apache.zeppelin.notebook.socket.WatcherMessage)2 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)2