Search in sources :

Example 1 with CategoryBars

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

the class CategoryBarsSerializerTest method serializeWidthCategoryBars_resultJsonHasWidth.

@Test
public void serializeWidthCategoryBars_resultJsonHasWidth() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setWidth(11);
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("width")).isTrue();
    Assertions.assertThat(actualObj.get("width").asInt()).isEqualTo(11);
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 2 with CategoryBars

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

the class CategoryBarsSerializerTest method serializeWidthsCategoryBars_resultJsonHasWidths.

@Test
public void serializeWidthsCategoryBars_resultJsonHasWidths() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setWidth(Arrays.asList(11, 22, 33));
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("widths")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("widths");
    Assertions.assertThat(arrayNode.get(1).asInt()).isEqualTo(22);
}
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 3 with CategoryBars

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

the class CategoryBarsSerializerTest method serializeOutlineColorsCategoryBars_resultJsonHasOutlineColors.

@Test
public void serializeOutlineColorsCategoryBars_resultJsonHasOutlineColors() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setOutlineColor(Arrays.asList(Color.BLUE, Color.GREEN, Color.BLACK));
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("outline_colors")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("outline_colors");
    Assertions.assertThat(arrayNode.get(1).get("rgb").asInt()).isEqualTo(Color.GREEN.getRGB());
}
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 4 with CategoryBars

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

the class CategoryBarsSerializerTest method serializeBasesCategoryBars_resultJsonHasBases.

@Test
public void serializeBasesCategoryBars_resultJsonHasBases() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setBase(Arrays.asList(11, 22, 33));
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("bases")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("bases");
    Assertions.assertThat(arrayNode.get(1).asInt()).isEqualTo(22);
}
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 5 with CategoryBars

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

the class CategoryBarsSerializerTest method serializeFillCategoryBars_resultJsonHasFill.

@Test
public void serializeFillCategoryBars_resultJsonHasFill() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setFill(true);
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("fill")).isTrue();
    Assertions.assertThat(actualObj.get("fill").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) Test(org.junit.Test)

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