Package com.opengamma.core.exchange

Examples of com.opengamma.core.exchange.Exchange


              return id.getValue();
            }
          } else if (_exchangeSource != null) {
            ExternalId exchangeId = FinancialSecurityUtils.getExchange(security);
            if (exchangeId != null) {
              Exchange exchange = _exchangeSource.getSingle(exchangeId);
              if (exchange == null) {
                s_logger.info("No exchange could be found with ID {}", exchangeId);
                return NO_REGION;
              }
              if (exchange.getRegionIdBundle() == null) {
                s_logger.info("Exchange " + exchange.getName() + " region bundle was null");
                return NO_REGION;
              }
              Region highestLevelRegion = _regionSource.getHighestLevelRegion(exchange.getRegionIdBundle());
              if (s_specialCountriesRegions.contains(highestLevelRegion.getName())) {
                return highestLevelRegion.getName();
              } else {
                Set<UniqueId> parentRegionIds = highestLevelRegion.getParentRegionIds();
                s_logger.info("got " + highestLevelRegion + ", looking for parent");
View Full Code Here


      @QueryParam("version") String version,
      @QueryParam("versionAsOf") String versionAsOf,
      @QueryParam("correctedTo") String correctedTo) {
    final ObjectId objectId = ObjectId.parse(idStr);
    if (version != null) {
      final Exchange result = getExchangeSource().get(objectId.atVersion(version));
      return responseOkFudge(result);
    } else {
      final VersionCorrection vc = VersionCorrection.parse(versionAsOf, correctedTo);
      Exchange result = getExchangeSource().get(objectId, vc);
      return responseOkFudge(result);
    }
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @GET
  @Path("exchangeSearches/single")
  public Response searchSingle(@QueryParam("id") List<String> externalIdStrs) {
    final ExternalIdBundle bundle = ExternalIdBundle.parse(externalIdStrs);
    Exchange result = getExchangeSource().getSingle(bundle);
    return responseOkFudge(result);
  }
View Full Code Here

    super(underlying, cacheManager);
  }

  @Override
  public Exchange getSingle(final ExternalId identifier) {
    final Exchange result = getUnderlying().getSingle(identifier);
    cacheItem(result);
    return result;
  }
View Full Code Here

    //TODO
  }

  @SuppressWarnings("unchecked")
  private static ExchangeSource myExchangeSource() {
    final Exchange exchange = Mockito.mock(Exchange.class);
    Mockito.when(exchange.getUniqueId()).thenReturn(UniqueId.of("SOMETHING", "SOMETHING ELSE"));
    final ExchangeSource source = Mockito.mock(ExchangeSource.class);
    Mockito.when(source.get(Mockito.any(UniqueId.class))).thenReturn(exchange);
    Mockito.when(source.get(Mockito.any(ObjectId.class), Mockito.any(VersionCorrection.class))).thenReturn(exchange);
    ((OngoingStubbing) Mockito.when(source.get(Mockito.any(ExternalIdBundle.class), Mockito.any(VersionCorrection.class)))).thenReturn(Collections.singleton(exchange));
    Mockito.when(source.getSingle(Mockito.any(ExternalId.class))).thenReturn(exchange);
View Full Code Here

    });
    EHCachingExchangeSource source = new EHCachingExchangeSource(underlying, _cacheManager);
    assertEquals(0, getCount.get());
    ExternalScheme scheme = ExternalScheme.of("Scheme");
    ExternalId id = ExternalId.of(scheme, "Value");
    Exchange get1 = source.getSingle(id);
    assertEquals(1, getCount.get());
    assertEquals(1, get1.getExternalIdBundle().size());
    assertEquals(id, get1.getExternalIdBundle().getExternalId(scheme));

    Exchange get2 = source.get(UniqueId.of("Test", "Foo", "0"));
    assertEquals(1, getCount.get());
    assertTrue(get1 == get2);

  }
View Full Code Here

    ExchangeMaster mock = mock(ExchangeMaster.class);
   
    ExchangeDocument doc = new ExchangeDocument(example());
    when(mock.get(UID)).thenReturn(doc);
    MasterExchangeSource test = new MasterExchangeSource(mock);
    Exchange testResult = test.get(UID);
    verify(mock, times(1)).get(UID);
   
    assertEquals(example(), testResult);
  }
View Full Code Here

    ExchangeMaster mock = mock(ExchangeMaster.class);
   
    ExchangeDocument doc = new ExchangeDocument(example());
    when(mock.get(OID, VC)).thenReturn(doc);
    MasterExchangeSource test = new MasterExchangeSource(mock, VC);
    Exchange testResult = test.get(UID);
    verify(mock, times(1)).get(OID, VC);
   
    assertEquals(example(), testResult);
  }
View Full Code Here

    ExchangeMaster mock = mock(ExchangeMaster.class);
   
    ExchangeDocument doc = new ExchangeDocument(example());
    when(mock.get(OID, VC)).thenReturn(doc);
    MasterExchangeSource test = new MasterExchangeSource(mock, VC);
    Exchange testResult = test.get(OID, VC);
    verify(mock, times(1)).get(OID, VC);
   
    assertEquals(example(), testResult);
  }
View Full Code Here

    ExchangeSearchResult result = new ExchangeSearchResult();
    result.getDocuments().add(new ExchangeDocument(example()));
   
    when(mock.search(request)).thenReturn(result);
    MasterExchangeSource test = new MasterExchangeSource(mock, VC);
    Exchange testResult = test.getSingle(ID);
    verify(mock, times(1)).search(request);
   
    assertEquals(example(), testResult);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.core.exchange.Exchange

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.