Search in sources :

Example 31 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class PegdownParserTest method testStrikethrough.

@Test
public void testStrikethrough() {
    InterpreterResult result = md.interpret("This is ~~deleted~~ text", null);
    assertEquals(wrapWithMarkdownClassDiv("<p>This is <del>deleted</del> text</p>"), result.message().get(0).getData());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Test(org.junit.Test)

Example 32 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class PegdownParserTest method testUnorderedList.

@Test
public void testUnorderedList() {
    String input = new StringBuilder().append("* Unordered list can use asterisks\n").append("- Or minuses\n").append("+ Or pluses").toString();
    String expected = new StringBuilder().append("<ul>\n").append("  <li>Unordered list can use asterisks</li>\n").append("  <li>Or minuses</li>\n").append("  <li>Or pluses</li>\n").append("</ul>").toString();
    InterpreterResult result = md.interpret(input, null);
    assertEquals(wrapWithMarkdownClassDiv(expected), result.message().get(0).getData());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Test(org.junit.Test)

Example 33 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class PegdownParserTest method testWebsequencePlugin.

@Test
public void testWebsequencePlugin() {
    String input = new StringBuilder().append("\n \n %%% sequence style=modern-blue\n").append("title Authentication Sequence\n").append("Alice->Bob: Authentication Request\n").append("note right of Bob: Bob thinks about it\n").append("Bob->Alice: Authentication Response\n").append("  %%%  ").toString();
    InterpreterResult result = md.interpret(input, null);
    // assert statement below can fail depends on response of websequence service.
    // To make unittest independent from websequence service,
    // catch exception, log and pass instead of assert.
    //
    //assertThat(result.message().get(0).getData(), CoreMatchers.containsString("<img src=\"http://www.websequencediagrams.com/?png="));
    System.err.println(result.message().get(0).getData());
    if (!result.message().get(0).getData().contains("<img src=\"http://www.websequencediagrams.com/?png=")) {
        logger.error("Expected {} but found {}", "<img src=\"http://www.websequencediagrams.com/?png=", result.message().get(0).getData());
    }
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Test(org.junit.Test)

Example 34 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class PegdownParserTest method testSimpleTable.

@Test
public void testSimpleTable() {
    String input = new StringBuilder().append("MarkdownInterpreter | Less | Pretty\n").append("--- | --- | ---\n").append("*Still* | `renders` | **nicely**\n").append("1 | 2 | 3").toString();
    String expected = new StringBuilder().append("<table>\n").append("  <thead>\n").append("    <tr>\n").append("      <th>MarkdownInterpreter </th>\n").append("      <th>Less </th>\n").append("      <th>Pretty</th>\n").append("    </tr>\n").append("  </thead>\n").append("  <tbody>\n").append("    <tr>\n").append("      <td><em>Still</em> </td>\n").append("      <td><code>renders</code> </td>\n").append("      <td><strong>nicely</strong></td>\n").append("    </tr>\n").append("    <tr>\n").append("      <td>1 </td>\n").append("      <td>2 </td>\n").append("      <td>3</td>\n").append("    </tr>\n").append("  </tbody>\n").append("</table>").toString();
    InterpreterResult result = md.interpret(input, null);
    assertEquals(wrapWithMarkdownClassDiv(expected), result.message().get(0).getData());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Test(org.junit.Test)

Example 35 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class PegdownParserTest method testOrderedList.

@Test
public void testOrderedList() {
    String input = new StringBuilder().append("1. First ordered list item\n").append("2. Another item").toString();
    String expected = new StringBuilder().append("<ol>\n").append("  <li>First ordered list item</li>\n").append("  <li>Another item</li>\n").append("</ol>").toString();
    InterpreterResult result = md.interpret(input, null);
    assertEquals(wrapWithMarkdownClassDiv(expected), result.message().get(0).getData());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Test(org.junit.Test)

Aggregations

InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)159 Test (org.junit.Test)68 Properties (java.util.Properties)17 File (java.io.File)10 IOException (java.io.IOException)9 AlluxioURI (alluxio.AlluxioURI)8 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)7 Theory (org.junit.experimental.theories.Theory)7 FileWriter (java.io.FileWriter)6 PrintStream (java.io.PrintStream)5 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)5 Code (org.apache.zeppelin.interpreter.InterpreterResult.Code)5 InterpreterResultMessage (org.apache.zeppelin.interpreter.InterpreterResultMessage)5 ActionResponse (org.apache.zeppelin.elasticsearch.action.ActionResponse)4 FileInStream (alluxio.client.file.FileInStream)3 JsonObject (com.google.gson.JsonObject)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 SQLException (java.sql.SQLException)3 HashMap (java.util.HashMap)3