use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class EvaluatorBaseTest method returnHelloString.
@Test
public void returnHelloString() throws Exception {
// given
String code = codeForHello();
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult result = evaluator().evaluate(seo, code);
// then
assertThat((String) result.result()).contains("Hello");
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class EvaluatorBaseTest method returnPrintln.
@Test
public void returnPrintln() throws Exception {
// given
String code = codeForPrintln();
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult result = evaluator().evaluate(seo, code);
// then
assertThat((String) result.result()).isNull();
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class SQLCodeRunner method call.
@Override
public TryResult call() throws Exception {
TryResult either;
try {
InternalVariable.setValue(simpleEvaluationObject);
Object r = sqlEvaluator.executeQuery(simpleEvaluationObject.getExpression(), namespaceClient, sqlEvaluator.defaultConnectionString, sqlEvaluator.namedConnectionString);
either = TryResult.createResult(r);
} catch (SQLException e) {
either = TryResult.createError(e.toString());
} catch (ThreadDeath e) {
either = TryResult.createError(INTERUPTED_MSG);
} catch (ReadVariableException e) {
either = TryResult.createError(e.getMessage());
} catch (Throwable e) {
logger.error(e.getMessage());
either = TryResult.createError(e.toString());
}
return either;
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class SQLWorkerThread method call.
@Override
public TryResult call() throws Exception {
NamespaceClient namespaceClient = null;
TryResult r;
job.getSimpleEvaluationObject().started();
try {
job.getSimpleEvaluationObject().setOutputHandler();
namespaceClient = NamespaceClient.getBeaker(sqlEvaluator.getSessionId());
namespaceClient.setOutputObj(job.getSimpleEvaluationObject());
r = sqlEvaluator.executeTask(new SQLCodeRunner(sqlEvaluator, job.getSimpleEvaluationObject(), namespaceClient));
} finally {
job.getSimpleEvaluationObject().clrOutputHandler();
if (namespaceClient != null) {
namespaceClient.setOutputObj(null);
}
}
return r;
}
use of com.twosigma.beakerx.TryResult in project beakerx by twosigma.
the class KotlinEvaluatorTest method handleErrors.
@Test
public void handleErrors() throws Exception {
// given
String code = "val plot = UndefinedPlot()";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = evaluator.evaluate(seo, code);
// then
assertThat(evaluate.error()).contains("unresolved reference: UndefinedPlot");
}
Aggregations