void () { final int SIZE = 4; final IntObjectCache<String> cache = new IntObjectCache<>(SIZE); cache.addDeletedPairsListener((key, value) -> { if (cache.count() >= cache.size() ) { final int newSize = cache.size() * 2; cache.resize(newSize); assertEquals(newSize, cache.size()); cache.cacheObject(key, value); } }); final int count = SIZE * 2000; for (int i = 1; i <= count; i++) { cache.cacheObject(i, String.valueOf(i)); } for (int i = 1; i <= count; i++) { assertEquals(String.valueOf(i), cache.tryKey(i)); } }