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
| import com.app.coroutinesmvp.data.MovieListResponse | |
| import retrofit2.http.GET | |
| import retrofit2.http.Query | |
| interface MovieApi { | |
| @GET("/3/discover/movie") | |
| suspend fun getMoviesList(@Query("api_key") apiKey: String): MovieListResponse | |
| } |
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
| internal fun callMoviesApi() { | |
| movieModel.callMoviesApi() | |
| .onStart { | |
| movieView.showLoadingView() | |
| } | |
| .catch { | |
| movieView.showErrorView() | |
| } | |
| .onEach { | |
| movieView.showMoviesList(it) |
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
| import com.app.coroutinesmvp.model.MovieModel | |
| import com.app.coroutinesmvp.presenter.MoviePresenter | |
| import com.nhaarman.mockitokotlin2.mock | |
| import com.nhaarman.mockitokotlin2.verify | |
| import com.nhaarman.mockitokotlin2.whenever | |
| import kotlinx.coroutines.Dispatchers | |
| import kotlinx.coroutines.MainScope | |
| import kotlinx.coroutines.flow.flow | |
| import kotlinx.coroutines.plus |
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
| @DisplayName("when movie list api failed then show error view") | |
| @Test | |
| fun testApiFailed() { | |
| moviePresenter.callMoviesApi() | |
| verify(view).showLoadingView() | |
| verify(view).showErrorView() | |
| verify(view).hideLoadingView() | |
| } |
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
| @DisplayName("test on click listener for movie item") | |
| @Test | |
| fun testOnclickListener() { | |
| MovieStateFlow.onClickStateFlow.value = "Spider man" | |
| moviePresenter.observeOnClickStateFlow() | |
| verify(view).openSingleItemView("Spider man") | |
| } |
OlderNewer