mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 13:53:54 +01:00
With media client APIs migrated to retrofit (#2998)
* With media client APIs migrated to retrofit * Add test cases and java docs * Fix test * Fix build * Fix build and other minor issues * Fix tests
This commit is contained in:
parent
828b5a3cd1
commit
78141cb609
17 changed files with 252 additions and 92 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package fr.free.nrw.commons.review
|
||||
|
||||
import fr.free.nrw.commons.Media
|
||||
import fr.free.nrw.commons.media.MediaClient
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi
|
||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
|
||||
import io.reactivex.Observable
|
||||
|
|
@ -31,6 +32,8 @@ class ReviewHelperTest {
|
|||
internal var okHttpJsonApiClient: OkHttpJsonApiClient? = null
|
||||
@Mock
|
||||
internal var mediaWikiApi: MediaWikiApi? = null
|
||||
@Mock
|
||||
internal var mediaClient: MediaClient? = null
|
||||
|
||||
@InjectMocks
|
||||
var reviewHelper: ReviewHelper? = null
|
||||
|
|
@ -74,7 +77,7 @@ class ReviewHelperTest {
|
|||
*/
|
||||
@Test
|
||||
fun getRandomMedia() {
|
||||
`when`(mediaWikiApi?.pageExists(ArgumentMatchers.anyString()))
|
||||
`when`(mediaClient?.checkPageExistsUsingTitle(ArgumentMatchers.anyString()))
|
||||
.thenReturn(Single.just(false))
|
||||
|
||||
val randomMedia = reviewHelper?.randomMedia?.blockingGet()
|
||||
|
|
@ -89,7 +92,7 @@ class ReviewHelperTest {
|
|||
*/
|
||||
@Test(expected = RuntimeException::class)
|
||||
fun getRandomMediaWithWithAllMediaNominatedForDeletion() {
|
||||
`when`(mediaWikiApi?.pageExists(ArgumentMatchers.anyString()))
|
||||
`when`(mediaClient?.checkPageExistsUsingTitle(ArgumentMatchers.anyString()))
|
||||
.thenReturn(Single.just(true))
|
||||
val media = reviewHelper?.randomMedia?.blockingGet()
|
||||
assertNull(media)
|
||||
|
|
@ -101,11 +104,11 @@ class ReviewHelperTest {
|
|||
*/
|
||||
@Test
|
||||
fun getRandomMediaWithWithOneMediaNominatedForDeletion() {
|
||||
`when`(mediaWikiApi?.pageExists("Commons:Deletion_requests/File:Test1.jpeg"))
|
||||
`when`(mediaClient?.checkPageExistsUsingTitle("Commons:Deletion_requests/File:Test1.jpeg"))
|
||||
.thenReturn(Single.just(true))
|
||||
`when`(mediaWikiApi?.pageExists("Commons:Deletion_requests/File:Test2.png"))
|
||||
`when`(mediaClient?.checkPageExistsUsingTitle("Commons:Deletion_requests/File:Test2.png"))
|
||||
.thenReturn(Single.just(false))
|
||||
`when`(mediaWikiApi?.pageExists("Commons:Deletion_requests/File:Test3.jpg"))
|
||||
`when`(mediaClient?.checkPageExistsUsingTitle("Commons:Deletion_requests/File:Test3.jpg"))
|
||||
.thenReturn(Single.just(true))
|
||||
|
||||
val media = reviewHelper?.randomMedia?.blockingGet()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue