MarketExposureSelector implements CurveSelector { public Set<CurveConstructionConfiguration> determineCurveConfigurations(Trade trade) { Set<CurveConstructionConfiguration> curveConfigs = new HashSet<>(); for (String curveName : getMulticurveNames(trade)) { curveConfigs.add(resolve(curveName)); } return curveConfigs; } MarketExposureSelector(ExposureFunctions exposureFunctions, SecuritySource securitySource); Set<CurveConstructionConfiguration> determineCurveConfigurations(Trade trade); Set<String> getMulticurveNames(Trade trade); @Deprecated Set<CurveConstructionConfiguration> findCurveConfigurationsForSecurity(FinancialSecurity security);  }
@Test public void testMultipleCurveConfigs() { ConfigMaster configMaster = new InMemoryConfigMaster(); ConfigSource configSource = new MasterConfigSource(configMaster); SecuritySource securitySource = new MasterSecuritySource(new InMemorySecurityMaster()); FRASecurity security = getFRASecurity(); String name = "test"; List<String> exposureFunctions = Lists.newArrayList(SecurityTypeExposureFunction.NAME, CurrencyExposureFunction.NAME); Map<ExternalId, String> idsToNames = new HashMap<>(); String securityTypeCurveConfigName = "SecurityTypeConfig"; idsToNames.put(ExternalId.of(ExposureFunction.SECURITY_IDENTIFIER, security.getSecurityType()), securityTypeCurveConfigName); String currencyCurveConfigName = "CurrencyConfig"; idsToNames.put(ExternalId.of(Currency.OBJECT_SCHEME, security.getCurrency().getCode()), currencyCurveConfigName); ExposureFunctions exposures = new ExposureFunctions(name, exposureFunctions, idsToNames); ConfigMasterUtils.storeByName(configMaster, ConfigItem.of(exposures)); CurveConstructionConfiguration securityTypeCurveConfig = new CurveConstructionConfiguration(securityTypeCurveConfigName, new ArrayList<CurveGroupConfiguration>(), new ArrayList<String>()); ConfigMasterUtils.storeByName(configMaster, ConfigItem.of(securityTypeCurveConfig)); CurveConstructionConfiguration currencyCurveConfig = new CurveConstructionConfiguration(currencyCurveConfigName, new ArrayList<CurveGroupConfiguration>(), new ArrayList<String>()); ConfigMasterUtils.storeByName(configMaster, ConfigItem.of(currencyCurveConfig)); ImmutableMap.Builder<Class<?>, Object> builder = ImmutableMap.builder(); builder.put(ConfigSource.class, configSource); builder.put(SecuritySource.class, securitySource); ServiceContext serviceContext = ServiceContext .of(builder.build()) .with(VersionCorrectionProvider.class, new FixedInstantVersionCorrectionProvider()); ThreadLocalServiceContext.init(serviceContext); MarketExposureSelector selector = new MarketExposureSelector(exposures, securitySource); Trade trade = new SimpleTrade(security, BigDecimal.ONE, new SimpleCounterparty(ExternalId.of(Counterparty.DEFAULT_SCHEME, "TEST")), LocalDate.now(), OffsetTime.now()); Set<CurveConstructionConfiguration> configs = selector.determineCurveConfigurations(trade); assertEquals("Expected single curve config", 1, configs.size()); assertTrue("Expected configs to contain security type config", configs.contains(securityTypeCurveConfig)); assertFalse("Expected configs to not contain currency config", configs.contains(currencyCurveConfig)); }