SparkInterpreter extends Interpreter { @Override public InterpreterResult interpret(String line, InterpreterContext context) { if (sparkVersion.isUnsupportedVersion()) { return new InterpreterResult(Code.ERROR, "Spark " + sparkVersion.toString() + " is not supported"); } z.setInterpreterContext(context); if (line == null || line.trim().length() == 0) { return new InterpreterResult(Code.SUCCESS); } return interpret(line.split("\n"), context); } SparkInterpreter(Properties property);  SparkInterpreter(Properties property, SparkContext sc); SparkContext getSparkContext(); boolean isSparkContextInitialized(); SQLContext getSQLContext(); SparkDependencyResolver getDependencyResolver(); SparkContext createSparkContext(); static String getSystemDefault(
      String envName,
      String propertyName,
      String defaultValue); boolean printREPLOutput(); @Override void open(); @Override List<InterpreterCompletion> completion(String buf, int cursor); Object getValue(String name); @Override InterpreterResult interpret(String line, InterpreterContext context); InterpreterResult interpret(String[] lines, InterpreterContext context); InterpreterResult interpretInput(String[] lines, InterpreterContext context); @Override void cancel(InterpreterContext context); @Override int getProgress(InterpreterContext context); @Override void close(); @Override FormType getFormType(); JobProgressListener getJobProgressListener(); @Override Scheduler getScheduler(); ZeppelinContext getZeppelinContext(); SparkVersion getSparkVersion(); static Logger logger; }
@Test public void testBasicIntp() { assertEquals(InterpreterResult.Code.SUCCESS, repl.interpret("val a = 1\nval b = 2", context).code()); InterpreterResult incomplete = repl.interpret("val a = \"\"\"", context); assertEquals(InterpreterResult.Code.INCOMPLETE, incomplete.code()); assertTrue(incomplete.message().length() > 0); }
@Test public void testNextLineInvocation() { assertEquals(InterpreterResult.Code.SUCCESS, repl.interpret("\"123\"\n.toInt", context).code()); }
@Test public void testNextLineComments() { assertEquals(InterpreterResult.Code.SUCCESS, repl.interpret("\"123\"\n.toInt", context).code()); }
@Test public void testNextLineCompanionObject() { String code = "class Counter {\nvar value: Long = 0\n}\n assertEquals(InterpreterResult.Code.SUCCESS, repl.interpret(code, context).code()); }
@Test public void testEndWithComment() { assertEquals(InterpreterResult.Code.SUCCESS, repl.interpret("val c=1\n }
@Test public void testReferencingUndefinedVal() { InterpreterResult result = repl.interpret("def category(min: Int) = {" + " if (0 <= value) \"error\"" + "}", context); assertEquals(Code.ERROR, result.code()); }