Search in sources :

Example 11 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class CategoryBarsSerializerTest method serializeDrawOutlinesCategoryBars_resultJsonHasDrawOutlines.

@Test
public void serializeDrawOutlinesCategoryBars_resultJsonHasDrawOutlines() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setDrawOutline(Arrays.asList(false, true, false));
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("outlines")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("outlines");
    Assertions.assertThat(arrayNode.get(1).asBoolean()).isTrue();
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Test(org.junit.Test)

Example 12 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class CategoryBarsSerializerTest method serializeFillsCategoryBars_resultJsonHasFills.

@Test
public void serializeFillsCategoryBars_resultJsonHasFills() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setFill(Arrays.asList(false, true, false));
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("fills")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("fills");
    Assertions.assertThat(arrayNode.get(1).asBoolean()).isTrue();
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Test(org.junit.Test)

Example 13 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class CategoryPlotSerializerTest method serializeGraphicsListCategoryPlot_resultJsonHasGraphicsList.

@Test
public void serializeGraphicsListCategoryPlot_resultJsonHasGraphicsList() throws IOException {
    // when
    CategoryPlot categoryPlot = new CategoryPlot();
    categoryPlot.add(Arrays.asList(new CategoryBars(), new CategoryPoints()));
    categoryPlotSerializer.serialize(categoryPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("graphics_list")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("graphics_list");
    Assertions.assertThat(arrayNode.size()).isEqualTo(2);
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) CategoryPoints(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 14 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class ItemLabelBuilderTest method setUp.

@Before
public void setUp() throws Exception {
    categoryGraphics = new CategoryBars();
    categoryGraphics.setValue(new Integer[] { new Integer(1), new Integer(2) });
    categoryGraphics.setSeriesNames(Arrays.asList("test series name"));
    categoryPlot = new CategoryPlot();
    categoryPlot.setCategoryNames(Arrays.asList("test category name"));
    categoryPlot.add(Arrays.asList(categoryGraphics));
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Before(org.junit.Before)

Example 15 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class CategoryPlotTest method initStubData.

@Before
public void initStubData() {
    array1 = new Integer[] { new Integer(1), new Integer(2) };
    array2 = new Integer[] { new Integer(3), new Integer(4) };
    categoryBars = new CategoryBars();
    categoryBars.setValue(new List[] { Arrays.asList(array1), Arrays.asList(array2) });
    categoryLines = new CategoryLines();
    categoryLines.setValue(new List[] { Arrays.asList(array1), Arrays.asList(array2) });
    categoryPoints = new CategoryPoints();
    categoryPoints.setValue(new List[] { Arrays.asList(array1), Arrays.asList(array2) });
    categoryStems = new CategoryStems();
    categoryStems.setValue(new List[] { Arrays.asList(array1), Arrays.asList(array2) });
}
Also used : CategoryLines(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryLines) CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) CategoryStems(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryStems) CategoryPoints(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints) Before(org.junit.Before)

Aggregations

CategoryBars (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars)16 Test (org.junit.Test)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)12 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)6 CategoryPlot (com.twosigma.beakerx.chart.categoryplot.CategoryPlot)3 CategoryPoints (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints)2 Before (org.junit.Before)2 KernelTest (com.twosigma.beakerx.KernelTest)1 AbstractChartTest (com.twosigma.beakerx.chart.AbstractChartTest)1 CategoryLines (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryLines)1 CategoryStems (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryStems)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1