Search in sources :

Example 1 with NewParagraphRequest

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);
        }
    }
}
Also used : Notebook(org.apache.zeppelin.notebook.Notebook) NewParagraphRequest(org.apache.zeppelin.rest.message.NewParagraphRequest) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Paragraph(org.apache.zeppelin.notebook.Paragraph) Test(org.junit.Test)

Aggregations

CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1 Notebook (org.apache.zeppelin.notebook.Notebook)1 Paragraph (org.apache.zeppelin.notebook.Paragraph)1 NewParagraphRequest (org.apache.zeppelin.rest.message.NewParagraphRequest)1 Test (org.junit.Test)1