PortfolioNodeTraverser { public static PortfolioNodeTraverser depthFirst(final PortfolioNodeTraversalCallback callback) { return new DepthFirstPortfolioNodeTraverser(callback); } protected  PortfolioNodeTraverser(final PortfolioNodeTraversalCallback callback); static PortfolioNodeTraverser depthFirst(final PortfolioNodeTraversalCallback callback); static PortfolioNodeTraverser breadthFirst(final PortfolioNodeTraversalCallback callback); static PortfolioNodeTraverser parallel(final PortfolioNodeTraversalCallback callback, final PoolExecutor executorService); PortfolioNodeTraversalCallback getCallback(); abstract void traverse(PortfolioNode portfolioNode);  }
@Test(groups = TestGroup.UNIT) public void testDepthFirst() { final Callback cb = new Callback(); PortfolioNodeTraverser.depthFirst(cb).traverse(createTestPortfolioNode(new AtomicInteger(), 2)); cb.assertVisitCount(); cb.assertVisit(NODE_PRE, 0); cb.assertVisit(POSITION_PRE, 19, 20); cb.assertVisit(NODE_PRE, 1); cb.assertVisit(POSITION_PRE, 8, 9); cb.assertVisit(NODE_PRE, 2); cb.assertVisit(POSITION_PRE, 3, 4); cb.assertVisit(POSITION_POST, 3, 4); cb.assertVisit(NODE_POST, 2); cb.assertVisit(NODE_PRE, 5); cb.assertVisit(POSITION_PRE, 6, 7); cb.assertVisit(POSITION_POST, 6, 7); cb.assertVisit(NODE_POST, 5); cb.assertVisit(POSITION_POST, 8, 9); cb.assertVisit(NODE_POST, 1); cb.assertVisit(NODE_PRE, 10); cb.assertVisit(POSITION_PRE, 17, 18); cb.assertVisit(NODE_PRE, 11); cb.assertVisit(POSITION_PRE, 12, 13); cb.assertVisit(POSITION_POST, 12, 13); cb.assertVisit(NODE_POST, 11); cb.assertVisit(NODE_PRE, 14); cb.assertVisit(POSITION_PRE, 15, 16); cb.assertVisit(POSITION_POST, 15, 16); cb.assertVisit(NODE_POST, 14); cb.assertVisit(POSITION_POST, 17, 18); cb.assertVisit(NODE_POST, 10); cb.assertVisit(POSITION_POST, 19, 20); cb.assertVisit(NODE_POST, 0); }