*/
@Test
public class LazyComputationTargetResolverTest {
public void testPortfolioNode() {
final MockComputationTargetResolver mock = MockComputationTargetResolver.unresolved();
final ComputationTargetResolver resolver = new LazyComputationTargetResolver(mock);
final ComputationTarget target = resolver.resolve(new ComputationTargetSpecification(ComputationTargetType.PORTFOLIO_NODE, UniqueId.of("Node", "0")), VersionCorrection.LATEST);
final PortfolioNode node = target.getPortfolioNode();
assertEquals(node.getUniqueId(), UniqueId.of("Node", "0"));
assertEquals(mock.getResolveCalls(), 0);
assertEquals(node.getName(), "Node 0");
assertEquals(mock.getResolveCalls(), 1);
final List<PortfolioNode> childNodes = node.getChildNodes();
assertEquals(childNodes.size(), 2);
assertEquals(mock.getResolveCalls(), 1);
assertEquals(childNodes.get(0).getUniqueId(), UniqueId.of("Node", "1"));
assertEquals(childNodes.get(1).getUniqueId(), UniqueId.of("Node", "4"));
assertEquals(mock.getResolveCalls(), 1);
assertEquals(childNodes.get(0).getName(), "Node 1");
assertEquals(childNodes.get(0).getChildNodes().size(), 2);
assertEquals(childNodes.get(1).getName(), "Node 4");
assertEquals(childNodes.get(1).getChildNodes().size(), 2);
assertEquals(mock.getResolveCalls(), 3);
final List<Position> positions = node.getPositions();
assertEquals(positions.size(), 2);
assertEquals(mock.getResolveCalls(), 3);
assertEquals(positions.get(0).getUniqueId(), UniqueId.of("Position", "12"));
assertEquals(positions.get(1).getUniqueId(), UniqueId.of("Position", "13"));
assertEquals(mock.getResolveCalls(), 3);
assertEquals(positions.get(0).getQuantity(), BigDecimal.ONE);
assertEquals(positions.get(1).getQuantity(), BigDecimal.ONE);
assertEquals(mock.getResolveCalls(), 5);
}