Package com.opengamma.engine.target

Examples of com.opengamma.engine.target.MockComputationTargetResolver


    EHCacheUtils.clear(_cacheManager);
  }

  //-------------------------------------------------------------------------
  public void testBasicMethods() {
    final MockComputationTargetResolver resolver = MockComputationTargetResolver.resolved();
    final Trade underlying = resolver.getPositionSource().getTrade(UniqueId.of("Trade", "0"));
    Trade trade = new LazyResolvedTrade(new LazyResolveContext(resolver.getSecuritySource(), null).atVersionCorrection(VersionCorrection.LATEST), underlying);
    assertEquals(trade.getAttributes(), underlying.getAttributes());
    trade.setAttributes(ImmutableMap.of("K1", "V1"));
    assertEquals(trade.getAttributes(), underlying.getAttributes());
    trade.addAttribute("K2", "V2");
    assertEquals(trade.getAttributes().size(), 2);
View Full Code Here


    assertEquals(trade.getQuantity(), underlying.getQuantity());
    assertEquals(trade.getSecurity().getUniqueId(), underlying.getSecurity().getUniqueId());
  }

  public void testSerialization_full() throws Exception {
    final MockComputationTargetResolver resolver = MockComputationTargetResolver.resolved();
    final Trade underlying = resolver.getPositionSource().getTrade(UniqueId.of("Trade", "0"));
    underlying.setAttributes(ImmutableMap.of("K1", "V1"));
    Trade trade = new LazyResolvedTrade(new LazyResolveContext(resolver.getSecuritySource(), null).atVersionCorrection(VersionCorrection.LATEST), underlying);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ObjectOutputStream(baos).writeObject(trade);
    final Object result = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject();
    assertTrue(result instanceof SimpleTrade);
    trade = (Trade) result;
View Full Code Here

    assertEquals(trade.getQuantity(), underlying.getQuantity());
    assertEquals(trade.getSecurity().getUniqueId(), underlying.getSecurity().getUniqueId());
  }

  public void testSerialization_targetResolver() throws Exception {
    final MockComputationTargetResolver resolver = MockComputationTargetResolver.resolved();
    final Trade underlying = resolver.getPositionSource().getTrade(UniqueId.of("Trade", "0"));
    underlying.setAttributes(ImmutableMap.of("K1", "V1"));
    Trade trade = new LazyResolvedTrade(new LazyResolveContext(resolver.getSecuritySource(), new DefaultCachingComputationTargetResolver(resolver,
        _cacheManager)).atVersionCorrection(VersionCorrection.LATEST), underlying);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new ObjectOutputStream(baos).writeObject(trade);
    final Object result = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject();
    assertTrue(result instanceof TargetResolverTrade);
View Full Code Here

    EHCacheUtils.clear(_cacheManager);
  }

  //-------------------------------------------------------------------------
  public void testBasicMethods() {
    final MockComputationTargetResolver resolver = MockComputationTargetResolver.resolved();
    final PortfolioNode underlying = resolver.getPositionSource().getPortfolioNode(UniqueId.of("Node", "0"), VersionCorrection.LATEST);
    final PortfolioNode node = new LazyResolvedPortfolioNode(new LazyResolveContext(resolver.getSecuritySource(), null).atVersionCorrection(VersionCorrection.LATEST), underlying);
    assertEquals(node.getName(), underlying.getName());
    assertEquals(node.getParentNodeId(), underlying.getParentNodeId());
    assertEquals(node.getUniqueId(), underlying.getUniqueId());
    assertEquals(node.getChildNodes().size(), underlying.getChildNodes().size());
    assertEquals(node.getPositions().size(), underlying.getPositions().size());
View Full Code Here

    assertEquals(node.getChildNodes().size(), underlying.getChildNodes().size());
    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;
View Full Code Here

    assertEquals(node.getChildNodes().size(), underlying.getChildNodes().size());
    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);
View Full Code Here

TOP

Related Classes of com.opengamma.engine.target.MockComputationTargetResolver

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.