Skip to content

Commit a3de551

Browse files
fix tests
Signed-off-by: parneet-guraya <[email protected]>
1 parent 865949f commit a3de551

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/src/test/kotlin/fr/free/nrw/commons/upload/ImageProcessingServiceTest.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package fr.free.nrw.commons.upload
22

3+
import android.content.ContentResolver
4+
import android.content.Context
35
import android.net.Uri
6+
import androidx.compose.material3.InputChip
47
import fr.free.nrw.commons.location.LatLng
58
import fr.free.nrw.commons.media.MediaClient
69
import fr.free.nrw.commons.nearby.Place
@@ -18,6 +21,7 @@ import org.mockito.Mockito.mock
1821
import org.mockito.Mockito.`when`
1922
import org.mockito.MockitoAnnotations
2023
import java.io.FileInputStream
24+
import java.io.InputStream
2125

2226
class ImageProcessingServiceTest {
2327
@Mock
@@ -38,6 +42,9 @@ class ImageProcessingServiceTest {
3842
@Mock
3943
internal var location: LatLng? = null
4044

45+
@Mock
46+
internal lateinit var appContext: Context
47+
4148
@InjectMocks
4249
var imageProcessingService: ImageProcessingService? = null
4350

@@ -49,8 +56,10 @@ class ImageProcessingServiceTest {
4956
fun setUp() {
5057
MockitoAnnotations.openMocks(this)
5158
val mediaUri = mock(Uri::class.java)
59+
val contentUri = mock(Uri::class.java)
5260
val mockPlace = mock(Place::class.java)
5361
val mockTitle = mock(List::class.java)
62+
val contentResolver = mock(ContentResolver::class.java)
5463

5564
`when`(mockPlace.wikiDataEntityId).thenReturn("Q1")
5665
`when`(mockPlace.getLocation()).thenReturn(mock(LatLng::class.java))
@@ -59,6 +68,8 @@ class ImageProcessingServiceTest {
5968
`when`(mockTitle.isSet).thenReturn(true)*/
6069

6170
`when`(uploadItem.mediaUri).thenReturn(mediaUri)
71+
`when`(uploadItem.contentUri).thenReturn(contentUri)
72+
`when`(appContext.contentResolver).thenReturn(contentResolver)
6273
`when`(uploadItem.imageQuality).thenReturn(ImageUtils.IMAGE_WAIT)
6374

6475
`when`(uploadItem.uploadMediaDetails).thenReturn(mockTitle as MutableList<UploadMediaDetail>?)
@@ -68,7 +79,9 @@ class ImageProcessingServiceTest {
6879

6980
`when`(fileUtilsWrapper!!.getFileInputStream(ArgumentMatchers.anyString()))
7081
.thenReturn(mock(FileInputStream::class.java))
71-
`when`(fileUtilsWrapper!!.getSHA1(any(FileInputStream::class.java)))
82+
`when`(appContext.contentResolver.openInputStream(ArgumentMatchers.any()))
83+
.thenReturn(mock(InputStream::class.java))
84+
`when`(fileUtilsWrapper!!.getSHA1(any(InputStream::class.java)))
7285
.thenReturn("fileSha")
7386

7487
`when`(fileUtilsWrapper!!.getGeolocationOfFile(ArgumentMatchers.anyString(), any(LatLng::class.java)))

0 commit comments

Comments
 (0)