ExternalId working = ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER_WEAK, "USPFJD5W Curncy");
ExternalId workingStrong = ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER, "USPFJD5W Curncy");
List<ExternalId> instruments = Lists.newArrayList(broken, working, workingStrong);
int repeats = 2;
CollectingLiveDataListener listener = new CollectingLiveDataListener(instruments.size() * repeats, 1 * repeats);
for (int i = 0; i < repeats; i++) {
subscribe(_liveDataClient, listener, instruments);
unsubscribe(_liveDataClient, listener, instruments);
_unitTestingProvider.rejectAllfurtherRequests();
}
assertTrue(listener.waitUntilEnoughUpdatesReceived(30000));
LiveDataSubscriptionResponse workingSub = null;
LiveDataSubscriptionResponse workingStrongSub = null;
for (LiveDataSubscriptionResponse response : listener.getSubscriptionResponses()) {
if (response.getRequestedSpecification().getIdentifiers().contains(working)) {
assertEquals(response.getSubscriptionResult(), LiveDataSubscriptionResult.SUCCESS);
workingSub = response;
} else if (response.getRequestedSpecification().getIdentifiers().contains(broken)) {
assertEquals(response.getSubscriptionResult(), LiveDataSubscriptionResult.INTERNAL_ERROR);
} else if (response.getRequestedSpecification().getIdentifiers().contains(workingStrong)) {
assertEquals(response.getSubscriptionResult(), LiveDataSubscriptionResult.SUCCESS);
workingStrongSub = response;
} else {
throw new Exception("Unexpected subscription response");
}
}
assertEquals(workingSub.getFullyQualifiedSpecification(), workingStrongSub.getFullyQualifiedSpecification());
assertEquals(workingSub.getTickDistributionSpecification(), workingStrongSub.getTickDistributionSpecification());
List<LiveDataValueUpdate> allUpdates = listener.getValueUpdates();
List<LiveDataValueUpdate> workingUpdates = listener.getValueUpdates(getLiveDataSpec(_liveDataClient, working));
assertEquals(allUpdates, workingUpdates);
assertFalse(_unitTestingProvider.hadToRejectRequests()); // Necessary, since exceptions are expected from the live data service
}