use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.
the class ScalaEvaluatorTest method evaluatePlot_shouldCreatePlotObject.
@Test
public void evaluatePlot_shouldCreatePlotObject() throws Exception {
// given
String code = "import com.twosigma.beakerx.chart.xychart.Plot;\n" + "val plot = new Plot();\n" + "plot.setTitle(\"test title\");";
SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
// when
TryResult evaluate = scalaEvaluator.evaluate(seo, code);
// then
assertThat(evaluate.result() instanceof Plot).isTrue();
assertThat(((Plot) evaluate.result()).getTitle()).isEqualTo("test title");
}
use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.
the class CombinedPlotSerializerTest method serializePlotTypeOfCombinedPlot_resultJsonHasPlotType.
@Test
public void serializePlotTypeOfCombinedPlot_resultJsonHasPlotType() throws IOException {
// when
CombinedPlot combinedPlot = new CombinedPlot();
combinedPlot.add(new Plot());
combinedPlot.add(new Plot());
combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
jgen.flush();
// then
JsonNode actualObj = mapper.readTree(sw.toString());
Assertions.assertThat(actualObj.has("plot_type")).isTrue();
Assertions.assertThat(actualObj.get("plot_type").asText()).isEqualTo("Plot");
}
use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.
the class CombinedPlotSerializerTest method serializePlotsOfCombinedPlot_resultJsonHasPlots.
@Test
public void serializePlotsOfCombinedPlot_resultJsonHasPlots() throws IOException {
// when
CombinedPlot combinedPlot = new CombinedPlot();
combinedPlot.add(new Plot());
combinedPlot.add(new Plot());
combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
jgen.flush();
// then
JsonNode actualObj = mapper.readTree(sw.toString());
Assertions.assertThat(actualObj.has("plots")).isTrue();
Assertions.assertThat(actualObj.get("plots")).isNotEmpty();
}
use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.
the class ChartObjectManagerTest method registerChart_containsThatChart.
@Test
public void registerChart_containsThatChart() {
Chart chart = new Plot();
// when
chartObjectManager.registerChart("id1", chart);
// then
Assertions.assertThat(chartObjectManager.getChart("id1")).isEqualTo(chart);
}
use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.
the class GroovyEvaluatorChartTest method parsePlotWithTitleScript_returnPlotObjectWithTitle.
@Test
public void parsePlotWithTitleScript_returnPlotObjectWithTitle() {
// when
Object result = parseClassFromScript("def plot = new Plot(title: \"Setting line properties\")");
// then
Assertions.assertThat(result instanceof Plot).isTrue();
Plot plot = (Plot) result;
Assertions.assertThat(plot.getTitle()).isEqualTo("Setting line properties");
}
Aggregations