HistoricalShockMarketDataProvider extends AbstractMarketDataProvider { @Override public void subscribe(ValueSpecification valueSpecification) { _historicalProvider1.subscribe(valueSpecification); _historicalProvider2.subscribe(valueSpecification); _baseProvider.subscribe(valueSpecification); } HistoricalShockMarketDataProvider(MarketDataProvider historicalProvider1,
                                           MarketDataProvider historicalProvider2,
                                           MarketDataProvider baseProvider); @Override void subscribe(ValueSpecification valueSpecification); @Override void subscribe(Set<ValueSpecification> valueSpecifications); @Override void unsubscribe(ValueSpecification valueSpecification); @Override void unsubscribe(Set<ValueSpecification> valueSpecifications); @Override MarketDataAvailabilityProvider getAvailabilityProvider(MarketDataSpecification marketDataSpec); @Override MarketDataPermissionProvider getPermissionProvider(); @Override boolean isCompatible(MarketDataSpecification marketDataSpec); @Override HistoricalShockMarketDataSnapshot snapshot(MarketDataSpecification marketDataSpec); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void subscribe() { Provider provider1 = new Provider(); Provider provider2 = new Provider(); Provider baseProvider = new Provider(); HistoricalShockMarketDataProvider shockProvider = new HistoricalShockMarketDataProvider(provider1, provider2, baseProvider); MarketDataListener listener = mock(MarketDataListener.class); shockProvider.addListener(listener); provider1.valueChanged(SPEC1); verify(listener).valuesChanged(Collections.singleton(SPEC1)); provider1.valueChanged(SPEC2); verify(listener).valuesChanged(Collections.singleton(SPEC2)); provider2.valueChanged(SPEC3); verify(listener).valuesChanged(Collections.singleton(SPEC3)); baseProvider.valueChanged(SPEC4); verify(listener).valuesChanged(Collections.singleton(SPEC4)); shockProvider.removeListener(listener); provider1.valueChanged(SPEC1); verifyNoMoreInteractions(listener); }