IgniteInterpreter extends Interpreter { @Override public InterpreterResult interpret(String line, InterpreterContext context) { if (initEx != null) { return IgniteInterpreterUtils.buildErrorResult(initEx); } if (line == null || line.trim().length() == 0) { return new InterpreterResult(Code.SUCCESS); } return interpret(line.split("\n")); } IgniteInterpreter(Properties property); @Override void open(); Object getValue(String name); @Override void close(); @Override InterpreterResult interpret(String line, InterpreterContext context); @Override void cancel(InterpreterContext context); @Override FormType getFormType(); @Override int getProgress(InterpreterContext context); @Override List<InterpreterCompletion> completion(String buf, int cursor); @Override Scheduler getScheduler();  }
@Test public void testInterpret() { String sizeVal = "size"; InterpreterResult result = intp.interpret("import org.apache.ignite.IgniteCache\n" + "val " + sizeVal + " = ignite.cluster().nodes().size()", INTP_CONTEXT); assertEquals(InterpreterResult.Code.SUCCESS, result.code()); assertTrue(result.message().contains(sizeVal + ": Int = " + ignite.cluster().nodes().size())); result = intp.interpret("\"123\"\n .toInt", INTP_CONTEXT); assertEquals(InterpreterResult.Code.SUCCESS, result.code()); }
@Test public void testInterpretInvalidInput() { InterpreterResult result = intp.interpret("invalid input", INTP_CONTEXT); assertEquals(InterpreterResult.Code.ERROR, result.code()); }