From 34d458fac51b8d3d51b57ba735744ab5e814433d Mon Sep 17 00:00:00 2001 From: davigonz Date: Tue, 11 Jun 2019 15:48:22 +0200 Subject: [PATCH] Apply CR changes --- .../shares/ui/usecases/CreatePublicShareTest.kt | 6 +----- .../shares/ui/usecases/DeletePublicShareTest.kt | 4 ++-- .../ui/usecases/EditPublicShareFolderTest.kt | 8 ++++---- .../shares/ui/usecases/EditPublicShareTest.kt | 10 +++++----- .../android/shares/repository/OCShareRepository.kt | 12 ++++++------ .../android/shares/repository/ShareRepository.kt | 6 +++--- .../android/shares/viewmodel/OCShareViewModel.kt | 6 +++--- .../shares/repository/OCShareRepositoryTest.kt | 14 +++++++------- .../shares/viewmodel/OCShareViewModelTest.kt | 12 ++++++------ 9 files changed, 37 insertions(+), 41 deletions(-) diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/CreatePublicShareTest.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/CreatePublicShareTest.kt index 4594ace7a62..d3640587278 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/CreatePublicShareTest.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/CreatePublicShareTest.kt @@ -28,7 +28,6 @@ import android.view.View import androidx.lifecycle.MutableLiveData import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.IdlingPolicies import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.doesNotExist @@ -67,7 +66,6 @@ import org.koin.dsl.module import org.mockito.Mockito.`when` import org.mockito.Mockito.mock import org.mockito.Mockito.spy -import java.util.concurrent.TimeUnit class CreatePublicShareTest { @Rule @@ -358,7 +356,7 @@ class CreatePublicShareTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) @@ -371,9 +369,7 @@ class CreatePublicShareTest { activityRule.activity.supportFragmentManager.findFragmentByTag(ShareActivity.TAG_PUBLIC_SHARE_DIALOG_FRAGMENT), View.VISIBLE ) - IdlingPolicies.setIdlingResourceTimeout(1, TimeUnit.HOURS); IdlingRegistry.getInstance().register(idlingResource) - return idlingResource } diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/DeletePublicShareTest.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/DeletePublicShareTest.kt index 585a46a57e8..3a3f47c9dc7 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/DeletePublicShareTest.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/DeletePublicShareTest.kt @@ -195,7 +195,7 @@ class DeletePublicShareTest { `when`( ocShareViewModel.deletePublicShare(ArgumentMatchers.anyLong()) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) @@ -224,7 +224,7 @@ class DeletePublicShareTest { `when`( ocShareViewModel.deletePublicShare(ArgumentMatchers.anyLong()) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareFolderTest.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareFolderTest.kt index 4be2ddcac27..cf16f667163 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareFolderTest.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareFolderTest.kt @@ -229,7 +229,7 @@ class EditPublicShareFolderTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) @@ -273,7 +273,7 @@ class EditPublicShareFolderTest { true ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) @@ -318,7 +318,7 @@ class EditPublicShareFolderTest { true ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) @@ -363,7 +363,7 @@ class EditPublicShareFolderTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) diff --git a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareTest.kt b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareTest.kt index 1413b48e84c..e2bb155411f 100644 --- a/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareTest.kt +++ b/owncloudApp/src/androidTest/java/com/owncloud/android/shares/ui/usecases/EditPublicShareTest.kt @@ -231,7 +231,7 @@ class EditPublicShareTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) @@ -276,7 +276,7 @@ class EditPublicShareTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) @@ -324,7 +324,7 @@ class EditPublicShareTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) @@ -374,7 +374,7 @@ class EditPublicShareTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) @@ -427,7 +427,7 @@ class EditPublicShareTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { postValue(Resource.success()) } ) diff --git a/owncloudApp/src/main/java/com/owncloud/android/shares/repository/OCShareRepository.kt b/owncloudApp/src/main/java/com/owncloud/android/shares/repository/OCShareRepository.kt index b73a839390c..cc98a65119a 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/shares/repository/OCShareRepository.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/shares/repository/OCShareRepository.kt @@ -71,8 +71,8 @@ class OCShareRepository( password: String, expirationTimeInMillis: Long, publicUpload: Boolean - ): LiveData> { - val result = MutableLiveData>() + ): LiveData> { + val result = MutableLiveData>() result.postValue(Resource.loading()) appExecutors.networkIO().execute() { @@ -114,8 +114,8 @@ class OCShareRepository( expirationDateInMillis: Long, permissions: Int, publicUpload: Boolean - ): LiveData> { - val result = MutableLiveData>() + ): LiveData> { + val result = MutableLiveData>() result.postValue(Resource.loading()) appExecutors.networkIO().execute() { @@ -150,8 +150,8 @@ class OCShareRepository( override fun deletePublicShare( remoteId: Long - ): LiveData> { - val result = MutableLiveData>() + ): LiveData> { + val result = MutableLiveData>() result.postValue(Resource.loading()) diff --git a/owncloudApp/src/main/java/com/owncloud/android/shares/repository/ShareRepository.kt b/owncloudApp/src/main/java/com/owncloud/android/shares/repository/ShareRepository.kt index fff235e11c2..16485c15d02 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/shares/repository/ShareRepository.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/shares/repository/ShareRepository.kt @@ -32,7 +32,7 @@ interface ShareRepository { password: String, expirationTimeInMillis: Long, publicUpload: Boolean - ): LiveData> + ): LiveData> fun updatePublicShareForFile( remoteId: Long, @@ -41,9 +41,9 @@ interface ShareRepository { expirationDateInMillis: Long, permissions: Int, publicUpload: Boolean - ): LiveData> + ): LiveData> fun deletePublicShare( remoteId: Long - ): LiveData> + ): LiveData> } diff --git a/owncloudApp/src/main/java/com/owncloud/android/shares/viewmodel/OCShareViewModel.kt b/owncloudApp/src/main/java/com/owncloud/android/shares/viewmodel/OCShareViewModel.kt index 7d846a6d3ca..b8c68a4953d 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/shares/viewmodel/OCShareViewModel.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/shares/viewmodel/OCShareViewModel.kt @@ -67,7 +67,7 @@ class OCShareViewModel( password: String, expirationTimeInMillis: Long, publicUpload: Boolean - ): LiveData> = shareRepository.insertPublicShareForFile( + ): LiveData> = shareRepository.insertPublicShareForFile( permissions, name, password, expirationTimeInMillis, publicUpload ) @@ -78,11 +78,11 @@ class OCShareViewModel( expirationDateInMillis: Long, permissions: Int, publicUpload: Boolean - ): LiveData> = shareRepository.updatePublicShareForFile( + ): LiveData> = shareRepository.updatePublicShareForFile( remoteId, name, password, expirationDateInMillis, permissions, publicUpload ) fun deletePublicShare( remoteId: Long - ): LiveData> = shareRepository.deletePublicShare(remoteId) + ): LiveData> = shareRepository.deletePublicShare(remoteId) } diff --git a/owncloudApp/src/test/java/com/owncloud/android/shares/repository/OCShareRepositoryTest.kt b/owncloudApp/src/test/java/com/owncloud/android/shares/repository/OCShareRepositoryTest.kt index 6635000ff87..f6aaacaa84f 100644 --- a/owncloudApp/src/test/java/com/owncloud/android/shares/repository/OCShareRepositoryTest.kt +++ b/owncloudApp/src/test/java/com/owncloud/android/shares/repository/OCShareRepositoryTest.kt @@ -189,7 +189,7 @@ class OCShareRepositoryTest { ) val data = insertShare(localData, remoteOperationResult) - val observer = mock>>() + val observer = mock>>() data.observeForever(observer) // Get public shares from database is called once, when creating the repository @@ -231,7 +231,7 @@ class OCShareRepositoryTest { // Retrieving public shares from server... // Observe changes in database livedata when there's an error from server - val observer = mock>>() + val observer = mock>>() data.observeForever(observer) verify(observer).onChanged( @@ -252,7 +252,7 @@ class OCShareRepositoryTest { val data = updateShare(localData, remoteOperationResult) - val observer = mock>>() + val observer = mock>>() data.observeForever(observer) // Get public shares from database is called once, when creating the repository @@ -279,7 +279,7 @@ class OCShareRepositoryTest { val data = deleteShare(localData, remoteOperationResult) - val observer = mock>>() + val observer = mock>>() data.observeForever(observer) // Get public shares from database is called once, when creating the repository @@ -329,7 +329,7 @@ class OCShareRepositoryTest { private fun insertShare( localData: MutableLiveData>, remoteOperationResult: RemoteOperationResult - ): LiveData> { + ): LiveData> { val ocShareRepository = createRepositoryWithData(localData, remoteOperationResult) return ocShareRepository.insertPublicShareForFile( @@ -344,7 +344,7 @@ class OCShareRepositoryTest { private fun updateShare( localData: MutableLiveData>, remoteOperationResult: RemoteOperationResult - ): LiveData> { + ): LiveData> { val ocShareRepository = createRepositoryWithData(localData, remoteOperationResult) return ocShareRepository.updatePublicShareForFile( @@ -360,7 +360,7 @@ class OCShareRepositoryTest { private fun deleteShare( localData: MutableLiveData>, remoteOperationResult: RemoteOperationResult - ): LiveData> { + ): LiveData> { val ocShareRepository = createRepositoryWithData(localData, remoteOperationResult) return ocShareRepository.deletePublicShare( 1 diff --git a/owncloudApp/src/test/java/com/owncloud/android/shares/viewmodel/OCShareViewModelTest.kt b/owncloudApp/src/test/java/com/owncloud/android/shares/viewmodel/OCShareViewModelTest.kt index d1f6f1f1615..a7cd4a31208 100644 --- a/owncloudApp/src/test/java/com/owncloud/android/shares/viewmodel/OCShareViewModelTest.kt +++ b/owncloudApp/src/test/java/com/owncloud/android/shares/viewmodel/OCShareViewModelTest.kt @@ -90,7 +90,7 @@ class OCShareViewModelTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { value = Resource.success() } ) @@ -98,7 +98,7 @@ class OCShareViewModelTest { // Viewmodel that will ask ocShareRepository for shares val ocShareViewModel = createOCShareViewModel(ocShareRepository) - val resource: Resource? = ocShareViewModel.insertPublicShareForFile( + val resource: Resource? = ocShareViewModel.insertPublicShareForFile( 1, "Photos 2 link", "1234", @@ -123,7 +123,7 @@ class OCShareViewModelTest { false ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { value = Resource.success() } ) @@ -131,7 +131,7 @@ class OCShareViewModelTest { // Viewmodel that will ask ocShareRepository for shares val ocShareViewModel = createOCShareViewModel(ocShareRepository) - val resource: Resource? = ocShareViewModel.updatePublicShareForFile( + val resource: Resource? = ocShareViewModel.updatePublicShareForFile( 1, "Photos 1 link", "123456", @@ -152,7 +152,7 @@ class OCShareViewModelTest { 3 ) ).thenReturn( - MutableLiveData>().apply { + MutableLiveData>().apply { value = Resource.success() } ) @@ -160,7 +160,7 @@ class OCShareViewModelTest { // Viewmodel that will ask ocShareRepository for shares val ocShareViewModel = createOCShareViewModel(ocShareRepository) - val resource: Resource? = ocShareViewModel.deletePublicShare( + val resource: Resource? = ocShareViewModel.deletePublicShare( 3 ).value