HistoricalShockMarketDataProvider extends AbstractMarketDataProvider { @Override public MarketDataPermissionProvider getPermissionProvider() { return _permissionProvider; } 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 permissionProvider() { MarketDataProvider historicalProvider1 = mock(MarketDataProvider.class); MarketDataProvider historicalProvider2 = mock(MarketDataProvider.class); MarketDataProvider baseProvider = mock(MarketDataProvider.class); MarketDataPermissionProvider pp1 = mock(MarketDataPermissionProvider.class); MarketDataPermissionProvider pp2 = mock(MarketDataPermissionProvider.class); MarketDataPermissionProvider pp3 = mock(MarketDataPermissionProvider.class); when(historicalProvider1.getPermissionProvider()).thenReturn(pp1); when(historicalProvider2.getPermissionProvider()).thenReturn(pp2); when(baseProvider.getPermissionProvider()).thenReturn(pp3); Set<ValueSpecification> specs = ImmutableSet.of(SPEC1, SPEC2, SPEC3, SPEC4); when(pp1.checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)).thenReturn(Collections.singleton(SPEC1)); when(pp2.checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)).thenReturn(Collections.singleton(SPEC2)); when(pp3.checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)).thenReturn(Collections.singleton(SPEC3)); HistoricalShockMarketDataProvider provider = new HistoricalShockMarketDataProvider(historicalProvider1, historicalProvider2, baseProvider); assertEquals(ImmutableSet.of(SPEC1, SPEC2, SPEC3), provider.getPermissionProvider().checkMarketDataPermissions(UserPrincipal.getTestUser(), specs)); }