Search in sources :

Example 6 with ConfigProvider

use of io.rx_cache2.ConfigProvider in project RxCache by VictorAlbertos.

the class ProxyTranslatorTest method Check_Basic_Method.

@Test
public void Check_Basic_Method() throws NoSuchMethodException {
    Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocks", Observable.class);
    ConfigProvider configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethod);
    assertThat(configProvider.getProviderKey(), is("getMocks"));
    assertNotNull(configProvider.getLoaderObservable());
    assertNull(configProvider.getLifeTimeMillis());
    assertThat(configProvider.evictProvider().evict(), is(false));
    assertThat(configProvider.requiredDetailedResponse(), is(false));
}
Also used : ConfigProvider(io.rx_cache2.ConfigProvider) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 7 with ConfigProvider

use of io.rx_cache2.ConfigProvider in project RxCache by VictorAlbertos.

the class ProxyTranslatorTest method When_Evict_Cache_Evict.

@Test
public void When_Evict_Cache_Evict() throws NoSuchMethodException {
    Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocksEvictProvider", Observable.class, EvictProvider.class);
    Object[] dataMethodEvict = { Observable.just(new Object[] {}), new EvictProvider(true) };
    ConfigProvider configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethodEvict);
    assertThat(configProvider.evictProvider().evict(), is(true));
    Object[] dataMethodNoEvict = { Observable.just(new Object[] {}), new EvictProvider(false) };
    configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethodNoEvict);
    assertThat(configProvider.evictProvider().evict(), is(false));
}
Also used : ConfigProvider(io.rx_cache2.ConfigProvider) Method(java.lang.reflect.Method) EvictProvider(io.rx_cache2.EvictProvider) Test(org.junit.Test)

Example 8 with ConfigProvider

use of io.rx_cache2.ConfigProvider in project RxCache by VictorAlbertos.

the class ProxyTranslatorTest method Check_Method_With_Life_Time_Defined.

@Test
public void Check_Method_With_Life_Time_Defined() throws NoSuchMethodException {
    Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocksLifeTimeMinutes", Observable.class);
    ConfigProvider configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethod);
    assertThat(configProvider.getLifeTimeMillis(), is(60000l));
    mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocksLifeTimeSeconds", Observable.class);
    configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethod);
    assertThat(configProvider.getLifeTimeMillis(), is(1000l));
    mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocksLifeTimeMillis", Observable.class);
    configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethod);
    assertThat(configProvider.getLifeTimeMillis(), is(65000l));
}
Also used : ConfigProvider(io.rx_cache2.ConfigProvider) Method(java.lang.reflect.Method) Observable(io.reactivex.Observable) Test(org.junit.Test)

Example 9 with ConfigProvider

use of io.rx_cache2.ConfigProvider in project RxCache by VictorAlbertos.

the class ProxyTranslatorTest method When_Evict_Cache_Dynamic_Key_Evict.

@Test
public void When_Evict_Cache_Dynamic_Key_Evict() throws NoSuchMethodException {
    final String dynamicKey = "aDynamicKey";
    Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocksDynamicKeyEvictPage", Observable.class, DynamicKey.class, EvictDynamicKey.class);
    Object[] dataMethodEvict = { Observable.just(new Object[] {}), new DynamicKey(dynamicKey), new EvictDynamicKey(true) };
    ConfigProvider configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethodEvict);
    EvictDynamicKey evictDynamicKey = (EvictDynamicKey) configProvider.evictProvider();
    assertThat(configProvider.getDynamicKey(), is(dynamicKey));
    assertThat(evictDynamicKey.evict(), is(true));
    Object[] dataMethodNoEvict = { Observable.just(new Object[] {}), new DynamicKey(dynamicKey), new EvictDynamicKey(false) };
    configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethodNoEvict);
    evictDynamicKey = (EvictDynamicKey) configProvider.evictProvider();
    assertThat(configProvider.getDynamicKey(), is(dynamicKey));
    assertThat(evictDynamicKey.evict(), is(false));
}
Also used : ConfigProvider(io.rx_cache2.ConfigProvider) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) Method(java.lang.reflect.Method) EvictDynamicKey(io.rx_cache2.EvictDynamicKey) DynamicKey(io.rx_cache2.DynamicKey) Test(org.junit.Test)

Example 10 with ConfigProvider

use of io.rx_cache2.ConfigProvider in project RxCache by VictorAlbertos.

the class ProxyTranslatorTest method Check_Maybe_Reactive_Type.

@Test
public void Check_Maybe_Reactive_Type() throws NoSuchMethodException {
    Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocksMaybe", Maybe.class);
    ConfigProvider configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethod);
    assertNotNull(configProvider.getLoaderObservable());
}
Also used : ConfigProvider(io.rx_cache2.ConfigProvider) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

ConfigProvider (io.rx_cache2.ConfigProvider)12 Method (java.lang.reflect.Method)9 Test (org.junit.Test)9 Observable (io.reactivex.Observable)2 DynamicKey (io.rx_cache2.DynamicKey)2 EvictDynamicKey (io.rx_cache2.EvictDynamicKey)2 EvictProvider (io.rx_cache2.EvictProvider)2 ObservableEmitter (io.reactivex.ObservableEmitter)1 ObservableOnSubscribe (io.reactivex.ObservableOnSubscribe)1 Function (io.reactivex.functions.Function)1 TestObserver (io.reactivex.observers.TestObserver)1 Reply (io.rx_cache2.Reply)1