ExposureFunctionFactory { public static ExposureFunction getExposureFunction(final SecuritySource securitySource, final String name) { ArgumentChecker.notNull(securitySource, "security source"); ArgumentChecker.notNull(name, "name"); if (name.startsWith(CombiningExposureFunction.NAME)) { String underlyingName = name.replace(CombiningExposureFunction.NAME, ""); return new CombiningExposureFunction(getExposureFunction(securitySource, underlyingName)); } switch (name) { case ContractCategoryExposureFunction.NAME: return new ContractCategoryExposureFunction(securitySource); case CounterpartyExposureFunction.NAME: return new CounterpartyExposureFunction(); case CurrencyExposureFunction.NAME: return new CurrencyExposureFunction(securitySource); case RegionExposureFunction.NAME: return new RegionExposureFunction(securitySource); case SecurityAndCurrencyExposureFunction.NAME: return new SecurityAndCurrencyExposureFunction(securitySource); case SecurityAndRegionExposureFunction.NAME: return new SecurityAndRegionExposureFunction(securitySource); case SecurityAndSettlementExchangeExposureFunction.NAME: return new SecurityAndSettlementExchangeExposureFunction(); case SecurityAndTradingExchangeExposureFunction.NAME: return new SecurityAndTradingExchangeExposureFunction(); case SecurityExposureFunction.NAME: return new SecurityExposureFunction(); case SecurityTypeExposureFunction.NAME: return new SecurityTypeExposureFunction(); case TradeAttributeExposureFunction.NAME: return new TradeAttributeExposureFunction(); case UnderlyingExposureFunction.NAME: return new UnderlyingExposureFunction(securitySource); default: throw new OpenGammaRuntimeException("Could not get exposure function called " + name); } }  static ExposureFunction getExposureFunction(final SecuritySource securitySource, final String name);  }
@Test public void testContractCategoryExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), ContractCategoryExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected ContractCategoryExposureFunction", function instanceof ContractCategoryExposureFunction); }
@Test public void testCounterpartyExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), CounterpartyExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected CounterpartyExposureFunction", function instanceof CounterpartyExposureFunction); }
@Test public void testCurrencyExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), CurrencyExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected CurrencyExposureFunction", function instanceof CurrencyExposureFunction); }
@Test public void testRegionExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), RegionExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected RegionExposureFunction", function instanceof RegionExposureFunction); }
@Test public void testSecurityAndCurrencyExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), SecurityAndCurrencyExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected SecurityAndCurrencyExposureFunction", function instanceof SecurityAndCurrencyExposureFunction); }
@Test public void testSecurityAndRegionExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), SecurityAndRegionExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected SecurityAndRegionExposureFunction", function instanceof SecurityAndRegionExposureFunction); }
@Test public void testSecurityAndSettlementExchangeExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), SecurityAndSettlementExchangeExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected SecurityAndSettlementExchangeExposureFunction", function instanceof SecurityAndSettlementExchangeExposureFunction); }
@Test public void testSecurityAndTradingExchangeExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), SecurityAndTradingExchangeExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected SecurityAndTradingExchangeExposureFunction", function instanceof SecurityAndTradingExchangeExposureFunction); }
@Test public void testSecurityExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), SecurityExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected SecurityExposureFunction", function instanceof SecurityExposureFunction); }
@Test public void testSecurityTypeExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), SecurityTypeExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected SecurityTypeExposureFunction", function instanceof SecurityTypeExposureFunction); }
@Test public void testUnderlyingExposureFunction() { ExposureFunction function = ExposureFunctionFactory.getExposureFunction(ExposureFunctionTestHelper.getSecuritySource(null), UnderlyingExposureFunction.NAME); assertNotNull("Null exposure function", function); assertTrue("Expected UnderlyingExposureFunction", function instanceof UnderlyingExposureFunction); }