class RedisCache extends AbstractCache<K, V> {

  @Override
  public long size() {
    try {
      return client.dbsize();
    } catch (ConnectionException|IOException e) {
      throw new RedisCacheException(e);
    }
  }

}

class RedisCacheTest {

  @Mock Client client;
   Serializer<Object> serializer;
  @Mock CacheLoader<Integer, Integer> cacheLoader;
  @Mock EvictionListener<Integer, Integer> evictionListener;
   RedisCache<Integer, Integer> cache;

  @Test
  public void size() throws ConnectionException, IOException {

    int size = 3;
    doReturn(size).when(client).dbsize();
    long actualSize = cache.size();
    assertEquals(size, actualSize);
  }

}