Search in sources :

Example 1 with CategoryPoints

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

the class CategoryPointsSerializerTest method serializeSizesCategoryPoints_resultJsonHasSizes.

@Test
public void serializeSizesCategoryPoints_resultJsonHasSizes() throws IOException {
    // when
    CategoryPoints categoryPoints = new CategoryPoints();
    categoryPoints.setSize(Arrays.asList(11, 22, 33));
    categoryPointsSerializer.serialize(categoryPoints, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("sizes")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("sizes");
    Assertions.assertThat(arrayNode.get(1).asInt()).isEqualTo(22);
}
Also used : 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) Test(org.junit.Test)

Example 2 with CategoryPoints

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

the class CategoryPointsSerializerTest method serializeFillCategoryPoints_resultJsonHasFill.

@Test
public void serializeFillCategoryPoints_resultJsonHasFill() throws IOException {
    // when
    CategoryPoints categoryPoints = new CategoryPoints();
    categoryPoints.setFill(true);
    categoryPointsSerializer.serialize(categoryPoints, 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 : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CategoryPoints(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints) Test(org.junit.Test)

Example 3 with CategoryPoints

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

the class CategoryPointsSerializerTest method serializeOutlineColorCategoryPoints_resultJsonHasOutlineColor.

@Test
public void serializeOutlineColorCategoryPoints_resultJsonHasOutlineColor() throws IOException {
    // when
    CategoryPoints categoryPoints = new CategoryPoints();
    categoryPoints.setOutlineColor(Color.GREEN);
    categoryPointsSerializer.serialize(categoryPoints, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("outline_color")).isTrue();
    Assertions.assertThat(actualObj.get("outline_color").get("rgb").asInt()).isEqualTo(Color.GREEN.getRGB());
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CategoryPoints(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints) Test(org.junit.Test)

Example 4 with CategoryPoints

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints 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 5 with CategoryPoints

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

the class CategoryPointsSerializerTest method serializeSizeCategoryPoints_resultJsonHasSize.

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

Aggregations

CategoryPoints (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)9 Test (org.junit.Test)9 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)5 CategoryBars (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars)2 KernelTest (com.twosigma.beakerx.KernelTest)1 CategoryPlot (com.twosigma.beakerx.chart.categoryplot.CategoryPlot)1 CategoryLines (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryLines)1 CategoryStems (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryStems)1 Before (org.junit.Before)1