BreadthFirstTrace implements Trace { @Override public void run(@NotNull NodeState node) { updateContext(context, 0, nodeCount.incrementAndGet()); traverse(newLinkedList(singleton(getNode(node, path))), 0); } BreadthFirstTrace(int depth, @NotNull String path, @NotNull Consumer<List<String>> context); @Override void run(@NotNull NodeState node); @NotNull
    static final String CONTEXT_SPEC; }
@Test public void testTraverseEmptyTree() { List<List<String>> trace = newArrayList(); new BreadthFirstTrace(4, "/", trace::add).run(createTree(0)); assertEquals(1, trace.size()); assertEquals(ImmutableList.of("0", "1"), trace.get(0)); }
@Test public void testTraverseDepth1Tree() { List<List<String>> trace = newArrayList(); new BreadthFirstTrace(4, "/", trace::add).run(createTree(1)); assertEquals(2, trace.size()); assertEquals(ImmutableList.of("0", "1"), trace.get(0)); assertEquals(ImmutableList.of("1", "2"), trace.get(1)); }
@Test public void testTraverseDepth2Tree() { List<List<String>> trace = newArrayList(); new BreadthFirstTrace(4, "/", trace::add).run(createTree(2)); assertEquals(3, trace.size()); assertEquals(ImmutableList.of("0", "1"), trace.get(0)); assertEquals(ImmutableList.of("1", "2"), trace.get(1)); assertEquals(ImmutableList.of("2", "3"), trace.get(2)); }
@Test public void testTraverseDepth3TreeWithLimit2() { List<List<String>> trace = newArrayList(); new BreadthFirstTrace(2, "/", trace::add).run(createTree(3)); assertEquals(3, trace.size()); assertEquals(ImmutableList.of("0", "1"), trace.get(0)); assertEquals(ImmutableList.of("1", "2"), trace.get(1)); assertEquals(ImmutableList.of("2", "3"), trace.get(2)); }