BloombergJmsTopicNameResolver extends AbstractResolver<JmsTopicNameResolveRequest, String> implements JmsTopicNameResolver { @Override public Map<JmsTopicNameResolveRequest, String> resolve(Collection<JmsTopicNameResolveRequest> requests) { Map<JmsTopicNameResolveRequest, String> returnValue = new HashMap<JmsTopicNameResolveRequest, String>(); Map<String, Collection<JmsTopicNameResolveRequest>> lookupKey2Requests = new HashMap<String, Collection<JmsTopicNameResolveRequest>>(); for (JmsTopicNameResolveRequest request : requests) { ExternalId marketDataUniqueId = request.getMarketDataUniqueId(); if (!marketDataUniqueId.getScheme().equals(ExternalSchemes.BLOOMBERG_BUID)) { s_logger.info("No Bloomberg BUID found, was given: " + marketDataUniqueId); returnValue.put(request, null); continue; } String lookupKey = BloombergDomainIdentifierResolver.toBloombergKey(marketDataUniqueId); Collection<JmsTopicNameResolveRequest> requestsForLookupKey = lookupKey2Requests.get(lookupKey); if (requestsForLookupKey == null) { requestsForLookupKey = new ArrayList<JmsTopicNameResolveRequest>(); lookupKey2Requests.put(lookupKey, requestsForLookupKey); } requestsForLookupKey.add(request); } if (!lookupKey2Requests.keySet().isEmpty()) { ReferenceDataProviderGetRequest rdRequest = ReferenceDataProviderGetRequest.createGet( lookupKey2Requests.keySet(), BloombergConstants.JMS_TOPIC_NAME_RESOLVER_FIELDS, true); ReferenceDataProviderGetResult referenceData = _referenceDataProvider.getReferenceData(rdRequest); for (Map.Entry<String, Collection<JmsTopicNameResolveRequest>> entry : lookupKey2Requests.entrySet()) { String lookupKey = entry.getKey(); ReferenceData result = referenceData.getReferenceDataOrNull(lookupKey); for (JmsTopicNameResolveRequest request : entry.getValue()) { String jmsTopicName = getJmsTopicName(request, result); returnValue.put(request, jmsTopicName); } } } return returnValue; } BloombergJmsTopicNameResolver(ReferenceDataProvider referenceDataProvider); ReferenceDataProvider getReferenceDataProvider(); @Override Map<JmsTopicNameResolveRequest, String> resolve(Collection<JmsTopicNameResolveRequest> requests);  }
@Test(enabled = false) private void testResolve(NormalizationRuleSet rules) { ReferenceDataProvider rdp = _server.getReferenceDataProvider(); BloombergIdResolver idResolver = new BloombergIdResolver(rdp); BloombergJmsTopicNameResolver topicNameResolver = new BloombergJmsTopicNameResolver(rdp); ExternalId aaplEquity = idResolver.resolve( ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("AAPL US Equity"))); String spec = topicNameResolver.resolve(new JmsTopicNameResolveRequest(aaplEquity, rules)); assertEquals("LiveData.Bloomberg.Equity.NASDAQ GS.AAPL" + rules.getJmsTopicSuffix(), spec); ExternalId usDomesticBond = idResolver.resolve( ExternalIdBundle.of(ExternalSchemes.cusipSecurityId("607059AT9"))); spec = topicNameResolver.resolve(new JmsTopicNameResolveRequest(usDomesticBond, rules)); assertEquals("LiveData.Bloomberg.Bond.MOBIL CORP.607059AT9" + rules.getJmsTopicSuffix(), spec); ExternalId globalBond = idResolver.resolve( ExternalIdBundle.of(ExternalSchemes.cusipSecurityId("4581X0AD0"))); spec = topicNameResolver.resolve(new JmsTopicNameResolveRequest(globalBond, rules)); assertEquals("LiveData.Bloomberg.Bond.INTER-AMERICAN DEVEL BK.US4581X0AD07" + rules.getJmsTopicSuffix(), spec); Set<ExternalId> options = BloombergDataUtils.getOptionChain(rdp, "AAPL US Equity"); assertFalse(options.isEmpty()); ExternalId aaplOptionId = options.iterator().next(); ExternalId aaplOption = idResolver.resolve(ExternalIdBundle.of(aaplOptionId)); spec = topicNameResolver.resolve(new JmsTopicNameResolveRequest(aaplOption, rules)); assertTrue(spec.startsWith("LiveData.Bloomberg.EquityOption.AAPL US.")); assertTrue(spec.endsWith(rules.getJmsTopicSuffix())); Map<JmsTopicNameResolveRequest, String> request2TopicName = topicNameResolver.resolve( Sets.newHashSet( new JmsTopicNameResolveRequest(aaplEquity, rules), new JmsTopicNameResolveRequest(usDomesticBond, rules))); assertEquals(2, request2TopicName.size()); assertEquals("LiveData.Bloomberg.Equity.NASDAQ GS.AAPL" + rules.getJmsTopicSuffix(), request2TopicName.get(new JmsTopicNameResolveRequest(aaplEquity, rules))); assertEquals("LiveData.Bloomberg.Bond.MOBIL CORP.607059AT9" + rules.getJmsTopicSuffix(), request2TopicName.get(new JmsTopicNameResolveRequest(usDomesticBond, rules))); }