Search in sources :

Example 1 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class ConstantBandSerializerTest method serializeConstantBand_resultJsonHasType.

@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");
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 2 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class ConstantBandSerializerTest method serializeXConstantBand_resultJsonHasX.

@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();
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 3 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class ConstantBandSerializerTest method serializeYAxisConstantBand_resultJsonHasYAxis.

@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");
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 4 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class ConstantBandSerializerTest method serializeYConstantBand_resultJsonHasY.

@Test
public void serializeYConstantBand_resultJsonHasY() throws IOException {
    // when
    ConstantBand constantBand = new ConstantBand();
    constantBand.setY(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("y")).isTrue();
    Assertions.assertThat(actualObj.get("y")).isNotEmpty();
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 5 with ConstantBand

use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.

the class PlotTest method addListOfPlotObjects_hasAllPlotObjects.

@Test
public void addListOfPlotObjects_hasAllPlotObjects() {
    // given
    Rasters rasters = new Rasters();
    List<Number> value = Collections.singletonList(1);
    rasters.setY(value);
    rasters.setWidth(value);
    rasters.setHeight(value);
    // when
    plot.add(Arrays.asList(line, new ConstantLine(), new ConstantBand(), rasters, new Text()));
    // then
    assertThat(plot.getGraphics().size()).isEqualTo(1);
    assertThat(plot.getConstantLines().size()).isEqualTo(1);
    assertThat(plot.getConstantBands().size()).isEqualTo(1);
    assertThat(plot.getRasters().size()).isEqualTo(1);
    assertThat(plot.getTexts().size()).isEqualTo(1);
}
Also used : Rasters(com.twosigma.beakerx.chart.xychart.plotitem.Rasters) ConstantBand(com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand) Text(com.twosigma.beakerx.chart.xychart.plotitem.Text) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) Test(org.junit.Test)

Aggregations

ConstantBand (com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand)11 Test (org.junit.Test)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)8 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 KernelTest (com.twosigma.beakerx.KernelTest)1 AbstractChartTest (com.twosigma.beakerx.chart.AbstractChartTest)1 ConstantLine (com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine)1 Rasters (com.twosigma.beakerx.chart.xychart.plotitem.Rasters)1 Text (com.twosigma.beakerx.chart.xychart.plotitem.Text)1 BigInteger (java.math.BigInteger)1 Map (java.util.Map)1