Add clearAllParagraphOutput unit test

This commit is contained in:
Mina Lee 2016-10-27 17:07:29 +09:00
parent 4adddb49d9
commit 98d7604a0f

View file

@ -17,8 +17,10 @@
package org.apache.zeppelin.notebook;
import org.apache.zeppelin.helium.HeliumPackage;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterFactory;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.notebook.repo.NotebookRepo;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.search.SearchService;
@ -125,4 +127,23 @@ public class NoteTest {
assertNull(p2.getText());
}
@Test
public void clearAllParagraphOutputTest() {
when(interpreterFactory.getInterpreter(anyString(), anyString(), eq("md"))).thenReturn(interpreter);
when(interpreter.getScheduler()).thenReturn(scheduler);
Note note = new Note(repo, interpreterFactory, jobListenerFactory, index, credentials, noteEventListener);
Paragraph p1 = note.addParagraph();
InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.TEXT, "result");
p1.setResult(result);
Paragraph p2 = note.addParagraph();
p2.setReturn(result, new Throwable());
note.clearAllParagraphOutput();
assertNull(p1.getReturn());
assertNull(p2.getReturn());
}
}