@Test public void serializeWidthStems_resultJsonHasWidth() throws IOException { //when stems.setWidth(11f); stemsSerializer.serialize(stems, 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 serializeColorStems_resultJsonHasColor() throws IOException { //when stems.setColor(Color.GREEN); stemsSerializer.serialize(stems, 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 serializeColorsPoints_resultJsonHasColors() throws IOException { //when points.setColor(Arrays.asList(Color.GREEN, Color.BLUE)); pointsSerializer.serialize(points, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("colors")).isTrue(); ArrayNode arrayNode = (ArrayNode) actualObj.get("colors"); Assertions.assertThat(arrayNode.get(1)).isNotEmpty(); }
@Test public void serializeShapePoints_resultJsonHasShape() throws IOException { //when points.setShape(ShapeType.CIRCLE); pointsSerializer.serialize(points, 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"); }
@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 serializeXConstantBand_resultJsonHasX() throws IOException { //when ConstantBand constantBand = new ConstantBand(); constantBand.setX(Arrays.asList(1, 2, 3)); constantBandSerializer.serialize(constantBand, 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 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 serializeInterpolationLine_resultJsonHasInterpolation() throws IOException { //when line.setInterpolation(1); lineSerializer.serialize(line, 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 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 serializeShowPointerText_resultJsonHasShowPointer() throws IOException { //when text.setShowPointer(true); textSerializer.serialize(text, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("show_pointer")).isTrue(); Assertions.assertThat(actualObj.get("show_pointer").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 serializeYAxisConstantLine_resultJsonHasYAxis() throws IOException { //when ConstantLine constantLine = new ConstantLine(); constantLine.setyAxis("Y Axis name"); constantLineSerializer.serialize(constantLine, 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 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(); }
@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"); }
@Test public void serializeBinCountOfHistogram_resultJsonHasBinCount() throws IOException { //when histogram.setBinCount(11); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("bin_count")).isTrue(); Assertions.assertThat(actualObj.get("bin_count").asInt()).isEqualTo(11); }
@Test public void serializeRangeMaxOfHistogram_resultJsonHasRangeMax() throws IOException { //when histogram.setRangeMax(11); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("range_max")).isTrue(); Assertions.assertThat(actualObj.get("range_max").asInt()).isEqualTo(11); }
@Test public void serializeRangeMinOfHistogram_resultJsonHasRangeMin() throws IOException { //when histogram.setRangeMin(11); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("range_min")).isTrue(); Assertions.assertThat(actualObj.get("range_min").asInt()).isEqualTo(11); }
@Test public void serializeColorOfHistogram_resultJsonHasColor() throws IOException { //when histogram.setColor(Color.GREEN); histogramSerializer.serialize(histogram, 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 serializeClickActionLineGraphics_resultJsonHasClickAction() throws IOException { //when line.onClick(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(); }
@Test public void serializeLineGraphics_resultJsonHasType() throws IOException { //when graphicsSerializer.serialize(line, 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("Line"); }