mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Convert wikidata/mwapi to kotlin (part 4) (#6010)
* Convert ImageDetails to kotlin * Convert MwException/MwServiceError to kotlin * Convert ListUserResponse to kotlin * Convert MwPostResponse to kotlin * Convert MwQueryResponse to kotlin * Convert MwQueryResult to kotlin * Convert MwQueryPage to kotlin --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
56ada36b83
commit
73311970c5
28 changed files with 474 additions and 615 deletions
|
|
@ -139,7 +139,7 @@ class ReviewControllerTest {
|
|||
@Test
|
||||
fun testSendThanks() {
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
whenever(firstRevision.revisionId).thenReturn(1)
|
||||
whenever(firstRevision.revisionId()).thenReturn(1)
|
||||
Whitebox.setInternalState(controller, "firstRevision", firstRevision)
|
||||
controller.sendThanks(activity)
|
||||
assertEquals(
|
||||
|
|
|
|||
|
|
@ -95,11 +95,11 @@ class ReviewHelperTest {
|
|||
@Test
|
||||
fun getFirstRevisionOfFile() {
|
||||
val rev1 = mock<MwQueryPage.Revision>()
|
||||
whenever(rev1.user).thenReturn("TestUser")
|
||||
whenever(rev1.revisionId).thenReturn(1L)
|
||||
whenever(rev1.user()).thenReturn("TestUser")
|
||||
whenever(rev1.revisionId()).thenReturn(1L)
|
||||
val rev2 = mock<MwQueryPage.Revision>()
|
||||
whenever(rev2.user).thenReturn("TestUser")
|
||||
whenever(rev2.revisionId).thenReturn(2L)
|
||||
whenever(rev2.user()).thenReturn("TestUser")
|
||||
whenever(rev2.revisionId()).thenReturn(2L)
|
||||
|
||||
val page = setupMedia("Test.jpg", rev1, rev2)
|
||||
whenever(mwQueryResult.firstPage()).thenReturn(page)
|
||||
|
|
@ -107,7 +107,7 @@ class ReviewHelperTest {
|
|||
|
||||
val firstRevisionOfFile = reviewHelper.getFirstRevisionOfFile("Test.jpg").blockingFirst()
|
||||
|
||||
assertEquals(1, firstRevisionOfFile.revisionId)
|
||||
assertEquals(1, firstRevisionOfFile.revisionId())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package fr.free.nrw.commons.wikidata.mwapi
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class MwQueryPageTest {
|
||||
private val didymUsage = MwQueryPage.FileUsage().apply {
|
||||
setTitle("User:Didym/Mobile upload")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkWhetherFileIsUsedInWikis_nullGlobalUsages() {
|
||||
assertFalse(checkWhetherFileIsUsedInWikis(null, null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkWhetherFileIsUsedInWikis_emptyGlobalUsages() {
|
||||
assertFalse(checkWhetherFileIsUsedInWikis(emptyList(), null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkWhetherFileIsUsedInWikis_emptyFileUsage() {
|
||||
assertFalse(checkWhetherFileIsUsedInWikis(emptyList(), emptyList()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkWhetherFileIsUsedInWikis_singleGlobalUsages() {
|
||||
assertTrue(checkWhetherFileIsUsedInWikis(listOf(MwQueryPage.GlobalUsage()), null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkWhetherFileIsUsedInWikis_singleFileUsageContainsDidym() {
|
||||
assertFalse(checkWhetherFileIsUsedInWikis(null, listOf(didymUsage)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkWhetherFileIsUsedInWikis_didymIgnoredInList() {
|
||||
assertTrue(
|
||||
checkWhetherFileIsUsedInWikis(
|
||||
null, listOf(
|
||||
didymUsage, MwQueryPage.FileUsage().apply { setTitle("somewhere else") }
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue