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));
}
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));
}
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));
}
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));
}
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());
}
Aggregations