@@ -4,7 +4,7 @@ import androidx.paging.PagingConfig
4
4
import androidx.paging.PagingSource
5
5
import androidx.paging.PagingState
6
6
import com.aliasadi.core.test.base.BaseTest
7
- import com.aliasadi.domain .entities.MovieEntity
7
+ import com.aliasadi.data .entities.MovieData
8
8
import com.aliasadi.domain.util.Result
9
9
import org.junit.Assert.assertEquals
10
10
import org.junit.Assert.assertNull
@@ -27,10 +27,18 @@ class SearchMoviePagingSourceTest : BaseTest() {
27
27
28
28
@Test
29
29
fun `test load returns page on success with distinct movies` () = runUnconfinedTest {
30
- val movieEntity1 = MovieEntity (1 , " Title1" , " Description1" , " Image1" , " Category1" , " BackgroundUrl1" )
31
- val movieEntity2 = MovieEntity (2 , " Title2" , " Description2" , " Image2" , " Category2" , " BackgroundUrl2" )
32
- val duplicateMovieEntity = MovieEntity (1 , " Title1" , " Description1" , " Image1" , " Category1" , " BackgroundUrl1" )
33
- whenever(remote.search(any(), any(), any())).thenReturn(Result .Success (listOf (movieEntity1, movieEntity2, duplicateMovieEntity)))
30
+ val movieEntity1 = MovieData (1 , " Title1" , " Description1" , " Image1" , " Category1" , " BackgroundUrl1" )
31
+ val movieEntity2 = MovieData (2 , " Title2" , " Description2" , " Image2" , " Category2" , " BackgroundUrl2" )
32
+ val duplicateMovieEntity = MovieData (1 , " Title1" , " Description1" , " Image1" , " Category1" , " BackgroundUrl1" )
33
+ whenever(remote.search(any(), any(), any())).thenReturn(
34
+ Result .Success (
35
+ listOf (
36
+ movieEntity1,
37
+ movieEntity2,
38
+ duplicateMovieEntity
39
+ )
40
+ )
41
+ )
34
42
35
43
val params = PagingSource .LoadParams .Refresh <Int >(key = null , loadSize = 10 , placeholdersEnabled = false )
36
44
val result = sut.load(params)
@@ -44,15 +52,15 @@ class SearchMoviePagingSourceTest : BaseTest() {
44
52
45
53
@Test
46
54
fun `test load returns page on success with prevKey and nextKey` () = runUnconfinedTest {
47
- val movieEntity = MovieEntity (1 , " Title" , " Description" , " Image" , " Category" , " BackgroundUrl" )
48
- whenever(remote.search(any(), any(), any())).thenReturn(Result .Success (listOf (movieEntity )))
55
+ val movieData = MovieData (1 , " Title" , " Description" , " Image" , " Category" , " BackgroundUrl" )
56
+ whenever(remote.search(any(), any(), any())).thenReturn(Result .Success (listOf (movieData )))
49
57
50
- val params = PagingSource .LoadParams .Append < Int > (key = 2 , loadSize = 10 , placeholdersEnabled = false )
58
+ val params = PagingSource .LoadParams .Append (key = 2 , loadSize = 10 , placeholdersEnabled = false )
51
59
val result = sut.load(params)
52
60
53
61
assertTrue(result is PagingSource .LoadResult .Page )
54
62
result as PagingSource .LoadResult .Page
55
- assertEquals(listOf (movieEntity ), result.data)
63
+ assertEquals(listOf (movieData ), result.data)
56
64
assertEquals(1 , result.prevKey)
57
65
assertEquals(3 , result.nextKey)
58
66
}
@@ -90,8 +98,8 @@ class SearchMoviePagingSourceTest : BaseTest() {
90
98
pages = listOf (
91
99
PagingSource .LoadResult .Page (
92
100
data = listOf (
93
- MovieEntity (1 , " Title1" , " Description1" , " Image1" , " Category1" , " BackgroundUrl1" ),
94
- MovieEntity (2 , " Title2" , " Description2" , " Image2" , " Category2" , " BackgroundUrl2" )
101
+ MovieData (1 , " Title1" , " Description1" , " Image1" , " Category1" , " BackgroundUrl1" ),
102
+ MovieData (2 , " Title2" , " Description2" , " Image2" , " Category2" , " BackgroundUrl2" )
95
103
),
96
104
prevKey = 1 ,
97
105
nextKey = 3
@@ -108,7 +116,7 @@ class SearchMoviePagingSourceTest : BaseTest() {
108
116
109
117
@Test
110
118
fun `test getRefreshKey returns null when no anchor` () {
111
- val state = PagingState <Int , MovieEntity >(
119
+ val state = PagingState <Int , MovieData >(
112
120
pages = listOf (),
113
121
anchorPosition = null ,
114
122
config = PagingConfig (pageSize = 10 ),
0 commit comments