use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.
the class ChartToJson method serializeConstantBands.
public static Map<Object, Object> serializeConstantBands(List<ConstantBand> constantBands) {
List result = new ArrayList();
for (ConstantBand item : constantBands) {
result.add(toJson(item));
}
Map<Object, Object> value = new LinkedHashMap<>();
value.put(XYChartSerializer.CONSTANT_BANDS, toJsonList(result));
return value;
}
use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.
the class XYChartSerializerTest method serializeConstantBandsOfXYChartPlot_resultJsonHasConstantBands.
@Test
public void serializeConstantBandsOfXYChartPlot_resultJsonHasConstantBands() throws IOException {
// given
ConstantBand constantBand = new ConstantBand();
plot.add(constantBand);
// when
xyChartSerializer.serialize(plot, jgen, new DefaultSerializerProvider.Impl());
jgen.flush();
// then
JsonNode actualObj = mapper.readTree(sw.toString());
Assertions.assertThat(actualObj.has("constant_bands")).isTrue();
Assertions.assertThat(actualObj.get("constant_bands")).isNotEmpty();
}
use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.
the class ConstantBandSerializerTest method serializeVisibleConstantBand_resultJsonHasVisible.
@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();
}
use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.
the class ConstantBandSerializerTest method serializeBigIntXWithNanoPlotType_resultJsonHasStringXs.
@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();
}
use of com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand in project beakerx by twosigma.
the class ConstantBandSerializerTest method serializeColorConstantBand_resultJsonHasColor.
@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());
}
Aggregations