Package com.opengamma.master.security

Examples of com.opengamma.master.security.SecurityDocument


  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_add_addWithMissingTypeProperty() {
    ManageableSecurity security = mock(ManageableSecurity.class);
    when(security.getName()).thenReturn("Test");
    when(security.getExternalIdBundle()).thenReturn(ExternalIdBundle.of("A", "B"));
    SecurityDocument doc = new SecurityDocument(security);
    _secMaster.add(doc);
  }
View Full Code Here


  }

  @Test
  public void test_add_addWithMinimalProperties() {
    ManageableSecurity security = new ManageableSecurity();
    SecurityDocument doc = new SecurityDocument(security);
    _secMaster.add(doc);
  }
View Full Code Here

    final ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName, rootNode);
    final PortfolioDocument portfolioDoc = new PortfolioDocument();
    portfolioDoc.setPortfolio(portfolio);

    for (final FXForwardSecurity fxForward : fxForwards) {
      final SecurityDocument fxForwardToAddDoc = new SecurityDocument();
      fxForwardToAddDoc.setSecurity(fxForward);
      securityMaster.add(fxForwardToAddDoc);
      final ManageablePosition fxForwardPosition = new ManageablePosition(BigDecimal.ONE, fxForward.getExternalIdBundle());
      final PositionDocument addedDoc = positionMaster.add(new PositionDocument(fxForwardPosition));
      rootNode.addPosition(addedDoc.getUniqueId());
    }
View Full Code Here

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_update_noSecurityId() {
    UniqueId uniqueId = UniqueId.of("DbSec", "101");
    ManageableSecurity security = new ManageableSecurity(uniqueId, "Name", "Type", ExternalIdBundle.of("A", "B"));
    SecurityDocument doc = new SecurityDocument();
    doc.setSecurity(security);
    _secMaster.update(doc);
  }
View Full Code Here

    _secMaster.update(doc);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_update_noSecurity() {
    SecurityDocument doc = new SecurityDocument();
    doc.setUniqueId(UniqueId.of("DbSec", "101", "0"));
    _secMaster.update(doc);
  }
View Full Code Here

  @Test(expectedExceptions = DataNotFoundException.class)
  public void test_update_notFound() {
    UniqueId uniqueId = UniqueId.of("DbSec", "0", "0");
    ManageableSecurity security = new ManageableSecurity(uniqueId, "Name", "Type", ExternalIdBundle.of("A", "B"));
    SecurityDocument doc = new SecurityDocument(security);
    _secMaster.update(doc);
  }
View Full Code Here

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_update_notLatestVersion() {
    UniqueId uniqueId = UniqueId.of("DbSec", "201", "0");
    ManageableSecurity security = new ManageableSecurity(uniqueId, "Name", "Type", ExternalIdBundle.of("A", "B"));
    SecurityDocument doc = new SecurityDocument(security);
    _secMaster.update(doc);
  }
View Full Code Here

  @Test
  public void test_update_getUpdateGet() {
    Instant now = Instant.now(_secMaster.getClock());
   
    UniqueId uniqueId = UniqueId.of("DbSec", "101", "0");
    SecurityDocument base = _secMaster.get(uniqueId);
    ManageableSecurity security = new ManageableSecurity(uniqueId, "Name", "Type", ExternalIdBundle.of("A", "B"));
    SecurityDocument input = new SecurityDocument(security);
   
    SecurityDocument updated = _secMaster.update(input);
    assertEquals(false, base.getUniqueId().equals(updated.getUniqueId()));
    assertEquals(now, updated.getVersionFromInstant());
    assertEquals(null, updated.getVersionToInstant());
    assertEquals(now, updated.getCorrectionFromInstant());
    assertEquals(null, updated.getCorrectionToInstant());
    assertEquals(input.getSecurity(), updated.getSecurity());
   
    SecurityDocument old = _secMaster.get(uniqueId);
    assertEquals(base.getUniqueId(), old.getUniqueId());
    assertEquals(base.getVersionFromInstant(), old.getVersionFromInstant());
    assertEquals(now, old.getVersionToInstant())// old version ended
    assertEquals(base.getCorrectionFromInstant(), old.getCorrectionFromInstant());
    assertEquals(base.getCorrectionToInstant(), old.getCorrectionToInstant());
    assertEquals(base.getSecurity(), old.getSecurity());
   
    SecurityHistoryRequest search = new SecurityHistoryRequest(base.getUniqueId(), null, now);
    search.setFullDetail(false);
    SecurityHistoryResult searchResult = _secMaster.history(search);
    assertEquals(2, searchResult.getDocuments().size());
View Full Code Here

  @Test
  public void test_update_rollback() {
    DbSecurityMaster w = new DbSecurityMaster(_secMaster.getDbConnector());
    w.setElSqlBundle(ElSqlBundle.of(new ElSqlConfig("TestRollback"), DbSecurityMaster.class));
    final SecurityDocument base = _secMaster.get(UniqueId.of("DbSec", "101", "0"));
    UniqueId uniqueId = UniqueId.of("DbSec", "101", "0");
    ManageableSecurity security = new ManageableSecurity(uniqueId, "Name", "Type", ExternalIdBundle.of("A", "B"));
    SecurityDocument input = new SecurityDocument(security);
    try {
      w.update(input);
      Assert.fail();
    } catch (BadSqlGrammarException ex) {
      // expected
    }
    final SecurityDocument test = _secMaster.get(UniqueId.of("DbSec", "101", "0"));
   
    assertEquals(base, test);
  }
View Full Code Here

  @BeforeMethod
  public void setUp() throws Exception {
    _portfolioMaster = new InMemoryPortfolioMaster();
    _positionMaster = new InMemoryPositionMaster();
    InMemorySecurityMaster securityMaster = new InMemorySecurityMaster();
    securityMaster.add(new SecurityDocument(APPLE_SECURITY));
    securityMaster.add(new SecurityDocument(INTEL_SECURITY));
    BigDecimal quantity = BigDecimal.valueOf(20);
    ManageablePosition position = new ManageablePosition(quantity, APPLE_SECURITY.getExternalIdBundle());
    position.addTrade(new ManageableTrade(quantity,
                                          APPLE_BUNDLE,
                                          LocalDate.of(2012, 12, 1),
View Full Code Here

TOP

Related Classes of com.opengamma.master.security.SecurityDocument

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.