final PortfolioStructure resolver = new PortfolioStructure(positionSource);
final SimplePortfolio portfolio = new SimplePortfolio(uid.get(), "Test");
_root = new SimplePortfolioNode(uid.get(), "root");
_child1 = new SimplePortfolioNode(uid.get(), "child 1");
_child2 = new SimplePortfolioNode(uid.get(), "child 2");
_position1 = new SimplePosition(uid.get(), new BigDecimal(10), ExternalId.of("Security", "Foo"));
_child2.addPosition(_position1);
_position2 = new SimplePosition(uid.get(), new BigDecimal(20), ExternalId.of("Security", "Bar"));
_child2.addPosition(_position2);
_child2.setParentNodeId(_child1.getUniqueId());
_child1.addChildNode(_child2);
_child1.setParentNodeId(_root.getUniqueId());
_root.addChildNode(_child1);
portfolio.setRootNode(_root);
positionSource.addPortfolio(portfolio);
_badChild = new SimplePortfolioNode(uid.get(), "child 3");
_badChild.setParentNodeId(uid.get());
_badPosition = new SimplePosition(uid.get(), new BigDecimal(10), ExternalId.of("Security", "Cow"));
_context = new FunctionCompilationContext();
_context.setPortfolioStructure(resolver);
}