AnalyticsCacheSettings { public boolean isCachingEnabled() { return isFixedCachingEnabled() || isProgressiveCachingEnabled(); } AnalyticsCacheSettings( final SystemSettingManager systemSettingManager ); boolean isProgressiveCachingEnabled(); boolean isFixedCachingEnabled(); long progressiveExpirationTimeOrDefault( final Date dateBeforeToday ); long fixedExpirationTimeOrDefault(); boolean isCachingEnabled();  }
@Test public void testIsCachingEnabledWhenFixedExpirationTimeIsSet() { final AnalyticsCacheTtlMode fixedCacheTtlMode = FIXED; final CacheStrategy aCacheStrategy = CACHE_10_MINUTES; when( systemSettingManager.getSystemSetting( ANALYTICS_CACHE_TTL_MODE ) ).thenReturn( fixedCacheTtlMode ); when( systemSettingManager.getSystemSetting( CACHE_STRATEGY ) ).thenReturn( aCacheStrategy ); final boolean actualReturn = analyticsCacheSettings.isCachingEnabled(); assertThat( actualReturn, is( true ) ); }
@Test public void testIsCachingEnabledWhenProgressiveExpirationTimeIsSet() { final AnalyticsCacheTtlMode progressiveCacheTtlMode = PROGRESSIVE; final CacheStrategy anyCacheStrategyButNoCache = CACHE_10_MINUTES; when( systemSettingManager.getSystemSetting( ANALYTICS_CACHE_TTL_MODE ) ).thenReturn( progressiveCacheTtlMode ); when( systemSettingManager.getSystemSetting( CACHE_STRATEGY ) ).thenReturn( anyCacheStrategyButNoCache ); final boolean actualReturn = analyticsCacheSettings.isCachingEnabled(); assertThat( actualReturn, is( true ) ); }
@Test public void testIsCachingEnabledWhenFixedExpirationTimeIsSetAndStrategyIsNoCache() { final AnalyticsCacheTtlMode fixedCacheTtlMode = FIXED; final CacheStrategy cacheStrategyNoCache = NO_CACHE; when( systemSettingManager.getSystemSetting( ANALYTICS_CACHE_TTL_MODE ) ).thenReturn( fixedCacheTtlMode ); when( systemSettingManager.getSystemSetting( CACHE_STRATEGY ) ).thenReturn( cacheStrategyNoCache ); final boolean actualReturn = analyticsCacheSettings.isCachingEnabled(); assertThat( actualReturn, is( false ) ); }