This file contains 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 com.mycompany.flightstatuslistview.homeScreen; | |
import com.mycompany.flightstatuslistview.BuildConfig; | |
import org.junit.After; | |
import org.junit.Assert; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; |
This file contains 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
private class HomeActivityOutputSpy implements HomeInteractorInput { | |
boolean fetchHomeMetaDataIsCalled = false; | |
HomeRequest homeRequestCopy; | |
@Override | |
public void fetchHomeMetaData(HomeRequest request) { | |
fetchHomeMetaDataIsCalled = true; | |
homeRequestCopy = request; | |
} | |
} |
This file contains 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
@Test | |
public void onCreate_shouldCall_fetchHomeMetaData(){ | |
//Given | |
HomeActivityOutputSpy homeActivityOutputSpy = new HomeActivityOutputSpy(); | |
HomeActivity homeActivity = Robolectric.setupActivity(HomeActivity.class); | |
// It must have called the onCreate earlier, | |
// we are injecting the mock and calling the fetchMetaData to test our condition | |
homeActivity.output = homeActivityOutputSpy; | |
//When |
This file contains 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
@Test | |
public void HomeActivity_ShouldNOT_be_Null(){ | |
//Given | |
HomeActivity activity = Robolectric.setupActivity(HomeActivity.class); | |
//When | |
// Then | |
Assert.assertNotNull(activity); | |
} |
This file contains 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
interface HomeInteractorInput { | |
public void fetchHomeMetaData(HomeRequest request); | |
} |
This file contains 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 HomeActivity extends AppCompatActivity implements HomeActivityInput { | |
protected HomeInteractorInput output; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
getSupportActionBar().hide(); | |
HomeConfigurator.INSTANCE.configure(this); |
This file contains 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
@Test | |
public void onCreate_Calls_fetchHomeMetaData_withCorrectData(){ | |
//Given | |
HomeActivityOutputSpy homeActivityOutputSpy = new HomeActivityOutputSpy(); | |
HomeActivity homeActivity = Robolectric.setupActivity(HomeActivity.class); | |
homeActivity.output = homeActivityOutputSpy; | |
//When | |
homeActivity.fetchMetaData(); |
This file contains 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
interface HomeInteractorInput { | |
public void fetchHomeMetaData(HomeRequest request); | |
} | |
public class HomeInteractor implements HomeInteractorInput{ | |
public HomePresenterInput output; | |
public FlightWorkerInput flightWorkerInput; |
This file contains 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
private class HomePresenterInputSpy implements HomePresenterInput { | |
boolean presentHomeMetaDataIsCalled = false; | |
HomeResponse homeResponseCopy; | |
@Override | |
public void presentHomeMetaData(HomeResponse response) { | |
presentHomeMetaDataIsCalled = true; | |
homeResponseCopy = response; | |
} | |
} |
This file contains 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
private class FlightWorkerInputSpy implements FlightWorkerInput { | |
boolean isgetFutureFlightsMethodCalled = false; | |
boolean isgetPastFlightsMethodCalled = false; | |
@Override | |
public ArrayList<FlightModel> getFutureFlights() { | |
isgetFutureFlightsMethodCalled = true; | |
ArrayList<FlightModel> flightsList = getFlightModels(); | |
return flightsList; |
OlderNewer