Package com.opengamma.core.position.impl

Examples of com.opengamma.core.position.impl.MockPositionSource


  private static final Position POSITION = new SimplePosition(UniqueId.of("Test", "1"), new BigDecimal(1), ExternalIdBundle.EMPTY);
  private static final Security SECURITY = new SimpleSecurity(UniqueId.of("Test", "SEC"), ExternalIdBundle.EMPTY, "Test security", "EQUITY");

  public void test_constructor() {
    final SecuritySource secSource = new InMemorySecuritySource();
    final PositionSource posSource = new MockPositionSource();
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    assertSame(secSource, test.getSecuritySource());
    assertSame(posSource, test.getPositionSource());
  }
View Full Code Here


    assertEquals(expected.getUniqueId(), actual.getUniqueId());
  }

  public void test_resolve_portfolioNode() {
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    final SimplePortfolio p = new SimplePortfolio(UniqueId.of("Test", "1"), "Name");
    p.getRootNode().addChildNode(NODE);
    posSource.addPortfolio(p);
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    final ComputationTargetSpecification spec = ComputationTargetSpecification.of(NODE);
    final ComputationTarget expected = new ComputationTarget(ComputationTargetType.PORTFOLIO_NODE, NODE);
    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }
View Full Code Here

    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }

  public void test_resolve_position() {
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    final SimplePortfolio p = new SimplePortfolio(UniqueId.of("Test", "1"), "Name");
    p.getRootNode().addPosition(POSITION);
    posSource.addPortfolio(p);
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    final ComputationTargetSpecification spec = ComputationTargetSpecification.of(POSITION);
    final ComputationTarget expected = new ComputationTarget(ComputationTargetType.POSITION, POSITION);
    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }
View Full Code Here

  }

  public void test_resolve_trade() {
    final OffsetDateTime now = OffsetDateTime.now();
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    final SimplePortfolio portfolio = new SimplePortfolio(UniqueId.of("Test", "1"), "Name");
    final SimplePosition position = new SimplePosition(UniqueId.of("Test", "1"), new BigDecimal(1), ExternalIdBundle.EMPTY);
    final SimpleTrade trade = new SimpleTrade(new SimpleSecurityLink(), new BigDecimal(1), new SimpleCounterparty(ExternalId.of("CPARTY", "C100")), now.toLocalDate(), now.toOffsetTime());
    trade.setUniqueId(UniqueId.of("TradeScheme", "1"));
    position.addTrade(trade);
    portfolio.getRootNode().addPosition(position);
    posSource.addPortfolio(portfolio);
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    final ComputationTargetSpecification spec = ComputationTargetSpecification.of(trade);
    final ComputationTarget expected = new ComputationTarget(ComputationTargetType.TRADE, trade);
    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }
View Full Code Here

    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }

  public void test_resolve_security() {
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    secSource.addSecurity(SECURITY);
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    final ComputationTargetSpecification spec = ComputationTargetSpecification.of(SECURITY);
    final ComputationTarget expected = new ComputationTarget(ComputationTargetType.SECURITY, SECURITY);
    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
View Full Code Here

    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }

  public void test_resolve_primitive() {
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    final ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.PRIMITIVE, UniqueId.of("Foo", "Bar"));
    final ComputationTarget expected = new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Foo", "Bar"));
    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }
View Full Code Here

    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }

  public void test_resolve_currency() {
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    final ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.CURRENCY, UniqueId.of("CurrencyISO", "USD"));
    final ComputationTarget expected = new ComputationTarget(ComputationTargetType.CURRENCY, Currency.USD);
    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }
View Full Code Here

    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }

  public void test_resolve_unorderedCurrencyPair() {
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    final ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.UNORDERED_CURRENCY_PAIR, UniqueId.of("UnorderedCurrencyPair", "EURGBP"));
    final ComputationTarget expected = new ComputationTarget(ComputationTargetType.UNORDERED_CURRENCY_PAIR, UnorderedCurrencyPair.of(Currency.GBP, Currency.EUR));
    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }
View Full Code Here

    assertExpected(expected, test.resolve(spec, VersionCorrection.LATEST));
  }

  public void test_resolve_null() {
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    assertExpected(ComputationTarget.NULL, test.resolve(ComputationTargetSpecification.NULL, VersionCorrection.LATEST));
  }
View Full Code Here

  }

  @Test(expectedExceptions = NullPointerException.class)
  public void test_resolve_nullSpecification() {
    final InMemorySecuritySource secSource = new InMemorySecuritySource();
    final MockPositionSource posSource = new MockPositionSource();
    final DefaultComputationTargetResolver test = new DefaultComputationTargetResolver(secSource, posSource);
    test.resolve(null, VersionCorrection.LATEST);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.core.position.impl.MockPositionSource

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.