// Path: src/main/java/com/navercorp/arcus/spring/cache/front/ArcusFrontCache.java
// public interface ArcusFrontCache {
// 
//   Object get(String key);
//   void set(String key, Object value, int expireTime);
//   void delete(String key);
//   void clear();
// 
// }
// 
// Path: src/main/java/com/navercorp/arcus/spring/concurrent/KeyLockProvider.java
// public interface KeyLockProvider {
// 
//   ReadWriteLock getLockForKey(Object key);
// 
// }


import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
import com.navercorp.arcus.spring.cache.front.ArcusFrontCache;
import com.navercorp.arcus.spring.concurrent.KeyLockProvider;
import net.spy.memcached.ArcusClientPool;
import net.spy.memcached.internal.GetFuture;
import net.spy.memcached.internal.OperationFuture;
import net.spy.memcached.transcoders.SerializingTranscoder;
import net.spy.memcached.transcoders.Transcoder;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cache.Cache;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

  @Test
  public void testClear_FrontCache_FutureException_ForceFrontCaching() {
    // given
    arcusCache.setForceFrontCaching(true);
    arcusCache.setArcusFrontCache(arcusFrontCache);
    when(arcusClientPool.flush(arcusCache.getServiceId() + arcusCache.getPrefix()))
        .thenReturn(createOperationFutureException());

    // when
    arcusCache.clear();

    // then
    verify(arcusClientPool, times(1))
        .flush(arcusCache.getServiceId() + arcusCache.getPrefix());
    verify(arcusFrontCache, times(1))
        .clear();
  }

  @Test
  public void testGetType() {
    // given
    when(arcusClientPool.asyncGet(arcusKey))
        .thenReturn(createGetFuture(VALUE));

    // when
    Object value = arcusCache.get(ARCUS_STRING_KEY, String.class);

    // then
    verify(arcusClientPool, times(1))
// Path: src/main/java/com/navercorp/arcus/spring/cache/front/ArcusFrontCache.java
// public interface ArcusFrontCache {
// 
//   Object get(String key);
//   void set(String key, Object value, int expireTime);
//   void delete(String key);
//   void clear();
// 
// }
// 
// Path: src/main/java/com/navercorp/arcus/spring/concurrent/KeyLockProvider.java
// public interface KeyLockProvider {
// 
//   ReadWriteLock getLockForKey(Object key);
// 
// }


// Path: src/test/java/com/navercorp/arcus/spring/cache/ArcusCacheTest.java
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
import com.navercorp.arcus.spring.cache.front.ArcusFrontCache;
import com.navercorp.arcus.spring.concurrent.KeyLockProvider;
import net.spy.memcached.ArcusClientPool;
import net.spy.memcached.internal.GetFuture;
import net.spy.memcached.internal.OperationFuture;
import net.spy.memcached.transcoders.SerializingTranscoder;
import net.spy.memcached.transcoders.Transcoder;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cache.Cache;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;


  @Test
  public void testClear_FrontCache_FutureException_ForceFrontCaching() {
    // given
    arcusCache.setForceFrontCaching(true);
    arcusCache.setArcusFrontCache(arcusFrontCache);
    when(arcusClientPool.flush(arcusCache.getServiceId() + arcusCache.getPrefix()))
        .thenReturn(createOperationFutureException());

    // when
    arcusCache.clear();

    // then
    verify(arcusClientPool, times(1))
        .flush(arcusCache.getServiceId() + arcusCache.getPrefix());
    verify(arcusFrontCache, times(1))
        .clear();
  }

  @Test
  public void testGetType() {
    // given
    when(arcusClientPool.asyncGet(arcusKey))
        .thenReturn(createGetFuture(VALUE));

    // when
    Object value = arcusCache.get(ARCUS_STRING_KEY, String.class);

    // then
    verify(arcusClientPool, times(1))
        .asyncGet(arcusKey);