Convert upload to kotlin (part 2) (#6069)

* Convert UploadCategoriesFragment to kotlin

* Convert DepictsFragment to kotlin

* Convert MediaLicensePresenter to kotlin

* Convert MediaLicenseFragment to kotlin

* Converted SimilarImageDialogFragment to kotlin

* Convert ThumbnailsAdapter to kotlin

* Convert UploadPresenter to kotlin

* Convert UploadBaseFragment to kotlin

* Convert UploadMediaDetailInputFilter to kotlin

* Convert UploadItem to kotlin

* Convert UploadController to kotlin

* Fix nullability of the UploadItem
This commit is contained in:
Paul Hawke 2024-12-24 01:11:46 -06:00 committed by GitHub
parent 369e79be5e
commit a9058d129e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 1830 additions and 2100 deletions

View file

@ -84,10 +84,10 @@ class CategoriesPresenterTest {
)
val nonEmptyCaptionUploadItem = mock<UploadItem>()
whenever(nonEmptyCaptionUploadItem.uploadMediaDetails)
.thenReturn(listOf(UploadMediaDetail(captionText = "nonEmpty")))
.thenReturn(mutableListOf(UploadMediaDetail(captionText = "nonEmpty")))
val emptyCaptionUploadItem = mock<UploadItem>()
whenever(emptyCaptionUploadItem.uploadMediaDetails)
.thenReturn(listOf(UploadMediaDetail(captionText = "")))
.thenReturn(mutableListOf(UploadMediaDetail(captionText = "")))
whenever(repository.getUploads()).thenReturn(
listOf(
nonEmptyCaptionUploadItem,

View file

@ -64,7 +64,7 @@ class ImageProcessingServiceTest {
`when`(uploadItem.uploadMediaDetails).thenReturn(mockTitle as MutableList<UploadMediaDetail>?)
`when`(uploadItem.place).thenReturn(mockPlace)
`when`(uploadItem.fileName).thenReturn("File:jpg")
`when`(uploadItem.filename).thenReturn("File:jpg")
`when`(fileUtilsWrapper!!.getFileInputStream(ArgumentMatchers.anyString()))
.thenReturn(mock(FileInputStream::class.java))

View file

@ -137,7 +137,7 @@ class UploadMediaPresenterTest {
whenever(uploadItem.imageQuality).thenReturn(0)
whenever(uploadItem.gpsCoords)
.thenReturn(imageCoordinates)
whenever(uploadItem.gpsCoords.decimalCoords)
whenever(uploadItem.gpsCoords?.decimalCoords)
.thenReturn("imageCoordinates")
uploadMediaPresenter.getImageQuality(0, location, mockActivity)
verify(view).showProgress(true)
@ -155,7 +155,7 @@ class UploadMediaPresenterTest {
whenever(uploadItem.imageQuality).thenReturn(0)
whenever(uploadItem.gpsCoords)
.thenReturn(imageCoordinates)
whenever(uploadItem.gpsCoords.decimalCoords)
whenever(uploadItem.gpsCoords?.decimalCoords)
.thenReturn(null)
uploadMediaPresenter.getImageQuality(0, location, mockActivity)
testScheduler.triggerActions()
@ -195,7 +195,7 @@ class UploadMediaPresenterTest {
uploadMediaDetail.languageCode = "en"
val uploadMediaDetailList: ArrayList<UploadMediaDetail> = ArrayList()
uploadMediaDetailList.add(uploadMediaDetail)
uploadItem.setMediaDetails(uploadMediaDetailList)
uploadItem.uploadMediaDetails = uploadMediaDetailList
Mockito.`when`(repository.getImageQuality(uploadItem, location)).then {
verify(view).showProgress(true)
testScheduler.triggerActions()
@ -211,7 +211,7 @@ class UploadMediaPresenterTest {
uploadMediaDetail.languageCode = "en"
uploadMediaDetail.captionText = "added caption"
uploadMediaDetail.languageCode = "eo"
uploadItem.setMediaDetails(Collections.singletonList(uploadMediaDetail))
uploadItem.uploadMediaDetails = Collections.singletonList(uploadMediaDetail)
Mockito.`when`(repository.getImageQuality(uploadItem, location)).then {
verify(view).showProgress(true)
testScheduler.triggerActions()
@ -228,7 +228,7 @@ class UploadMediaPresenterTest {
whenever(repository.getUploads()).thenReturn(listOf(uploadItem))
whenever(repository.getUploadItem(ArgumentMatchers.anyInt()))
.thenReturn(uploadItem)
whenever(uploadItem.uploadMediaDetails).thenReturn(listOf())
whenever(uploadItem.uploadMediaDetails).thenReturn(mutableListOf())
uploadMediaPresenter.fetchTitleAndDescription(0)
verify(view).updateMediaDetails(ArgumentMatchers.any())

View file

@ -83,7 +83,7 @@ class UploadPresenterTest {
@Test
fun handleSubmitImagesNoLocationWithConsecutiveNoLocationUploads() {
`when`(imageCoords.imageCoordsExists).thenReturn(false)
`when`(uploadItem.getGpsCoords()).thenReturn(imageCoords)
`when`(uploadItem.gpsCoords).thenReturn(imageCoords)
`when`(repository.getUploads()).thenReturn(uploadableItems)
uploadableItems.add(uploadItem)
@ -111,7 +111,7 @@ class UploadPresenterTest {
defaultKvStore.getInt(UploadPresenter.COUNTER_OF_CONSECUTIVE_UPLOADS_WITHOUT_COORDINATES, 0),
).thenReturn(UploadPresenter.CONSECUTIVE_UPLOADS_WITHOUT_COORDINATES_REMINDER_THRESHOLD)
`when`(imageCoords.imageCoordsExists).thenReturn(true)
`when`(uploadItem.getGpsCoords()).thenReturn(imageCoords)
`when`(uploadItem.gpsCoords).thenReturn(imageCoords)
`when`(repository.getUploads()).thenReturn(uploadableItems)
uploadableItems.add(uploadItem)
uploadPresenter.handleSubmit()

View file

@ -62,6 +62,7 @@ class UploadCategoriesFragmentUnitTests {
OkHttpConnectionFactory.CLIENT = createTestClient()
val activity = Robolectric.buildActivity(UploadActivity::class.java).create().get()
fragment = UploadCategoriesFragment()
fragment.callback = callback
fragmentManager = activity.supportFragmentManager
val fragmentTransaction: FragmentTransaction = fragmentManager.beginTransaction()
fragmentTransaction.add(fragment, null)

View file

@ -481,7 +481,7 @@ class UploadMediaDetailFragmentUnitTest {
`when`(imageCoordinates.zoomLevel).thenReturn(14.0)
`when`(defaultKvStore.getString(LAST_ZOOM)).thenReturn(null)
fragment.showExternalMap(uploadItem)
Mockito.verify(uploadItem.gpsCoords, Mockito.times(1)).zoomLevel
Mockito.verify(uploadItem.gpsCoords, Mockito.times(1))?.zoomLevel
val shadowActivity: ShadowActivity = shadowOf(activity)
val startedIntent = shadowActivity.nextStartedActivity
val shadowIntent: ShadowIntent = shadowOf(startedIntent)