CaptureNode implements HNode<CaptureNode> { public void addChild(CaptureNode node) { myChildren.add(node); node.myParent = this; } CaptureNode(@NotNull CaptureNodeModel model); void addChild(CaptureNode node); @NotNull List<CaptureNode> getChildren(); @NotNull CaptureNodeModel getData(); @Override int getChildCount(); @NotNull @Override CaptureNode getChildAt(int index); @Nullable @Override CaptureNode getParent(); @Override long getStart(); @Override long getEnd(); @Override int getDepth(); void setStartGlobal(long startGlobal); long getStartGlobal(); void setEndGlobal(long endGlobal); long getEndGlobal(); void setStartThread(long startThread); long getStartThread(); void setEndThread(long endThread); long getEndThread(); void setClockType(@NotNull ClockType clockType); double threadGlobalRatio(); @NotNull ClockType getClockType(); void setDepth(int depth); @NotNull FilterResult applyFilter(@NotNull Filter filter); @NotNull FilterType getFilterType(); void setFilterType(@NotNull FilterType type); boolean isUnmatched();  }
@Test public void addChild() { CaptureNode realParent = new CaptureNode(new StubCaptureNodeModel()); CaptureNode childA = new CaptureNode(new StubCaptureNodeModel()); VisualNodeCaptureNode visualParent = new VisualNodeCaptureNode(new StubCaptureNodeModel()); realParent.addChild(childA); assertThat(childA.getParent()).isEqualTo(realParent); assertThat(realParent.getChildAt(0)).isEqualTo(childA); visualParent.addChild(childA); assertThat(childA.getParent()).isEqualTo(realParent); assertThat(realParent.getChildAt(0)).isEqualTo(childA); assertThat(visualParent.getChildAt(0)).isEqualTo(childA); }