use of org.apache.zeppelin.rest.message.NewParagraphRequest in project zeppelin by apache.
the class ClusterEventTest method insertParagraphEvent.
@Test
public void insertParagraphEvent() throws IOException {
String noteId = null;
try {
// Create note and set result explicitly
noteId = TestUtils.getInstance(Notebook.class).createNote("note1", anonymous);
TestUtils.getInstance(Notebook.class).processNote(noteId, note -> {
Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.TEXT, "result");
p1.setResult(result);
return null;
});
// insert new paragraph
NewParagraphRequest newParagraphRequest = new NewParagraphRequest();
CloseableHttpResponse post = AbstractTestRestApi.httpPost("/notebook/" + noteId + "/paragraph", newParagraphRequest.toJson());
LOG.info("test clear paragraph output response\n" + EntityUtils.toString(post.getEntity(), StandardCharsets.UTF_8));
assertThat(post, AbstractTestRestApi.isAllowed());
post.close();
// wait cluster sync event
Thread.sleep(1000);
checkClusterNoteEventListener();
} catch (InterruptedException e) {
LOGGER.error(e.getMessage(), e);
} finally {
// cleanup
if (null != noteId) {
TestUtils.getInstance(Notebook.class).removeNote(noteId, anonymous);
}
}
}
Aggregations