protected ValueSpecification constructSpecification(final String ticker) {
return new ValueSpecification(_marketDataRequirement, constructTargetSpec(ticker), ValueProperties.with(ValuePropertyNames.FUNCTION, "MarketData").get());
}
public void snapshotting() {
final TestLiveDataClient client = new TestLiveDataClient();
final FixedMarketDataAvailabilityProvider availabilityProvider = new FixedMarketDataAvailabilityProvider();
availabilityProvider.addAvailableData(getTicker("test1"), constructSpecification("test1"));
availabilityProvider.addAvailableData(getTicker("test2"), constructSpecification("test2"));
availabilityProvider.addAvailableData(getTicker("test3"), constructSpecification("test3"));
final LiveMarketDataProvider provider = new InMemoryLKVLiveMarketDataProvider(client, availabilityProvider.getAvailabilityFilter(), UserPrincipal.getTestUser());
final ValueSpecification test1Specification = provider.getAvailabilityProvider(MarketData.live()).getAvailability(constructTargetSpec("test1"), getTicker("test1"), constructRequirement("test1"));
final ValueSpecification test2Specification = provider.getAvailabilityProvider(MarketData.live()).getAvailability(constructTargetSpec("test2"), getTicker("test2"), constructRequirement("test2"));
final ValueSpecification test3Specification = provider.getAvailabilityProvider(MarketData.live()).getAvailability(constructTargetSpec("test3"), getTicker("test3"), constructRequirement("test3"));
provider.subscribe(test1Specification);
provider.subscribe(test2Specification);
provider.subscribe(test3Specification);
provider.subscribe(test3Specification);
provider.subscribe(test3Specification);
final MutableFudgeMsg msg1 = new FudgeContext().newMessage();
msg1.add(_marketDataRequirement, 52.07);
final MutableFudgeMsg msg2 = new FudgeContext().newMessage();
msg2.add(_marketDataRequirement, 52.15);
final MutableFudgeMsg msg3a = new FudgeContext().newMessage();
msg3a.add(_marketDataRequirement, 52.16);
final MutableFudgeMsg msg3b = new FudgeContext().newMessage();
msg3b.add(_marketDataRequirement, 52.17);
client.marketDataReceived(new LiveDataSpecification(client.getDefaultNormalizationRuleSetId(), getTicker("test1")), msg1);
client.marketDataReceived(new LiveDataSpecification(client.getDefaultNormalizationRuleSetId(), getTicker("test2")), msg2);
client.marketDataReceived(new LiveDataSpecification(client.getDefaultNormalizationRuleSetId(), getTicker("test3")), msg3a);
client.marketDataReceived(new LiveDataSpecification(client.getDefaultNormalizationRuleSetId(), getTicker("test3")), msg3b);
final MarketDataSnapshot snapshot = provider.snapshot(null);
snapshot.init(Collections.<ValueSpecification>emptySet(), 0, TimeUnit.MILLISECONDS);
final Double test1Value = (Double) snapshot.query(test1Specification);
assertNotNull(test1Value);
assertEquals(52.07, test1Value, 0.000001);