AnalyticsCacheSettings { public long fixedExpirationTimeOrDefault() { final CacheStrategy cacheStrategy = (CacheStrategy) systemSettingManager.getSystemSetting( CACHE_STRATEGY ); if ( cacheStrategy != null && cacheStrategy.hasExpirationTimeSet() ) { return cacheStrategy.toSeconds(); } else { final CacheStrategy defaultExpirationTime = (CacheStrategy) CACHE_STRATEGY.getDefaultValue(); if ( defaultExpirationTime.hasExpirationTimeSet() ) { return defaultExpirationTime.toSeconds(); } else { return NO_CACHE.toSeconds(); } } } AnalyticsCacheSettings( final SystemSettingManager systemSettingManager ); boolean isProgressiveCachingEnabled(); boolean isFixedCachingEnabled(); long progressiveExpirationTimeOrDefault( final Date dateBeforeToday ); long fixedExpirationTimeOrDefault(); boolean isCachingEnabled();  }
@Test public void testWhenFixedExpirationTimeOrDefaultIsSet() { final CacheStrategy aCacheStrategy = CACHE_10_MINUTES; when( systemSettingManager.getSystemSetting( CACHE_STRATEGY ) ).thenReturn( aCacheStrategy ); final long expirationTime = analyticsCacheSettings.fixedExpirationTimeOrDefault(); assertThat( expirationTime, is( valueOf( CACHE_10_MINUTES.toSeconds() ) ) ); }
@Test public void testWhenFixedExpirationTimeOrDefaultIsNotCache() { final CacheStrategy aCacheStrategy = NO_CACHE; final long theExpectedExpirationTime = ((CacheStrategy) CACHE_STRATEGY.getDefaultValue()).toSeconds(); when( systemSettingManager.getSystemSetting( CACHE_STRATEGY ) ).thenReturn( aCacheStrategy ); final long expirationTime = analyticsCacheSettings.fixedExpirationTimeOrDefault(); assertThat( expirationTime, is( theExpectedExpirationTime ) ); }