Convert upload to kotlin (part 1) (#6024)

* Convert upload dagger module to kotlin

* Code cleanup and convert the upload contract to kotlin

* Code cleanup and convert CategoriesContract to kotlin

* Code cleanup and convert MediaLicenseContract to kotlin

* Code cleanup and convert UploadMediaDetailsContract to kotlin

* Code cleanup, fixed nullability and converted DepictsContract to kotlin

* Removed unused class

* Convert FileMetadataUtils to kotlin

* Convert EXIFReader to kotlin

* Convert FileUtils to kotlin

* Convert FileUtilsWrapper to kotlin

* Convert ImageProcessingService to kotlin

* Convert PageContentsCreator to kotlin

* Convert PendingUploadsPresenter and contract to Kotlin with some code-cleanup

* Convert ReadFBMD to kotlin

* Convert SimilarImageInterface to kotlin

* Removed unused classes

* Fix merge/rebase issue

---------

Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
Paul Hawke 2024-12-13 08:15:13 -06:00 committed by GitHub
parent cb007608d9
commit 2c8c441f25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 1595 additions and 1835 deletions

View file

@ -5,7 +5,6 @@ import android.content.Intent
import androidx.test.core.app.ApplicationProvider
import androidx.work.Configuration
import androidx.work.testing.WorkManagerTestInitHelper
import fr.free.nrw.commons.CommonsApplication
import fr.free.nrw.commons.OkHttpConnectionFactory
import fr.free.nrw.commons.R
import fr.free.nrw.commons.TestCommonsApplication
@ -75,7 +74,7 @@ class UploadActivityUnitTests {
@Test
@Throws(Exception::class)
fun testIsLoggedIn() {
activity.isLoggedIn
activity.isLoggedIn()
}
@Test
@ -139,7 +138,7 @@ class UploadActivityUnitTests {
@Test
@Throws(Exception::class)
fun testGetUploadableFiles() {
activity.uploadableFiles
activity.getUploadableFiles()
}
@Test

View file

@ -8,14 +8,13 @@ import com.nhaarman.mockitokotlin2.anyOrNull
import com.nhaarman.mockitokotlin2.argumentCaptor
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.times
import com.nhaarman.mockitokotlin2.whenever
import fr.free.nrw.commons.CommonsApplication.Companion.DEFAULT_EDIT_SUMMARY
import fr.free.nrw.commons.auth.csrf.CsrfTokenClient
import fr.free.nrw.commons.contributions.ChunkInfo
import fr.free.nrw.commons.contributions.Contribution
import fr.free.nrw.commons.contributions.ContributionDao
import fr.free.nrw.commons.upload.UploadClient.TimeProvider
import fr.free.nrw.commons.utils.TimeProvider
import fr.free.nrw.commons.wikidata.mwapi.MwException
import fr.free.nrw.commons.wikidata.mwapi.MwServiceError
import io.reactivex.Observable

View file

@ -61,7 +61,7 @@ class UploadPresenterTest {
uploadPresenter.onAttachView(view)
`when`(repository.buildContributions()).thenReturn(Observable.just(contribution))
uploadableFiles.add(uploadableFile)
`when`(view.uploadableFiles).thenReturn(uploadableFiles)
`when`(view.getUploadableFiles()).thenReturn(uploadableFiles)
`when`(uploadableFile.getFilePath()).thenReturn("data://test")
}
@ -71,9 +71,9 @@ class UploadPresenterTest {
@Ignore
@Test
fun handleSubmitTestUserLoggedIn() {
`when`(view.isLoggedIn).thenReturn(true)
`when`(view.isLoggedIn()).thenReturn(true)
uploadPresenter.handleSubmit()
verify(view).isLoggedIn
verify(view).isLoggedIn()
verify(view).showProgress(true)
verify(repository).buildContributions()
verify(repository).buildContributions()
@ -130,9 +130,9 @@ class UploadPresenterTest {
false,
),
).thenReturn(true)
`when`(view.isLoggedIn).thenReturn(true)
`when`(view.isLoggedIn()).thenReturn(true)
uploadPresenter.handleSubmit()
verify(view).isLoggedIn
verify(view).isLoggedIn()
verify(view).showProgress(true)
verify(repository).buildContributions()
verify(repository).buildContributions()
@ -144,9 +144,9 @@ class UploadPresenterTest {
@Ignore
@Test
fun handleSubmitTestUserNotLoggedIn() {
`when`(view.isLoggedIn).thenReturn(false)
`when`(view.isLoggedIn()).thenReturn(false)
uploadPresenter.handleSubmit()
verify(view).isLoggedIn
verify(view).isLoggedIn()
verify(view).askUserToLogIn()
}

View file

@ -6,7 +6,6 @@ import android.view.LayoutInflater
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import androidx.test.core.app.ApplicationProvider
import com.nhaarman.mockitokotlin2.times
import fr.free.nrw.commons.Media
import fr.free.nrw.commons.OkHttpConnectionFactory
import fr.free.nrw.commons.R
@ -184,14 +183,14 @@ class UploadCategoriesFragmentUnitTests {
@Throws(Exception::class)
fun testGetExistingCategories() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.existingCategories
fragment.getExistingCategories()
}
@Test
@Throws(Exception::class)
fun testGetFragmentContext() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fragment.fragmentContext
fragment.getFragmentContext()
}
@Test

View file

@ -258,7 +258,7 @@ class DepictsFragmentUnitTests {
@Test
@Throws(Exception::class)
fun testGetFragmentContext() {
fragment.fragmentContext
fragment.getFragmentContext()
}
@Test