Buggy code:
@ Listeners ( CacheValidationListener . class ) @ Test ( dataProviderClass = CacheProvider . class ) public final class ExpireAfterAccessTest { @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterAccess = Expire . ONE_MINUTE , population = { Population . PARTIAL , Population . FULL } ) public void getIfPresent ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterAccess = Expire . ONE_MINUTE , population = { Population . PARTIAL , Population . FULL } ) public void get ( Cache < Integer , Integer > cache , CacheContext context ) { <START_BUG> Function < Integer , Integer > mappingFunction = ( key ) -> - key ; <END_BUG> context . ticker ( ) . advance ( 30 , TimeUnit . SECONDS ) ; cache . get ( context . firstKey ( ) , mappingFunction ) ; context . ticker ( ) . advance ( 45 , TimeUnit . SECONDS ) ; cache . get ( context . firstKey ( ) , mappingFunction ) ; cache . get ( context . lastKey ( ) , mappingFunction ) ; cache . cleanUp ( ) ; assertThat ( cache . estimatedSize ( ) , is ( 2L ) ) ; long count = ( context . initialSize ( ) ) - 1 ; assertThat ( cache , hasRemovalNotifications ( context , count , EXPIRED ) ) ; } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterAccess = Expire . ONE_MINUTE , population = { Population . PARTIAL , Population . FULL } ) public void getAllPresent ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterAccess = Expire . ONE_MINUTE , population = { Population . SINGLETON , Population . PARTIAL , Population . FULL } ) public void put ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterAccess = Expire . ONE_MINUTE , population = { Population . SINGLETON , Population . PARTIAL , Population . FULL } ) public void putAll ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterAccess = Expire . ONE_MINUTE , population = { Population . SINGLETON , Population . PARTIAL , Population . FULL } ) public void size ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterAccess = Expire . ONE_MINUTE , loader = Loader . IDENTITY , population = { Population . PARTIAL , Population . FULL } ) public void get ( LoadingCache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterAccess = Expire . ONE_MINUTE , loader = Loader . IDENTITY , population = { Population . PARTIAL , Population . FULL } ) public void getAll ( LoadingCache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterAccess = Expire . ONE_MINUTE ) public void getExpiresAfter_access ( @ ExpireAfterAccess Expiration < Integer , Integer > expireAfterAccess ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterAccess = Expire . ONE_MINUTE ) public void setExpiresAfter_access ( Cache < Integer , Integer > cache , CacheContext context , @ ExpireAfterAccess Expiration < Integer , Integer > expireAfterAccess ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterAccess = Expire . ONE_MINUTE , population = { Population . SINGLETON , Population . PARTIAL , Population . FULL } ) public void ageOf_access ( CacheContext context , @ ExpireAfterAccess Expiration < Integer , Integer > expireAfterAccess ) { } @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterAccess = Expire . ONE_MINUTE ) @ Test ( dataProvider = "caches" , expectedExceptions = UnsupportedOperationException . class ) public void oldest_unmodifiable ( @ ExpireAfterAccess Expiration < Integer , Integer > expireAfterAccess ) { } @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterAccess = Expire . ONE_MINUTE ) @ Test ( dataProvider = "caches" , expectedExceptions = IllegalArgumentException . class ) public void oldest_negative ( @ ExpireAfterAccess Expiration < Integer , Integer > expireAfterAccess ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterAccess = Expire . ONE_MINUTE ) public void oldest_zero ( @ ExpireAfterAccess Expiration < Integer , Integer > expireAfterAccess ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( implementation = Implementation . Caffeine , population = Population . FULL , expireAfterAccess = Expire . ONE_MINUTE ) public void oldest_partial ( CacheContext context , @ ExpireAfterAccess Expiration < Integer , Integer > expireAfterAccess ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterAccess = Expire . ONE_MINUTE , removalListener = { Listener . DEFAULT , Listener . REJECTING } ) public void oldest_order ( CacheContext context , @ ExpireAfterAccess Expiration < Integer , Integer > expireAfterAccess ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterAccess = Expire . ONE_MINUTE ) public void oldest_snapshot ( Cache < Integer , Integer > cache , CacheContext context , @ ExpireAfterAccess Expiration < Integer , Integer > expireAfterAccess ) { }

Fix:
Function < Integer , Integer > mappingFunction = ( key ) -> context . original ( ) . get ( key ) ;