Search in sources :

Example 1 with DefaultValue

use of net.sf.jtreemap.swing.DefaultValue in project beakerx by twosigma.

the class TreeMapNodeSerializerTest method serializeDoubleValueOfTreeMapNode_resultJsonHasDoubleValue.

@Test
public void serializeDoubleValueOfTreeMapNode_resultJsonHasDoubleValue() throws IOException {
    // when
    TreeMapNode treeMapNode = new TreeMapNode("010", 1, new DefaultValue(1.5));
    treeMapNode.setUserObject(values);
    treeMapNodeSerializer.serialize(treeMapNode, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("doubleValue")).isTrue();
    Assertions.assertThat(actualObj.get("doubleValue").asDouble()).isEqualTo(1.5);
}
Also used : DefaultValue(net.sf.jtreemap.swing.DefaultValue) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) TreeMapNode(net.sf.jtreemap.swing.TreeMapNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 2 with DefaultValue

use of net.sf.jtreemap.swing.DefaultValue in project beakerx by twosigma.

the class RandomColorProviderTest method initStubData.

@Before
public void initStubData() {
    node01 = new TreeMapNode("010", 1, new DefaultValue(1));
    node02 = new TreeMapNode("021");
    node02.setWeight(2.0);
    node02.setValue(new DefaultValue(2));
}
Also used : DefaultValue(net.sf.jtreemap.swing.DefaultValue) TreeMapNode(net.sf.jtreemap.swing.TreeMapNode) Before(org.junit.Before)

Example 3 with DefaultValue

use of net.sf.jtreemap.swing.DefaultValue in project beakerx by twosigma.

the class TreeMapNodeSerializerTest method serializeLabelValueOfTreeMapNode_resultJsonHasLabelValue.

@Test
public void serializeLabelValueOfTreeMapNode_resultJsonHasLabelValue() throws IOException {
    // when
    TreeMapNode treeMapNode = new TreeMapNode("010", 1, new DefaultValue(1.5));
    treeMapNode.setUserObject(values);
    treeMapNodeSerializer.serialize(treeMapNode, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("labelValue")).isTrue();
    Assertions.assertThat(actualObj.get("labelValue").asText()).isEqualTo("1.5");
}
Also used : DefaultValue(net.sf.jtreemap.swing.DefaultValue) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) TreeMapNode(net.sf.jtreemap.swing.TreeMapNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 4 with DefaultValue

use of net.sf.jtreemap.swing.DefaultValue in project beakerx by twosigma.

the class TreeMapNodeSerializerTest method serializeChildrenOfTreeMapNode_resultJsonHasChildren.

@Test
public void serializeChildrenOfTreeMapNode_resultJsonHasChildren() throws IOException {
    // when
    TreeMapNode treeMapNodeRoot = new TreeMapNode("001");
    treeMapNodeRoot.add(new TreeMapNode("010", 1, new DefaultValue(1.5)));
    treeMapNodeRoot.add(new TreeMapNode("020", 2, new DefaultValue(2.5)));
    treeMapNodeSerializer.serialize(treeMapNodeRoot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("children")).isTrue();
    Assertions.assertThat(actualObj.get("children")).isNotEmpty();
}
Also used : DefaultValue(net.sf.jtreemap.swing.DefaultValue) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) TreeMapNode(net.sf.jtreemap.swing.TreeMapNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 5 with DefaultValue

use of net.sf.jtreemap.swing.DefaultValue in project beakerx by twosigma.

the class TreeMapNodeSerializerTest method serializeLabelOfTreeMapNode_resultJsonHasLabel.

@Test
public void serializeLabelOfTreeMapNode_resultJsonHasLabel() throws IOException {
    // when
    TreeMapNode treeMapNode = new TreeMapNode("010", 1, new DefaultValue(1.5));
    treeMapNode.setUserObject(values);
    treeMapNodeSerializer.serialize(treeMapNode, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("label")).isTrue();
    Assertions.assertThat(actualObj.get("label").asText()).isEqualTo("some label");
}
Also used : DefaultValue(net.sf.jtreemap.swing.DefaultValue) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) TreeMapNode(net.sf.jtreemap.swing.TreeMapNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

DefaultValue (net.sf.jtreemap.swing.DefaultValue)10 TreeMapNode (net.sf.jtreemap.swing.TreeMapNode)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)6 Test (org.junit.Test)6 Before (org.junit.Before)3 KernelTest (com.twosigma.beakerx.KernelTest)2 TreeMap (com.twosigma.beakerx.chart.treemap.TreeMap)2 StringWriter (java.io.StringWriter)1