Package com.opengamma.core.security

Examples of com.opengamma.core.security.SecurityLink


  //-------------------------------------------------------------------------
  @Test
  public void testResolveLinkWithObjectId() {
    SimpleSecurityResolver resolver = new SimpleSecurityResolver(_securitySource, VersionCorrection.of(_securityV2ValidFrom, _now));
    SecurityLink link = new SimpleSecurityLink(_objectId);
    Security resolvedSecurity = resolver.resolve(link);
    assertEquals(_securityV2, resolvedSecurity);
  }
View Full Code Here


  @Test(expectedExceptions = DataNotFoundException.class)
  public void testResolveLinkWithUnknownObjectId() {
    VersionCorrection vc = VersionCorrection.of(Instant.ofEpochMilli(123), Instant.ofEpochMilli(123));
    SimpleSecurityResolver resolver = new SimpleSecurityResolver(_securitySource, vc);
    SecurityLink link = new SimpleSecurityLink(UNKNOWN_OID);
    resolver.resolve(link);
  }
View Full Code Here

  @Test
  public void testResolveLinkWithExternalIdBundle() {
    SimpleSecurityResolver resolver = new SimpleSecurityResolver(_securitySource, VersionCorrection.of(_securityV2ValidFrom, _now));

    SecurityLink link = new SimpleSecurityLink(_securityExternalId);
    Security resolvedSecurity = resolver.resolve(link);
    assertEquals(_securityV2, resolvedSecurity);

    link = new SimpleSecurityLink(ExternalIdBundle.of(_intersectingExternalIdBundle));
    resolvedSecurity = resolver.resolve(link);
View Full Code Here

  }

  @Test(expectedExceptions = DataNotFoundException.class)
  public void testResolveLinkWithUnknownExternalIdBundle() {
    SimpleSecurityResolver resolver = new SimpleSecurityResolver(_securitySource, VersionCorrection.of(Instant.ofEpochMilli(123), Instant.ofEpochMilli(123)));
    SecurityLink link = new SimpleSecurityLink(ExternalId.of("Unknown", "Unknown"));
    resolver.resolve(link);
  }
View Full Code Here

  }

  @Test(expectedExceptions = DataNotFoundException.class)
  public void testResolveEmptyLink() {
    SimpleSecurityResolver resolver = new SimpleSecurityResolver(_securitySource, VersionCorrection.of(Instant.ofEpochMilli(123), Instant.ofEpochMilli(123)));
    SecurityLink link = new SimpleSecurityLink();
    resolver.resolve(link);
  }
View Full Code Here

  public void getSecurityLink() {
    final Trade trade = Mockito.mock(Trade.class);
    final ResolutionLogger logger = Mockito.mock(ResolutionLogger.class);
    final Trade logged = new LoggedResolutionTrade(trade, logger);
    final SecurityLink link = Mockito.mock(SecurityLink.class);
    Mockito.when(trade.getSecurityLink()).thenReturn(link);
    assertSame(logged.getSecurityLink(), link);
    Mockito.verifyZeroInteractions(logger);
  }
View Full Code Here

  public void getSecurityLink() {
    final Position position = Mockito.mock(Position.class);
    final ResolutionLogger logger = Mockito.mock(ResolutionLogger.class);
    final Position logged = new LoggedResolutionPosition(position, logger);
    final SecurityLink link = Mockito.mock(SecurityLink.class);
    Mockito.when(position.getSecurityLink()).thenReturn(link);
    assertSame(logged.getSecurityLink(), link);
    Mockito.verifyZeroInteractions(logger);
  }
View Full Code Here

              sameLinks.add(link);
            }
          } else {
            if (sameLinkObject != link) {
              final Collection<SecurityLink> sameLinks = new ArrayList<SecurityLink>();
              final SecurityLink sameLink = (SecurityLink) sameLinkObject;
              sameLinks.add(sameLink);
              sameLinks.add(link);
              securityLinkMap.put(key, sameLinks);
            }
          }
View Full Code Here

        final PositionOrTrade position = target.getPositionOrTrade();
        Security security = position.getSecurity();
        if (security != null) {
          return security.getName();
        }
        final SecurityLink link = position.getSecurityLink();
        if (link != null) {
          security = link.getTarget();
          if (security != null) {
            return security.getName();
          }
          final ExternalIdBundle identifiers = link.getExternalId();
          if (identifiers != null) {
            if (identifiers.size() > 0) {
              return position.getQuantity() + " x " + identifiers.iterator().next();
            } else {
              return position.getQuantity() + " x " + identifiers;
            }
          } else if (link.getObjectId() != null) {
            return position.getQuantity() + " x " + link.getObjectId();
          }
        }
        return null;
      }
    });
View Full Code Here

    return getUnderlying().getSecurityLink();
  }

  @Override
  public Security getSecurity() {
    final SecurityLink link = getSecurityLink();
    if (_resolved) {
      return link.getTarget();
    } else {
      Security target = getLazyResolveContext().resolveLink(link);
      if (target == null) {
        throw new OpenGammaRuntimeException("Couldn't resolve " + link);
      }
View Full Code Here

TOP

Related Classes of com.opengamma.core.security.SecurityLink

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.