Buggy code:
@ Listeners ( CacheValidationListener . class ) @ Test ( dataProviderClass = CacheProvider . class ) public final class ExpireAfterWriteTest { @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterWrite = Expire . ONE_MINUTE , population = { Population . PARTIAL , Population . FULL } ) public void getIfPresent ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterWrite = 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 . lastKey ( ) , mappingFunction ) ; cache . cleanUp ( ) ; assertThat ( cache . estimatedSize ( ) , is ( 1L ) ) ; long count = context . initialSize ( ) ; assertThat ( cache , hasRemovalNotifications ( context , count , EXPIRED ) ) ; } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterWrite = Expire . ONE_MINUTE , population = { Population . PARTIAL , Population . FULL } ) public void getAllPresent ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterWrite = Expire . ONE_MINUTE , population = { Population . SINGLETON , Population . PARTIAL , Population . FULL } ) public void put ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterWrite = Expire . ONE_MINUTE , population = { Population . SINGLETON , Population . PARTIAL , Population . FULL } ) public void putAll ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterWrite = Expire . ONE_MINUTE , population = { Population . SINGLETON , Population . PARTIAL , Population . FULL } ) public void size ( Cache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterWrite = Expire . ONE_MINUTE , population = { Population . PARTIAL , Population . FULL } ) public void get ( LoadingCache < Integer , Integer > cache , CacheContext context ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( expireAfterWrite = 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 , expireAfterWrite = Expire . ONE_MINUTE ) public void getExpiresAfter_write ( @ ExpireAfterWrite Expiration < Integer , Integer > expireAfterWrite ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterWrite = Expire . ONE_MINUTE ) public void setExpiresAfter_write ( Cache < Integer , Integer > cache , CacheContext context , @ ExpireAfterWrite Expiration < Integer , Integer > expireAfterWrite ) { } @ Test ( dataProvider = "caches" ) @ CacheSpec ( implementation = Implementation . Caffeine , expireAfterWrite = Expire . ONE_MINUTE , population = { Population . SINGLETON , Population . PARTIAL , Population . FULL } ) public void ageOf_write ( CacheContext context , @ ExpireAfterWrite Expiration < Integer , Integer > expireAfterWrite ) { } }

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