Search in sources :

Example 6 with CategoryPoints

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

the class CategoryPointsSerializerTest method serializeShapeCategoryPoints_resultJsonHasShape.

@Test
public void serializeShapeCategoryPoints_resultJsonHasShape() throws IOException {
    // when
    CategoryPoints categoryPoints = new CategoryPoints();
    categoryPoints.setShape(ShapeType.CIRCLE);
    categoryPointsSerializer.serialize(categoryPoints, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("shape")).isTrue();
    Assertions.assertThat(actualObj.get("shape").asText()).isEqualTo("CIRCLE");
}
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 7 with CategoryPoints

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

the class CategoryPointsSerializerTest method serializeFillsCategoryPoints_resultJsonHasFills.

@Test
public void serializeFillsCategoryPoints_resultJsonHasFills() throws IOException {
    // when
    CategoryPoints categoryPoints = new CategoryPoints();
    categoryPoints.setFill(Arrays.asList(false, true, false));
    categoryPointsSerializer.serialize(categoryPoints, 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 : 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 8 with CategoryPoints

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

the class CategoryPointsSerializerTest method serializeShapesCategoryPoints_resultJsonHasShapes.

@Test
public void serializeShapesCategoryPoints_resultJsonHasShapes() throws IOException {
    // when
    CategoryPoints categoryPoints = new CategoryPoints();
    categoryPoints.setShape(Arrays.asList(ShapeType.CIRCLE, ShapeType.TRIANGLE));
    categoryPointsSerializer.serialize(categoryPoints, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("shaps")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("shaps");
    Assertions.assertThat(arrayNode.get(1).asText()).isEqualTo("TRIANGLE");
}
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 9 with CategoryPoints

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

the class CategoryPointsSerializerTest method serializeOutlineColorsCategoryPoints_resultJsonHasOutlineColors.

@Test
public void serializeOutlineColorsCategoryPoints_resultJsonHasOutlineColors() throws IOException {
    // when
    CategoryPoints categoryPoints = new CategoryPoints();
    categoryPoints.setOutlineColor(Arrays.asList(Color.BLUE, Color.GREEN, Color.BLACK));
    categoryPointsSerializer.serialize(categoryPoints, 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 : 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 10 with CategoryPoints

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

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