Search in sources :

Example 11 with TreeMapNode

use of net.sf.jtreemap.swing.TreeMapNode 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 12 with TreeMapNode

use of net.sf.jtreemap.swing.TreeMapNode 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)

Example 13 with TreeMapNode

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

the class TreeMapNodeSerializerTest method serializeTooltipOfTreeMapNode_resultJsonHasTooltip.

@Test
public void serializeTooltipOfTreeMapNode_resultJsonHasTooltip() 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("tooltip")).isTrue();
    Assertions.assertThat(actualObj.get("tooltip").asText()).isEqualTo("some tooltip");
}
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 14 with TreeMapNode

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

the class TreeMapNodeSerializerTest method serializeWeightOfTreeMapNode_resultJsonHasWeight.

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

Example 15 with TreeMapNode

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

the class TreeMapNodeSerializerTest method serializeColorOfTreeMapNode_resultJsonHasColor.

@Test
public void serializeColorOfTreeMapNode_resultJsonHasColor() 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("color")).isTrue();
}
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

TreeMapNode (net.sf.jtreemap.swing.TreeMapNode)18 Test (org.junit.Test)11 DefaultValue (net.sf.jtreemap.swing.DefaultValue)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)8 KernelTest (com.twosigma.beakerx.KernelTest)3 TreeMap (com.twosigma.beakerx.chart.treemap.TreeMap)3 Before (org.junit.Before)3 ChartTest (com.twosigma.beakerx.chart.ChartTest)2 IToolTipBuilder (com.twosigma.beakerx.chart.treemap.util.IToolTipBuilder)2 Color (com.twosigma.beakerx.chart.Color)1 StringWriter (java.io.StringWriter)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1