// Path: waterfallcache/src/main/java/com/github/simonpercic/waterfallcache/cache/RxCache.java
// public interface RxCache {
// 
//     /**
//      * Get from cache.
//      *
//      * @param key key
//      * @param typeOfT type of cache value
//      * @param <T> T of cache value
//      * @return Observable that emits the cache value
//      */
//     <T> Observable<T> get(String key, Type typeOfT);
// 
//     /**
//      * Put value to cache.
//      *
//      * @param key key
//      * @param object value
//      * @return Observable that emits <tt>true</tt> if successful, <tt>false</tt> otherwise
//      */
//     Observable<Boolean> put(String key, Object object);
// 
//     /**
//      * Cache contains key.
//      *
//      * @param key key
//      * @return Observable that emits <tt>true</tt> if cache contains key, <tt>false</tt> otherwise
//      */
//     Observable<Boolean> contains(String key);
// 
//     /**
//      * Remove cache value.
//      *
//      * @param key key
//      * @return Observable that emits <tt>true</tt> if successful, <tt>false</tt> otherwise
//      */
//     Observable<Boolean> remove(String key);
// 
//     /**
//      * Clear all cache values.
//      *
//      * @return Observable that emits <tt>true</tt> if successful, <tt>false</tt> otherwise
//      */
//     Observable<Boolean> clear();
// }
// 
// Path: waterfallcache/src/main/java/com/github/simonpercic/waterfallcache/callback/WaterfallCallback.java
// public interface WaterfallCallback extends WaterfallFailureCallback {
// 
//     /**
//      * Called on success.
//      */
//     void onSuccess();
// }
// 
// Path: waterfallcache/src/main/java/com/github/simonpercic/waterfallcache/callback/WaterfallGetCallback.java
// public interface WaterfallGetCallback<T> extends WaterfallFailureCallback {
// 
//     /**
//      * Called on success. Returns the value.
//      *
//      * @param object returned object
//      */
//     void onSuccess(T object);
// }
// 
// Path: waterfallcache/src/test/java/com/github/simonpercic/waterfallcache/model/SimpleObject.java
// public class SimpleObject {
// 
//     private String value;
// 
//     public SimpleObject(String value) {
//         this.value = value;
//     }
// 
//     public String getValue() {
//         return value;
//     }
// }


import com.github.simonpercic.waterfallcache.cache.RxCache;
import com.github.simonpercic.waterfallcache.callback.WaterfallCallback;
import com.github.simonpercic.waterfallcache.callback.WaterfallGetCallback;
import com.github.simonpercic.waterfallcache.model.SimpleObject;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.when;
package com.github.simonpercic.waterfallcache;






/**
 * @author Simon Percic <a href="https://github.com/simonpercic">https://github.com/simonpercic</a>
 */
public class WaterfallCacheAsyncTest {

    @Mock RxCache cache;

    WaterfallCache waterfallCache;

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);

        waterfallCache = WaterfallCache.builder()
                .addCache(cache)
                .withObserveOnScheduler(Schedulers.immediate())
                .build();
    }

    @Test
    public void testGetAsync() throws Exception {
        String key = "TEST_KEY";
        String value = "TEST_VALUE";

// Path: waterfallcache/src/main/java/com/github/simonpercic/waterfallcache/cache/RxCache.java
// public interface RxCache {
// 
//     /**
//      * Get from cache.
//      *
//      * @param key key
//      * @param typeOfT type of cache value
//      * @param <T> T of cache value
//      * @return Observable that emits the cache value
//      */
//     <T> Observable<T> get(String key, Type typeOfT);
// 
//     /**
//      * Put value to cache.
//      *
//      * @param key key
//      * @param object value
//      * @return Observable that emits <tt>true</tt> if successful, <tt>false</tt> otherwise
//      */
//     Observable<Boolean> put(String key, Object object);
// 
//     /**
//      * Cache contains key.
//      *
//      * @param key key
//      * @return Observable that emits <tt>true</tt> if cache contains key, <tt>false</tt> otherwise
//      */
//     Observable<Boolean> contains(String key);
// 
//     /**
//      * Remove cache value.
//      *
//      * @param key key
//      * @return Observable that emits <tt>true</tt> if successful, <tt>false</tt> otherwise
//      */
//     Observable<Boolean> remove(String key);
// 
//     /**
//      * Clear all cache values.
//      *
//      * @return Observable that emits <tt>true</tt> if successful, <tt>false</tt> otherwise
//      */
//     Observable<Boolean> clear();
// }
// 
// Path: waterfallcache/src/main/java/com/github/simonpercic/waterfallcache/callback/WaterfallCallback.java
// public interface WaterfallCallback extends WaterfallFailureCallback {
// 
//     /**
//      * Called on success.
//      */
//     void onSuccess();
// }
// 
// Path: waterfallcache/src/main/java/com/github/simonpercic/waterfallcache/callback/WaterfallGetCallback.java
// public interface WaterfallGetCallback<T> extends WaterfallFailureCallback {
// 
//     /**
//      * Called on success. Returns the value.
//      *
//      * @param object returned object
//      */
//     void onSuccess(T object);
// }
// 
// Path: waterfallcache/src/test/java/com/github/simonpercic/waterfallcache/model/SimpleObject.java
// public class SimpleObject {
// 
//     private String value;
// 
//     public SimpleObject(String value) {
//         this.value = value;
//     }
// 
//     public String getValue() {
//         return value;
//     }
// }


// Path: waterfallcache/src/test/java/com/github/simonpercic/waterfallcache/WaterfallCacheAsyncTest.java
import com.github.simonpercic.waterfallcache.cache.RxCache;
import com.github.simonpercic.waterfallcache.callback.WaterfallCallback;
import com.github.simonpercic.waterfallcache.callback.WaterfallGetCallback;
import com.github.simonpercic.waterfallcache.model.SimpleObject;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.when;

package com.github.simonpercic.waterfallcache;






/**
 * @author Simon Percic <a href="https://github.com/simonpercic">https://github.com/simonpercic</a>
 */
public class WaterfallCacheAsyncTest {

    @Mock RxCache cache;

    WaterfallCache waterfallCache;

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);

        waterfallCache = WaterfallCache.builder()
                .addCache(cache)
                .withObserveOnScheduler(Schedulers.immediate())
                .build();
    }

    @Test
    public void testGetAsync() throws Exception {
        String key = "TEST_KEY";
        String value = "TEST_VALUE";

        when(cache.get(eq(key), eq(SimpleObject.class))).thenReturn(Observable.just(new SimpleObject(value)));