@Test public void toV1Dto() throws Exception { Debate d1 = debate(null); Debate d2 = debate(null); Debate d2_1 = debate(d2); Debate d2_2 = debate(d2); Debate d3 = debate(null); Debate d3_1 = debate(d3); List<Debate> flatten = asList( d1, d2, d2_1, d2_2, d3, d3_1); DebateTree tree = DebateTree.fromDepthFirst(flatten); V1DebateNodeDto dto = tree.toV1Dto(); assertNull(dto.getDebate()); List<V1DebateNodeDto> children1 = dto.getChildren(); assertEquals(d1.getDebateId().toString(), children1.get(0).getDebate().getDebateId()); assertEquals(d2.getDebateId().toString(), children1.get(1).getDebate().getDebateId()); assertEquals(d3.getDebateId().toString(), children1.get(2).getDebate().getDebateId()); assertTrue(children1.get(0).getChildren().isEmpty()); List<V1DebateNodeDto> children2 = children1.get(1).getChildren(); assertEquals(d2_1.getDebateId().toString(), children2.get(0).getDebate().getDebateId()); assertEquals(d2_2.getDebateId().toString(), children2.get(1).getDebate().getDebateId()); assertTrue(children2.get(0).getChildren().isEmpty()); assertTrue(children2.get(1).getChildren().isEmpty()); List<V1DebateNodeDto> children3 = children1.get(2).getChildren(); assertEquals(d3_1.getDebateId().toString(), children3.get(0).getDebate().getDebateId()); assertTrue(children3.get(0).getChildren().isEmpty()); }
public V1DebateNodeDto toV1Dto() { return deepDto(node); }
DebateTree { public V1DebateNodeDto toV1Dto() { return deepDto(node); } }
DebateTree { public V1DebateNodeDto toV1Dto() { return deepDto(node); } DebateTree(SortingNode<Debate> node); }
DebateTree { public V1DebateNodeDto toV1Dto() { return deepDto(node); } DebateTree(SortingNode<Debate> node); static DebateTree fromDepthFirst(List<Debate> flatten); List<SortingNode<Debate>> getChildren(); boolean isEmpty(); DebateTree sortByBestScore(ToDoubleFunction<Debate> scoreCalc); DebateTree sortByBestScore(); Stream<Debate> depthFirst(); V1DebateNodeDto toV1Dto(); }
DebateTree { public V1DebateNodeDto toV1Dto() { return deepDto(node); } DebateTree(SortingNode<Debate> node); static DebateTree fromDepthFirst(List<Debate> flatten); List<SortingNode<Debate>> getChildren(); boolean isEmpty(); DebateTree sortByBestScore(ToDoubleFunction<Debate> scoreCalc); DebateTree sortByBestScore(); Stream<Debate> depthFirst(); V1DebateNodeDto toV1Dto(); static final ToDoubleFunction<Debate> DEBATE_TO_WILSON_SCORE; }