@Test public void serializeBigIntXWithNanoPlotType_resultJsonHasStringXs() throws IOException { //when ConstantBand constantBand = new ConstantBand(); constantBand.setX( Arrays.asList( new BigInteger("12345678901234567891000"), new BigInteger("12345678901234567892000"))); constantBand.setPlotType(NanoPlot.class); constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("x")).isTrue(); ArrayNode arrayNode = (ArrayNode) actualObj.get("x"); Assertions.assertThat(arrayNode.get(0).isTextual()).isTrue(); }
@Test public void serializeDataOfHeatMap_resultJsonHasGraphicsList() throws IOException { //when HeatMap heatMap = new HeatMap(); heatMap.setData( new Integer[][] { new Integer[] {new Integer(1), new Integer(2)}, new Integer[] {new Integer(3), new Integer(4)} }); heatMapSerializer.serialize(heatMap, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("graphics_list")).isTrue(); Assertions.assertThat(actualObj.get("graphics_list")).isNotEmpty(); }
@Test public void serializeClickActionLineGraphics_resultJsonHasClickAction() throws IOException { //when Line line = new Line(); line.onClick( new GraphicsActionListener() { @Override public void execute(GraphicsActionObject actionObject) {} }); graphicsSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("hasClickAction")).isTrue(); Assertions.assertThat(actualObj.get("hasClickAction").asBoolean()).isTrue(); }
public JsonNode serializeObject(V value) throws IOException { StringWriter sw = new StringWriter(); JsonGenerator jgen = mapper.getFactory().createGenerator(sw); serializer.serialize(value, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); return mapper.readTree(sw.toString()); }
@Test public void serializeXOfXYGraphicsLine_resultJsonHasX() throws IOException { //when line.setX(Arrays.asList(1, 2, 3)); xyGraphicsSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("x")).isTrue(); Assertions.assertThat(actualObj.get("x")).isNotEmpty(); }
@Test public void serializeBigIntXWithNanoPlotType_resultJsonHasStringX() throws IOException { //when line.setX( Arrays.asList( new BigInteger("12345678901234567891000"), new BigInteger("12345678901234567891000"))); line.setPlotType(NanoPlot.class); xyGraphicsSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("x")).isTrue(); ArrayNode arrayNode = (ArrayNode) actualObj.get("x"); Assertions.assertThat(arrayNode.get(1).isTextual()).isTrue(); }
@Test public void serializeYOfXYGraphicsLine_resultJsonHasY() throws IOException { //when line.setY(Arrays.asList(1, 2, 3)); xyGraphicsSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("y")).isTrue(); Assertions.assertThat(actualObj.get("y")).isNotEmpty(); }
@Test public void serializeDataListListOfHistogram_resultJsonHasGraphicsList() throws IOException { //when histogram.setData(Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4))); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("graphics_list")).isTrue(); Assertions.assertThat(actualObj.get("graphics_list")).isNotEmpty(); }
@Test public void serializeLodFilterOfXYGraphicsLine_resultJsonHasLodFilter() throws IOException { //when line.setLodFilter(Filter.LINE); xyGraphicsSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("lod_filter")).isTrue(); Assertions.assertThat(actualObj.get("lod_filter").asText()).isEqualTo("line"); }
@Test public void serializeLogOfHistogram_resultJsonHasLog() throws IOException { //when histogram.setLog(true); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("log")).isTrue(); Assertions.assertThat(actualObj.get("log").asBoolean()).isTrue(); }
@Test public void serializeConstantBand_resultJsonHasType() throws IOException { //when ConstantBand constantBand = new ConstantBand(); constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("type")).isTrue(); Assertions.assertThat(actualObj.get("type").asText()).isEqualTo("ConstantBand"); }
@Test public void serializeDisplayModeOfHistogram_resultJsonHasDisplayMode() throws IOException { //when histogram.setDisplayMode(Histogram.DisplayMode.STACK); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("displayMode")).isTrue(); Assertions.assertThat(actualObj.get("displayMode").asText()).isEqualTo("STACK"); }
@Test public void serializeNamesOfHistogram_resultJsonHasNames() throws IOException { //when histogram.setNames(Arrays.asList("name1", "name2")); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("names")).isTrue(); ArrayNode arrayNode = (ArrayNode) actualObj.get("names"); Assertions.assertThat(arrayNode.get(1).asText()).isEqualTo("name2"); }
@Test public void serializeVisibleConstantBand_resultJsonHasVisible() throws IOException { //when ConstantBand constantBand = new ConstantBand(); constantBand.setVisible(true); constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("visible")).isTrue(); Assertions.assertThat(actualObj.get("visible").asBoolean()).isTrue(); }
@Test public void serializeYAxisConstantBand_resultJsonHasYAxis() throws IOException { //when ConstantBand constantBand = new ConstantBand(); constantBand.setyAxis("Y Axis name"); constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("yAxis")).isTrue(); Assertions.assertThat(actualObj.get("yAxis").asText()).isEqualTo("Y Axis name"); }
@Test public void serializeColorConstantBand_resultJsonHasColor() throws IOException { //when ConstantBand constantBand = new ConstantBand(); constantBand.setColor(Color.GREEN); constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("color")).isTrue(); Assertions.assertThat(actualObj.get("color").get("rgb").asInt()) .isEqualTo(Color.GREEN.getRGB()); }
@Test public void serializeTimePlotTypeOfCombinedPlot_resultJsonHasTimePlotType() throws IOException { //when CombinedPlot combinedPlot = new CombinedPlot(); combinedPlot.add( new SimpleTimePlot(createDataForSimpleTimePlot(), Arrays.asList("m3", "time"))); 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("TimePlot"); }
@Test public void serializeBaseOfBasedXYGraphics_resultJsonHasBase() throws IOException { //when Area area = new Area(); area.setBase(11); basedXYGraphicsSerializer.serialize(area, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("base")).isTrue(); Assertions.assertThat(actualObj.get("base").asInt()).isEqualTo(11); }
@Test public void serializeWidthCategoryLines_resultJsonHasWidth() throws IOException { //when CategoryLines categoryLines = new CategoryLines(); categoryLines.setWidth(11f); categoryLinesSerializer.serialize(categoryLines, 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); }
@Test public void serializeStrokeTypeStems_resultJsonHasStyle() throws IOException { //when CategoryLines categoryLines = new CategoryLines(); categoryLines.setStyle(StrokeType.SOLID); categoryLinesSerializer.serialize(categoryLines, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("style")).isTrue(); Assertions.assertThat(actualObj.get("style").asText()).isEqualTo("SOLID"); }
@Test public void serializeStrokeTypeListStems_resultJsonHasStyles() throws IOException { //when CategoryLines categoryLines = new CategoryLines(); categoryLines.setStyle(Arrays.asList(StrokeType.SOLID, StrokeType.DASHDOT)); categoryLinesSerializer.serialize(categoryLines, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("styles")).isTrue(); ArrayNode arrayNode = (ArrayNode) actualObj.get("styles"); Assertions.assertThat(arrayNode.get(1).asText()).isEqualTo("DASHDOT"); }
@Test public void serializeInterpolationCategoryLines_resultJsonHasInterpolation() throws IOException { //when CategoryLines categoryLines = new CategoryLines(); categoryLines.setInterpolation(1); categoryLinesSerializer.serialize(categoryLines, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("interpolation")).isTrue(); Assertions.assertThat(actualObj.get("interpolation").asInt()).isEqualTo(1); }
@Test public void serializeText_resultJsonHasType() throws IOException { //when textSerializer.serialize(text, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("type")).isTrue(); Assertions.assertThat(actualObj.get("type").asText()).isEqualTo("Text"); }
@Test public void serializeDataListOfHistogram_resultJsonHasGraphicsList() throws IOException { //when histogram.setData(Arrays.asList(1, 2)); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("graphics_list")).isTrue(); Assertions.assertThat(actualObj.get("graphics_list")).isNotEmpty(); }
@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); }
@Test public void serializeTextOfText_resultJsonHasText() throws IOException { //when text.setText("some text"); textSerializer.serialize(text, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("text")).isTrue(); Assertions.assertThat(actualObj.get("text").asText()).isEqualTo("some text"); }
@Test public void serializeOutlineColorCategoryBars_resultJsonHasOutlineColor() throws IOException { //when CategoryBars categoryBars = new CategoryBars(); categoryBars.setOutlineColor(Color.GREEN); categoryBarsSerializer.serialize(categoryBars, 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()); }
@Test public void serializeColorConstantLine_resultJsonHasColor() throws IOException { //when ConstantLine constantLine = new ConstantLine(); constantLine.setColor(Color.GREEN); constantLineSerializer.serialize(constantLine, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("color")).isTrue(); Assertions.assertThat(actualObj.get("color").get("rgb").asInt()) .isEqualTo(Color.GREEN.getRGB()); }
@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(); }
@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(); }
@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); }
@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(); }
@Test public void serializeLabelPositionCategoryBars_resultJsonHasLabelPosition() throws IOException { //when CategoryBars categoryBars = new CategoryBars(); categoryBars.setLabelPosition(LabelPositionType.CENTER); categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("labelPosition")).isTrue(); Assertions.assertThat(actualObj.get("labelPosition").asText()).isEqualTo("CENTER"); }
@Test public void serializeWidthBars_resultJsonHasWidth() throws IOException { //when Bars bars = new Bars(); bars.setWidth(11); barsSerializer.serialize(bars, 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); }
@Test public void serializeShowLabelConstantLine_resultJsonHasShowLabel() throws IOException { //when ConstantLine constantLine = new ConstantLine(); constantLine.setShowLabel(true); constantLineSerializer.serialize(constantLine, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("showLabel")).isTrue(); Assertions.assertThat(actualObj.get("showLabel").asBoolean()).isTrue(); }
@Test public void serializeCombinedPlot_resultJsonHasType() throws IOException { //when CombinedPlot combinedPlot = new CombinedPlot(); combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("type")).isTrue(); Assertions.assertThat(actualObj.get("type").asText()).isEqualTo("CombinedPlot"); }
@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); }
@Test public void serializeOutlineColorBars_resultJsonHasOutlineColor() throws IOException { //when Bars bars = new Bars(); bars.setOutlineColor(Color.GREEN); barsSerializer.serialize(bars, 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()); }
@Test public void serializeCumulativeOfHistogram_resultJsonHasCumulative() throws IOException { //when histogram.setCumulative(true); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("cumulative")).isTrue(); Assertions.assertThat(actualObj.get("cumulative").asBoolean()).isTrue(); }
@Test public void serializeBigIntXWithNanoPlotType_resultJsonHasStringX() throws IOException { //when text.setX(new BigInteger("12345678901234567891000")); text.setPlotType(NanoPlot.class); textSerializer.serialize(text, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("x")).isTrue(); Assertions.assertThat(actualObj.get("x").isTextual()).isTrue(); }