ProxyTranslator { ConfigProvider processMethod(Method method, Object[] objectsMethod) { ConfigProvider prev = loadConfigProviderMethod(method); ConfigProvider configProvider = new ConfigProvider(prev.getProviderKey(), null, prev.getLifeTimeMillis(), prev.requiredDetailedResponse(), prev.isExpirable(), prev.isEncrypted(), getDynamicKey(method, objectsMethod), getDynamicKeyGroup(method, objectsMethod), getLoaderObservable(method, objectsMethod), evictProvider(method, objectsMethod)); return configProvider; } @Inject  ProxyTranslator();   }
@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)); }
@Test public void When_Use_Evict_Dynamic_Key_Group_Providing_Dynamic_Key_Group_Not_Throw_Exception() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod( "getMockEvictDynamicKeyGroupProvidingDynamicKeyGroup", Observable.class, DynamicKeyGroup.class, EvictDynamicKeyGroup.class); Object[] data = {Observable.just(new Object[]{}), new DynamicKeyGroup("1", "1"), new EvictDynamicKeyGroup(true)}; proxyTranslatorUT.processMethod(mockMethod, data); }
@Test(expected = IllegalArgumentException.class) public void When_Use_Evict_Dynamic_Key_Group_Without_Providing_Dynamic_Key_Group_Throw_Exception() throws NoSuchMethodException { Method mockMethod = ProvidersRxCache.class.getDeclaredMethod( "getMockEvictDynamicKeyGroupWithoutProvidingDynamicKeyGroup", Observable.class, EvictDynamicKeyGroup.class); Object[] data = {Observable.just(new Object[]{}), new EvictDynamicKeyGroup(true)}; proxyTranslatorUT.processMethod(mockMethod, data); }
@Test public void When_Return_Response_Then_Required_Detail_Response_Is_True() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocksWithDetailResponse", Observable.class); ConfigProvider configProvider = proxyTranslatorUT.processMethod(mockMethod, dataMethod); assertThat(configProvider.requiredDetailedResponse(), is(true)); }
@Test(expected = IllegalArgumentException.class) public void When_Method_Not_Return_Supported_Reactive_Type_Then_Throw_Exception() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMocksBadReturnType", Observable.class); proxyTranslatorUT.processMethod(mockMethod, dataMethod); }
@Test(expected = IllegalArgumentException.class) public void When_Not_Loader_Provided_Throw_Exception() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod( "getMockWithoutLoaderObservable"); Object[] emptyDataMethod = {}; proxyTranslatorUT.processMethod(mockMethod, emptyDataMethod); }
@Test(expected = IllegalArgumentException.class) public void When_Not_Return_Observable_Throw_Exception() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod( "getMockWithoutReturnObservable"); proxyTranslatorUT.processMethod(mockMethod, dataMethod); }
@Test(expected = IllegalArgumentException.class) public void When_Multiple_Observable_Throw_Exception() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMockMultipleObservables", Observable.class, Observable.class); Object[] data = {Observable.just(new Object[]{}), Observable.just("")}; proxyTranslatorUT.processMethod(mockMethod, data); }
@Test(expected = IllegalArgumentException.class) public void When_Multiple_Evict_Throw_Exception() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMockMultipleEvicts", Observable.class, EvictProvider.class, EvictProvider.class); Object[] data = {Observable.just(new Object[]{}), new EvictProvider(true), new EvictProvider(true)}; proxyTranslatorUT.processMethod(mockMethod, data); }
@Test(expected = IllegalArgumentException.class) public void When_Multiple_Dynamic_Keys_Throw_Exception() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod("getMockMultipleDynamicKeys", Observable.class, DynamicKey.class, DynamicKey.class); Object[] data = {Observable.just(new Object[]{}), new DynamicKey(1), new DynamicKey(1)}; proxyTranslatorUT.processMethod(mockMethod, data); }
@Test public void When_Use_Evict_Dynamic_Key_Providing_Dynamic_Key_Not_Throw_Exception() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod( "getMockEvictDynamicKeyProvidingDynamicKey", Observable.class, DynamicKey.class, EvictDynamicKey.class); Object[] data = {Observable.just(new Object[]{}), new DynamicKey("1"), new EvictDynamicKey(true)}; proxyTranslatorUT.processMethod(mockMethod, data); }
@Test(expected = IllegalArgumentException.class) public void When_Use_Evict_Dynamic_Key_Without_Providing_Dynamic_Key_Throw_Exception() throws NoSuchMethodException { Method mockMethod = io.rx_cache2.internal.ProvidersRxCache.class.getDeclaredMethod( "getMockEvictDynamicKeyWithoutProvidingDynamicKey", Observable.class, EvictDynamicKey.class); Object[] data = {Observable.just(new Object[]{}), new EvictDynamicKey(true)}; proxyTranslatorUT.processMethod(mockMethod, data); }