Search in sources :

Example 11 with ConstantLine

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

the class ConstantLineSerializerTest method serializeVisibleConstantLine_resultJsonHasVisible.

@Test
public void serializeVisibleConstantLine_resultJsonHasVisible() throws IOException {
    // when
    ConstantLine constantLine = new ConstantLine();
    constantLine.setVisible(true);
    constantLineSerializer.serialize(constantLine, 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();
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) Test(org.junit.Test)

Example 12 with ConstantLine

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

the class ConstantLineSerializerTest method serializeConstantLine_resultJsonHasType.

@Test
public void serializeConstantLine_resultJsonHasType() throws IOException {
    // when
    ConstantLine constantLine = new ConstantLine() {
    };
    constantLineSerializer.serialize(constantLine, 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("ConstantLine");
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) Test(org.junit.Test)

Example 13 with ConstantLine

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

the class ConstantLineSerializerTest method serializeYConstantLine_resultJsonHasY.

@Test
public void serializeYConstantLine_resultJsonHasY() throws IOException {
    // when
    ConstantLine constantLine = new ConstantLine();
    constantLine.setY(1);
    constantLineSerializer.serialize(constantLine, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("y")).isTrue();
    Assertions.assertThat(actualObj.get("y").asInt()).isEqualTo(1);
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) Test(org.junit.Test)

Example 14 with ConstantLine

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

the class XYChartTest method shouldSendCommMsgWhenAddConstantLineByLeftShift.

@Test
public void shouldSendCommMsgWhenAddConstantLineByLeftShift() throws Exception {
    // given
    XYChart xyChart = createWidget();
    // when
    xyChart.leftShift(new ConstantLine());
    // then
    List valueAsArray = getValueAsArray(CONSTANT_LINES);
    Map actual = (Map) valueAsArray.get(0);
    assertThat(actual.get(ConstantLineSerializer.TYPE)).isEqualTo(ConstantLine.class.getSimpleName());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) AbstractChartTest(com.twosigma.beakerx.chart.AbstractChartTest) Test(org.junit.Test)

Aggregations

ConstantLine (com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine)14 Test (org.junit.Test)13 JsonNode (com.fasterxml.jackson.databind.JsonNode)11 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)11 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 KernelTest (com.twosigma.beakerx.KernelTest)1 AbstractChartTest (com.twosigma.beakerx.chart.AbstractChartTest)1 ConstantBand (com.twosigma.beakerx.chart.xychart.plotitem.ConstantBand)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