public void test_get_subset() {
HistoricalTimeSeriesProviderGetRequest request = HistoricalTimeSeriesProviderGetRequest.createGet(BUNDLE, "S", "P", "F");
request.setMaxPoints(-1);
HistoricalTimeSeriesProviderGetRequest allRequest = HistoricalTimeSeriesProviderGetRequest.createGet(BUNDLE, "S", "P", "F");
HistoricalTimeSeriesProviderGetResult result = new HistoricalTimeSeriesProviderGetResult();
result.getResultMap().put(BUNDLE, BIG_HTS);
when(_underlyingProvider.getHistoricalTimeSeries(allRequest)).thenReturn(result);
// Fetching same series twice should return same result
HistoricalTimeSeriesProviderGetResult test1 = _cachingProvider.getHistoricalTimeSeries(request);
HistoricalTimeSeriesProviderGetResult test2 = _cachingProvider.getHistoricalTimeSeries(request);
assertEquals(test1, test2);
assertEquals(SMALL_HTS, test1.getResultMap().get(BUNDLE));
// underlying source should only have been called once if cache worked as expected
verify(_underlyingProvider, times(1)).getHistoricalTimeSeries(allRequest);
verify(_underlyingProvider, times(0)).getHistoricalTimeSeries(request);
// no further underlying hits
HistoricalTimeSeriesProviderGetResult test3 = _cachingProvider.getHistoricalTimeSeries(allRequest);
assertEquals(BIG_HTS, test3.getResultMap().get(BUNDLE));
// underlying source should only have been called once if cache worked as expected
verify(_underlyingProvider, times(1)).getHistoricalTimeSeries(allRequest);
verify(_underlyingProvider, times(0)).getHistoricalTimeSeries(request);
}