Package com.opengamma.core.position

Examples of com.opengamma.core.position.PortfolioNode


    assertEquals(node.getPositions().size(), underlying.getPositions().size());
  }

  public void testSerialization_full() throws Exception {
    final MockComputationTargetResolver resolver = MockComputationTargetResolver.resolved();
    final PortfolioNode underlying = resolver.getPositionSource().getPortfolioNode(UniqueId.of("Node", "0"), VersionCorrection.LATEST);
    PortfolioNode node = new LazyResolvedPortfolioNode(new LazyResolveContext(resolver.getSecuritySource(), null).atVersionCorrection(VersionCorrection.LATEST), underlying);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ObjectOutputStream(baos).writeObject(node);
    final Object resultObject = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject();
    assertTrue(resultObject instanceof SimplePortfolioNode);
    node = (PortfolioNode) resultObject;
    assertEquals(node.getName(), underlying.getName());
    assertEquals(node.getChildNodes().size(), underlying.getChildNodes().size());
    assertEquals(node.getPositions().size(), underlying.getPositions().size());
  }
View Full Code Here


    assertEquals(node.getPositions().size(), underlying.getPositions().size());
  }

  public void testSerialization_targetResolver() throws Exception {
    final MockComputationTargetResolver resolver = MockComputationTargetResolver.resolved();
    final PortfolioNode underlying = resolver.getPositionSource().getPortfolioNode(UniqueId.of("Node", "0"), VersionCorrection.LATEST);
    PortfolioNode node = new LazyResolvedPortfolioNode(new LazyResolveContext(resolver.getSecuritySource(), new DefaultCachingComputationTargetResolver(resolver,
        _cacheManager)).atVersionCorrection(VersionCorrection.LATEST), underlying);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ObjectOutputStream(baos).writeObject(node);
    final Object resultObject = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject();
    assertTrue(resultObject instanceof TargetResolverPortfolioNode);
    node = (PortfolioNode) resultObject;
    assertEquals(node.getName(), underlying.getName());
    assertEquals(node.getChildNodes().size(), underlying.getChildNodes().size());
    assertEquals(node.getPositions().size(), underlying.getPositions().size());
  }
View Full Code Here

            _childNodes = Collections.emptyList();
          } else {
            _childNodes = new LazyArrayList<PortfolioNode>(childNodes) {
              @Override
              public PortfolioNode resolve(final PortfolioNode childNode) {
                final PortfolioNode newChildNode = new LazyResolvedPortfolioNode(getLazyResolveContext(), childNode);
                getLazyResolveContext().cachePortfolioNode(newChildNode);
                return newChildNode;
              }
            };
          }
View Full Code Here

  }

  @Override
  public PortfolioNode getRootNode() {
    if (_rootNode == null) {
      PortfolioNode rootNode = null;
      synchronized (this) {
        if (_rootNode == null) {
          rootNode = new LazyResolvedPortfolioNode(getLazyResolveContext(), getUnderlying().getRootNode());
          _rootNode = rootNode;
        }
View Full Code Here

TOP

Related Classes of com.opengamma.core.position.PortfolioNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.