CompositeMarketDataSnapshot implements MarketDataSnapshot { @Override public Object query(final ValueSpecification value) { ArgumentChecker.notNull(value, "value"); final Pair<Integer, ValueSpecification> lookup = _valueMap.getUnderlyingAndSpecification(value); if (lookup == null) { return null; } return _snapshots.get(lookup.getFirst()).query(lookup.getSecond()); } CompositeMarketDataSnapshot(final List<MarketDataSnapshot> snapshots, final SnapshottingViewExecutionDataProvider.ValueSpecificationProvider valueMap); @Override UniqueId getUniqueId(); @Override Instant getSnapshotTimeIndication(); @Override void init(); @Override void init(final Set<ValueSpecification> values, final long timeout, final TimeUnit unit); @Override boolean isInitialized(); @Override boolean isEmpty(); @Override Instant getSnapshotTime(); @Override Object query(final ValueSpecification value); @Override Map<ValueSpecification, Object> query(final Set<ValueSpecification> values);  }
@Test public void queryOne() { assertEquals(VALUE1, _snapshot.query(SPECIFICATION1_EXT)); assertEquals(VALUE2, _snapshot.query(SPECIFICATION2_EXT)); assertNull(_snapshot.query(UNKNOWN_SPECIFICATION)); }
@Test public void queryMultiSubset() { final Set<ValueSpecification> specs = Sets.newHashSet(SPECIFICATION1_EXT, UNKNOWN_SPECIFICATION); final Map<ValueSpecification, Object> result = _snapshot.query(specs); assertEquals(VALUE1, result.get(SPECIFICATION1_EXT)); assertNull(result.get(SPECIFICATION2_EXT)); assertNull(result.get(UNKNOWN_SPECIFICATION)); }
@Test public void queryMultiAll() { final Set<ValueSpecification> specs = Sets.newHashSet(SPECIFICATION1_EXT, SPECIFICATION2_EXT, UNKNOWN_SPECIFICATION); final Map<ValueSpecification, Object> result = _snapshot.query(specs); assertEquals(VALUE1, result.get(SPECIFICATION1_EXT)); assertEquals(VALUE2, result.get(SPECIFICATION2_EXT)); assertNull(result.get(UNKNOWN_SPECIFICATION)); }