@Test
@SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
public void testSampleNode() throws IOException {

  LOG.debug("sample");
  StackTraceElement[] st1 = new StackTraceElement[3];
  st1[0] = new StackTraceElement("C1", "m1", "C1.java", 10);
  st1[1] = new StackTraceElement("C1", "m2", "C1.java", 11);
  st1[2] = new StackTraceElement("C1", "m3", "C1.java", 12);
  SampleNode node1 = SampleNode.createSampleNode(st1);
  LOG.debug("Node 1", node1);
  Assert.assertEquals(4, node1.getNrNodes());
  StackTraceElement[] st2 = new StackTraceElement[1];
  st2[0] = new StackTraceElement("C1", "m1", "C1.java", 10);
  SampleNode.addToSampleNode(node1, st2);
  LOG.debug("Node 1", node1);
  Assert.assertEquals(5, node1.getNrNodes());
  StackTraceElement[] st3 = new StackTraceElement[3];
  st3[0] = new StackTraceElement("C2", "m1", "C2.java", 10);
  st3[1] = new StackTraceElement("C2", "m2", "C2.java", 11);
  st3[2] = new StackTraceElement("C2", "m3", "C2.java", 12);
  SampleNode.addToSampleNode(node1, st3);
  LOG.debug("Node 1", node1);
  StackTraceElement[] st4 = new StackTraceElement[3];
  st4[0] = new StackTraceElement("C1", "m1", "C1.java", 10);
  st4[1] = new StackTraceElement("C1", "m2", "C1.java", 11);
  st4[2] = new StackTraceElement("C1", "m4", "C1.java", 14);
  SampleNode.addToSampleNode(node1, st4);
  SampleNode.addToSampleNode(node1, st1);
  LOG.debug("Node 1", node1);
  SampleNode agg = SampleNode.aggregate(node1, node1);
  LOG.debug("n1 + n2", agg);
  Assert.assertEquals(node1.getSampleCount() * 2, agg.getSampleCount());
  final Method method = Methods.getMethod("C1", "m3");
  Assert.assertEquals(node1.getSubNodes().get(method).getSampleCount() * 2,
          agg.getSubNodes().get(method).getSampleCount());
  StringBuilder sb = new StringBuilder();
  node1.writeTo(sb);
  LOG.debug("Serialized String", sb);
  SampleNode into = new SampleNode();
  SampleNode.parseInto(new StringReader(sb.toString()), into);
  Pair<Method, SampleNode> parsed = SampleNode.parse(new StringReader(sb.toString()));
  Assert.assertEquals(node1, parsed.getSecond());
  Assert.assertEquals(node1, Objects.clone(node1));
  Assert.assertEquals(node1, into);
  SampleNode node1Clone = SampleNode.clone(node1);
  Assert.assertEquals(node1, node1Clone);
  node1Clone.addToCount(5);
  Assert.assertNotEquals(node1, node1Clone);
  StringBuilder sb2 = new StringBuilder();
  node1.writeD3JsonTo(sb2);
  LOG.debug("Serialized D3 String", sb2);
  Pair<Method, SampleNode> parsed2 = SampleNode.parseD3Json(new StringReader(sb2.toString()));
  Assert.assertEquals(node1, parsed2.getSecond());
  SampleNode.traverse(parsed.getFirst(), parsed.getSecond(), (f, t, s) -> {
    LOG.debug("{} -> {} sampled {} times", f, t, s);
    return true;
  });
}