Search in sources :

Example 11 with CombinedPlot

use of com.twosigma.beakerx.chart.xychart.CombinedPlot 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");
}
Also used : SimpleTimePlot(com.twosigma.beakerx.chart.xychart.SimpleTimePlot) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Plot(com.twosigma.beakerx.chart.xychart.Plot) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 12 with CombinedPlot

use of com.twosigma.beakerx.chart.xychart.CombinedPlot 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();
}
Also used : SimpleTimePlot(com.twosigma.beakerx.chart.xychart.SimpleTimePlot) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Plot(com.twosigma.beakerx.chart.xychart.Plot) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 13 with CombinedPlot

use of com.twosigma.beakerx.chart.xychart.CombinedPlot in project beakerx by twosigma.

the class CombinedPlotSerializerTest method serializeXTickLabelsVisibleOfCombinedPlot_resultJsonHasXTickLabelsVisible.

@Test
public void serializeXTickLabelsVisibleOfCombinedPlot_resultJsonHasXTickLabelsVisible() throws IOException {
    // when
    CombinedPlot combinedPlot = new CombinedPlot();
    combinedPlot.setxTickLabelsVisible(true);
    combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("x_tickLabels_visible")).isTrue();
    Assertions.assertThat(actualObj.get("x_tickLabels_visible").asBoolean()).isTrue();
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 14 with CombinedPlot

use of com.twosigma.beakerx.chart.xychart.CombinedPlot in project beakerx by twosigma.

the class CombinedPlotSerializerTest method serializeInitWidthOfCombinedPlot_resultJsonHasInitWidth.

@Test
public void serializeInitWidthOfCombinedPlot_resultJsonHasInitWidth() throws IOException {
    // when
    CombinedPlot combinedPlot = new CombinedPlot();
    combinedPlot.setInitWidth(600);
    combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("init_width")).isTrue();
    Assertions.assertThat(actualObj.get("init_width").asInt()).isEqualTo(600);
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 15 with CombinedPlot

use of com.twosigma.beakerx.chart.xychart.CombinedPlot in project beakerx by twosigma.

the class GroovyEvaluatorChartTest method parseCombinedPlotScript_returnCombinedPlotObjectWithSubplots.

@Test
public void parseCombinedPlotScript_returnCombinedPlotObjectWithSubplots() {
    // when
    Object result = parseClassFromScript("def cplot = new CombinedPlot(xLabel: \"Linear\");\n" + "cplot.add(new Plot())\n" + "cplot.add(new Plot())\n" + "cplot");
    // then
    Assertions.assertThat(result instanceof CombinedPlot).isTrue();
    CombinedPlot combinedPlot = (CombinedPlot) result;
    Assertions.assertThat(combinedPlot.getSubplots()).isNotEmpty();
}
Also used : CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test)

Aggregations

CombinedPlot (com.twosigma.beakerx.chart.xychart.CombinedPlot)15 Test (org.junit.Test)14 KernelTest (com.twosigma.beakerx.KernelTest)13 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)12 SimpleTimePlot (com.twosigma.beakerx.chart.xychart.SimpleTimePlot)4 Plot (com.twosigma.beakerx.chart.xychart.Plot)3 CategoryPlot (com.twosigma.beakerx.chart.categoryplot.CategoryPlot)1 XYChart (com.twosigma.beakerx.chart.xychart.XYChart)1