mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
fix tests
Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
parent
865949f260
commit
b3d2fe4f08
1 changed files with 13 additions and 1 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package fr.free.nrw.commons.upload
|
package fr.free.nrw.commons.upload
|
||||||
|
|
||||||
|
import android.content.ContentResolver
|
||||||
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import fr.free.nrw.commons.location.LatLng
|
import fr.free.nrw.commons.location.LatLng
|
||||||
import fr.free.nrw.commons.media.MediaClient
|
import fr.free.nrw.commons.media.MediaClient
|
||||||
|
|
@ -18,6 +20,7 @@ import org.mockito.Mockito.mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
class ImageProcessingServiceTest {
|
class ImageProcessingServiceTest {
|
||||||
@Mock
|
@Mock
|
||||||
|
|
@ -38,6 +41,9 @@ class ImageProcessingServiceTest {
|
||||||
@Mock
|
@Mock
|
||||||
internal var location: LatLng? = null
|
internal var location: LatLng? = null
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
internal lateinit var appContext: Context
|
||||||
|
|
||||||
@InjectMocks
|
@InjectMocks
|
||||||
var imageProcessingService: ImageProcessingService? = null
|
var imageProcessingService: ImageProcessingService? = null
|
||||||
|
|
||||||
|
|
@ -49,8 +55,10 @@ class ImageProcessingServiceTest {
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
val mediaUri = mock(Uri::class.java)
|
val mediaUri = mock(Uri::class.java)
|
||||||
|
val contentUri = mock(Uri::class.java)
|
||||||
val mockPlace = mock(Place::class.java)
|
val mockPlace = mock(Place::class.java)
|
||||||
val mockTitle = mock(List::class.java)
|
val mockTitle = mock(List::class.java)
|
||||||
|
val contentResolver = mock(ContentResolver::class.java)
|
||||||
|
|
||||||
`when`(mockPlace.wikiDataEntityId).thenReturn("Q1")
|
`when`(mockPlace.wikiDataEntityId).thenReturn("Q1")
|
||||||
`when`(mockPlace.getLocation()).thenReturn(mock(LatLng::class.java))
|
`when`(mockPlace.getLocation()).thenReturn(mock(LatLng::class.java))
|
||||||
|
|
@ -59,6 +67,8 @@ class ImageProcessingServiceTest {
|
||||||
`when`(mockTitle.isSet).thenReturn(true)*/
|
`when`(mockTitle.isSet).thenReturn(true)*/
|
||||||
|
|
||||||
`when`(uploadItem.mediaUri).thenReturn(mediaUri)
|
`when`(uploadItem.mediaUri).thenReturn(mediaUri)
|
||||||
|
`when`(uploadItem.contentUri).thenReturn(contentUri)
|
||||||
|
`when`(appContext.contentResolver).thenReturn(contentResolver)
|
||||||
`when`(uploadItem.imageQuality).thenReturn(ImageUtils.IMAGE_WAIT)
|
`when`(uploadItem.imageQuality).thenReturn(ImageUtils.IMAGE_WAIT)
|
||||||
|
|
||||||
`when`(uploadItem.uploadMediaDetails).thenReturn(mockTitle as MutableList<UploadMediaDetail>?)
|
`when`(uploadItem.uploadMediaDetails).thenReturn(mockTitle as MutableList<UploadMediaDetail>?)
|
||||||
|
|
@ -68,7 +78,9 @@ class ImageProcessingServiceTest {
|
||||||
|
|
||||||
`when`(fileUtilsWrapper!!.getFileInputStream(ArgumentMatchers.anyString()))
|
`when`(fileUtilsWrapper!!.getFileInputStream(ArgumentMatchers.anyString()))
|
||||||
.thenReturn(mock(FileInputStream::class.java))
|
.thenReturn(mock(FileInputStream::class.java))
|
||||||
`when`(fileUtilsWrapper!!.getSHA1(any(FileInputStream::class.java)))
|
`when`(appContext.contentResolver.openInputStream(ArgumentMatchers.any()))
|
||||||
|
.thenReturn(mock(InputStream::class.java))
|
||||||
|
`when`(fileUtilsWrapper!!.getSHA1(any(InputStream::class.java)))
|
||||||
.thenReturn("fileSha")
|
.thenReturn("fileSha")
|
||||||
|
|
||||||
`when`(fileUtilsWrapper!!.getGeolocationOfFile(ArgumentMatchers.anyString(), any(LatLng::class.java)))
|
`when`(fileUtilsWrapper!!.getGeolocationOfFile(ArgumentMatchers.anyString(), any(LatLng::class.java)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue