Skip to content

Commit

Permalink
Migrate to Sandwich 2.0 for core-data module
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Nov 2, 2023
1 parent 027faeb commit 15e159f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.skydoves.pokedex.core.repository.DetailRepositoryImpl
import com.skydoves.pokedex.core.test.MainCoroutinesRule
import com.skydoves.pokedex.core.test.MockUtil.mockPokemonInfo
import com.skydoves.sandwich.ApiResponse
import com.skydoves.sandwich.retrofit.responseOf
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
import org.junit.Before
Expand Down Expand Up @@ -60,7 +61,7 @@ class DetailRepositoryTest {
val mockData = mockPokemonInfo()
whenever(pokemonInfoDao.getPokemonInfo(name_ = "bulbasaur")).thenReturn(null)
whenever(service.fetchPokemonInfo(name = "bulbasaur")).thenReturn(
ApiResponse.of {
ApiResponse.responseOf {
Response.success(
mockData,
)
Expand All @@ -86,7 +87,7 @@ class DetailRepositoryTest {
val mockData = mockPokemonInfo()
whenever(pokemonInfoDao.getPokemonInfo(name_ = "bulbasaur")).thenReturn(mockData.asEntity())
whenever(service.fetchPokemonInfo(name = "bulbasaur")).thenReturn(
ApiResponse.of {
ApiResponse.responseOf {
Response.success(
mockData,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.skydoves.pokedex.core.repository.MainRepositoryImpl
import com.skydoves.pokedex.core.test.MainCoroutinesRule
import com.skydoves.pokedex.core.test.MockUtil.mockPokemonList
import com.skydoves.sandwich.ApiResponse
import com.skydoves.sandwich.retrofit.responseOf
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
import org.junit.Before
Expand Down Expand Up @@ -62,7 +63,13 @@ class MainRepositoryImplTest {
PokemonResponse(count = 984, next = null, previous = null, results = mockPokemonList())
whenever(pokemonDao.getPokemonList(page_ = 0)).thenReturn(emptyList())
whenever(pokemonDao.getAllPokemonList(page_ = 0)).thenReturn(mockData.results.asEntity())
whenever(service.fetchPokemonList()).thenReturn(ApiResponse.of { Response.success(mockData) })
whenever(service.fetchPokemonList()).thenReturn(
ApiResponse.responseOf {
Response.success(
mockData,
)
},
)

repository.fetchPokemonList(
page = 0,
Expand Down

0 comments on commit 15e159f

Please sign in to comment.