AnalyticsCacheSettings { public boolean isFixedCachingEnabled() { final AnalyticsCacheTtlMode analyticsCacheMode = (AnalyticsCacheTtlMode) systemSettingManager .getSystemSetting( ANALYTICS_CACHE_TTL_MODE ); final CacheStrategy cacheStrategy = (CacheStrategy) systemSettingManager.getSystemSetting( CACHE_STRATEGY ); return FIXED == analyticsCacheMode && cacheStrategy != null && cacheStrategy.hasExpirationTimeSet(); } AnalyticsCacheSettings( final SystemSettingManager systemSettingManager ); boolean isProgressiveCachingEnabled(); boolean isFixedCachingEnabled(); long progressiveExpirationTimeOrDefault( final Date dateBeforeToday ); long fixedExpirationTimeOrDefault(); boolean isCachingEnabled();  }
@Test public void testWhenFixedCachingIsEnabled() { final AnalyticsCacheTtlMode fixedCacheTtlMode = FIXED; final CacheStrategy anyTimeoutStrategy = CACHE_1_MINUTE; when( systemSettingManager.getSystemSetting( ANALYTICS_CACHE_TTL_MODE ) ).thenReturn( fixedCacheTtlMode ); when( systemSettingManager.getSystemSetting( CACHE_STRATEGY ) ).thenReturn( anyTimeoutStrategy ); final boolean fixedCacheFlag = analyticsCacheSettings.isFixedCachingEnabled(); assertThat( fixedCacheFlag, is( true ) ); }
@Test public void testWhenFixedCachingIsEnabledButStrategyIsNoCache() { final AnalyticsCacheTtlMode fixedCacheTtlMode = FIXED; final CacheStrategy anyTimeoutStrategy = NO_CACHE; when( systemSettingManager.getSystemSetting( ANALYTICS_CACHE_TTL_MODE ) ).thenReturn( fixedCacheTtlMode ); when( systemSettingManager.getSystemSetting( CACHE_STRATEGY ) ).thenReturn( anyTimeoutStrategy ); final boolean fixedCacheFlag = analyticsCacheSettings.isFixedCachingEnabled(); assertThat( fixedCacheFlag, is( false ) ); }