@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));
}