This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View.OnClickListener onClickListener = new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
if(view == fetchTweetButton){ | |
registerSubscription( | |
tweeterApi.getTweet() | |
.subscribe(s -> { | |
currentTweetTextView.setText(s); | |
tweetsAdded++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.patrykpoborca.cleanarchitecture.mockimpl; | |
import io.patrykpoborca.cleanarchitecture.network.base.OKHttp; | |
public class MockOkHTTP extends OKHttp { | |
@Override | |
public String rawResponse() { | |
return "Mocked raw response: "; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MockRetrofit extends Retrofit { | |
private static final String MOCK_PARSE = "SomeMockResponse"; | |
public static final String MOCKED_STRING = "MOCKED PAGE:"; | |
public MockRetrofit(OKHttp okHttp, Scheduler mainScheduler) { | |
super(okHttp, mainScheduler); | |
} | |
@Override | |
public Observable<String> completeRequest() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class NetworkModule { | |
@ApplicationScope | |
@Provides | |
protected OKHttp providesOkHTTP(){ | |
return new OKHttp(); | |
} | |
@ApplicationScope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Retrofit { | |
protected OKHttp okHttp; | |
protected final Scheduler mainScheduler; | |
public Retrofit(OKHttp okHttp, Scheduler mainScheduler) { | |
this.okHttp = okHttp; | |
this.mainScheduler = mainScheduler; | |
} | |
public Observable<String> completeRequest(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class ThreadingModule { | |
@Named(Constants.MAIN_THREAD) | |
@Provides | |
public Scheduler providesMainThread(){ | |
return AndroidSchedulers.mainThread(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MockLocalDataCache extends LocalDataCache { | |
public MockLocalDataCache(Context context) { | |
super(context); | |
} | |
@Override | |
public void saveTweet(String tweet) { | |
sPastTweets.add(tweet); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MockTweeterApi extends TweeterApi{ | |
public MockTweeterApi(Retrofit retrofit, LocalDataCache dataCache, Scheduler mainScheduler) { | |
super(retrofit, dataCache, mainScheduler); | |
} | |
@Override | |
public Observable<UserProfile> login(String username, String password) { | |
return Observable.just(new UserProfile(username, password)) | |
.observeOn(mainScheduler); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestHelper { | |
private static ApplicationComponent sApplicationComponent; | |
private static BaseComponent sBaseComponent; | |
private static TestClassInjector sTestClassInjector; | |
public static ApplicationComponent getApplicationComponent(){ | |
if(sApplicationComponent == null) | |
{ | |
sApplicationComponent = DaggerApplicationComponent.builder() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(AndroidJUnit4.class) | |
public class PlainTweeterTest { | |
@Rule | |
public ActivityTestRule<io.patrykpoborca.cleanarchitecture.ui.PlainTweeterActivity> plainTweeterActivity = new ActivityTestRule<>(io.patrykpoborca.cleanarchitecture.ui.PlainTweeterActivity.class, | |
false, | |
true); | |
private static final String SOME_URL = "SOME_URL"; | |
private static final String USER_PASSWORD = "USER_PASSWORD"; |