InMemoryLKVLiveMarketDataProviderFactory implements LiveMarketDataProviderFactory { @Override public MarketDataProvider create(UserPrincipal user, MarketDataSpecification marketDataSpec) { ArgumentChecker.notNull(user, "user"); ArgumentChecker.notNull(marketDataSpec, "marketDataSpec"); LiveMarketDataSpecification liveSpec = (LiveMarketDataSpecification) marketDataSpec; if (liveSpec.getDataSource() == null) { return _defaultFactory.create(user); } LiveDataFactory liveDataFactory = _namedFactories.get(liveSpec.getDataSource()); if (liveDataFactory == null) { throw new IllegalArgumentException("No provider could be created for data source '" + liveSpec.getDataSource() + "'"); } return liveDataFactory.create(user); } InMemoryLKVLiveMarketDataProviderFactory(LiveDataFactory defaultFactory, Map<String, LiveDataFactory> namedFactories); @Override MarketDataProvider create(UserPrincipal user, MarketDataSpecification marketDataSpec); @Override List<String> getProviderNames();  }
@Test public void createDefault() { MarketDataProvider provider = _factory.create(_user, LiveMarketDataSpecification.LIVE_SPEC); assertEquals(_defaultProvider, provider); }
@Test public void createNamed() { MarketDataProvider provider1 = _factory.create(_user, LiveMarketDataSpecification.of("1")); assertEquals(provider1, _provider1); MarketDataProvider provider2 = _factory.create(_user, LiveMarketDataSpecification.of("2")); assertEquals(provider2, _provider2); }
@Test(expectedExceptions = IllegalArgumentException.class) public void createMissing() { _factory.create(_user, LiveMarketDataSpecification.of("3")); }