mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 05:43:55 +01:00
Update master with backend overhaul branch (#2829)
* Beginnings of integration with Wikipedia client library. (#2642) * Remove remaining unnecessary API version check. * Roll up sleeves. * Add and integrate the beginnings of app adapter. * Remove vestigial event logging logic. Event logging is no longer used in this app. * Beginnings: remove StringUtils and associated redundancies. * Remove redundant capitalize() method. * Remove redundant urlEncode() method. * Remove redundant (and incomplete) language lists. * Remove redundant usages of SimpleDateFormat. * Remove redundant json type adapter. * Remove redundant MW error model classes. * Rip out redundant MW model classes. * Pass SessionManager into AppAdapter instead of injecting. * Wire up more of the AppAdapter. * Remove redundant Gson initialization and type adapters. * Rip out PageTitle. This was being used in some slightly incorrect/unexpected ways. * Don't need static WikiSite. * Bump data client library version * Bump library version and fix build * Fix tests * Fix build * Fix media of the day * With fixes in recently modified APIs
This commit is contained in:
parent
76e5a30fb5
commit
dcbf076965
76 changed files with 424 additions and 2122 deletions
|
|
@ -1,10 +1,8 @@
|
|||
package fr.free.nrw.commons.review
|
||||
|
||||
import fr.free.nrw.commons.Media
|
||||
import fr.free.nrw.commons.media.model.MwQueryPage
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi
|
||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
|
||||
import fr.free.nrw.commons.mwapi.model.RecentChange
|
||||
import io.reactivex.Single
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
|
|
@ -15,6 +13,8 @@ import org.mockito.Mock
|
|||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.wikipedia.dataclient.mwapi.MwQueryPage
|
||||
import org.wikipedia.dataclient.mwapi.RecentChange
|
||||
|
||||
/**
|
||||
* Test class for ReviewHelper
|
||||
|
|
@ -43,10 +43,11 @@ class ReviewHelperTest {
|
|||
*/
|
||||
@Test
|
||||
fun getRandomMedia() {
|
||||
val recentChange = getMockRecentChange("test", "File:Test1.jpeg", 0)
|
||||
val recentChange1 = getMockRecentChange("test", "File:Test2.png", 0)
|
||||
val recentChange2 = getMockRecentChange("test", "File:Test3.jpg", 0)
|
||||
`when`(okHttpJsonApiClient?.recentFileChanges)
|
||||
.thenReturn(Single.just(listOf(RecentChange("test", "File:Test1.jpeg", "0"),
|
||||
RecentChange("test", "File:Test2.png", "0"),
|
||||
RecentChange("test", "File:Test3.jpg", "0"))))
|
||||
.thenReturn(Single.just(listOf(recentChange, recentChange1, recentChange2)))
|
||||
|
||||
`when`(mediaWikiApi?.pageExists(ArgumentMatchers.anyString()))
|
||||
.thenReturn(Single.just(true))
|
||||
|
|
@ -55,6 +56,14 @@ class ReviewHelperTest {
|
|||
assertTrue(randomMedia is Media)
|
||||
}
|
||||
|
||||
fun getMockRecentChange(type: String, title: String, oldRevisionId: Long): RecentChange {
|
||||
val recentChange = mock(RecentChange::class.java)
|
||||
`when`(recentChange!!.type).thenReturn(type)
|
||||
`when`(recentChange.title).thenReturn(title)
|
||||
`when`(recentChange.oldRevisionId).thenReturn(oldRevisionId)
|
||||
return recentChange
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getting first revision of file
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue