Skip to content

Commit

Permalink
Apply CR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
davigonz committed Jun 11, 2019
1 parent 420413a commit 34d458f
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -358,7 +356,7 @@ class CreatePublicShareTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class DeletePublicShareTest {
`when`(
ocShareViewModel.deletePublicShare(ArgumentMatchers.anyLong())
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down Expand Up @@ -224,7 +224,7 @@ class DeletePublicShareTest {
`when`(
ocShareViewModel.deletePublicShare(ArgumentMatchers.anyLong())
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class EditPublicShareFolderTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down Expand Up @@ -273,7 +273,7 @@ class EditPublicShareFolderTest {
true
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down Expand Up @@ -318,7 +318,7 @@ class EditPublicShareFolderTest {
true
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down Expand Up @@ -363,7 +363,7 @@ class EditPublicShareFolderTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class EditPublicShareTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down Expand Up @@ -276,7 +276,7 @@ class EditPublicShareTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down Expand Up @@ -324,7 +324,7 @@ class EditPublicShareTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down Expand Up @@ -374,7 +374,7 @@ class EditPublicShareTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down Expand Up @@ -427,7 +427,7 @@ class EditPublicShareTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
postValue(Resource.success())
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class OCShareRepository(
password: String,
expirationTimeInMillis: Long,
publicUpload: Boolean
): LiveData<Resource<Void>> {
val result = MutableLiveData<Resource<Void>>()
): LiveData<Resource<Unit>> {
val result = MutableLiveData<Resource<Unit>>()
result.postValue(Resource.loading())

appExecutors.networkIO().execute() {
Expand Down Expand Up @@ -114,8 +114,8 @@ class OCShareRepository(
expirationDateInMillis: Long,
permissions: Int,
publicUpload: Boolean
): LiveData<Resource<Void>> {
val result = MutableLiveData<Resource<Void>>()
): LiveData<Resource<Unit>> {
val result = MutableLiveData<Resource<Unit>>()
result.postValue(Resource.loading())

appExecutors.networkIO().execute() {
Expand Down Expand Up @@ -150,8 +150,8 @@ class OCShareRepository(

override fun deletePublicShare(
remoteId: Long
): LiveData<Resource<Void>> {
val result = MutableLiveData<Resource<Void>>()
): LiveData<Resource<Unit>> {
val result = MutableLiveData<Resource<Unit>>()

result.postValue(Resource.loading())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface ShareRepository {
password: String,
expirationTimeInMillis: Long,
publicUpload: Boolean
): LiveData<Resource<Void>>
): LiveData<Resource<Unit>>

fun updatePublicShareForFile(
remoteId: Long,
Expand All @@ -41,9 +41,9 @@ interface ShareRepository {
expirationDateInMillis: Long,
permissions: Int,
publicUpload: Boolean
): LiveData<Resource<Void>>
): LiveData<Resource<Unit>>

fun deletePublicShare(
remoteId: Long
): LiveData<Resource<Void>>
): LiveData<Resource<Unit>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class OCShareViewModel(
password: String,
expirationTimeInMillis: Long,
publicUpload: Boolean
): LiveData<Resource<Void>> = shareRepository.insertPublicShareForFile(
): LiveData<Resource<Unit>> = shareRepository.insertPublicShareForFile(
permissions, name, password, expirationTimeInMillis, publicUpload
)

Expand All @@ -78,11 +78,11 @@ class OCShareViewModel(
expirationDateInMillis: Long,
permissions: Int,
publicUpload: Boolean
): LiveData<Resource<Void>> = shareRepository.updatePublicShareForFile(
): LiveData<Resource<Unit>> = shareRepository.updatePublicShareForFile(
remoteId, name, password, expirationDateInMillis, permissions, publicUpload
)

fun deletePublicShare(
remoteId: Long
): LiveData<Resource<Void>> = shareRepository.deletePublicShare(remoteId)
): LiveData<Resource<Unit>> = shareRepository.deletePublicShare(remoteId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class OCShareRepositoryTest {
)

val data = insertShare(localData, remoteOperationResult)
val observer = mock<Observer<Resource<Void>>>()
val observer = mock<Observer<Resource<Unit>>>()
data.observeForever(observer)

// Get public shares from database is called once, when creating the repository
Expand Down Expand Up @@ -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<Observer<Resource<Void>>>()
val observer = mock<Observer<Resource<Unit>>>()
data.observeForever(observer)

verify(observer).onChanged(
Expand All @@ -252,7 +252,7 @@ class OCShareRepositoryTest {

val data = updateShare(localData, remoteOperationResult)

val observer = mock<Observer<Resource<Void>>>()
val observer = mock<Observer<Resource<Unit>>>()
data.observeForever(observer)

// Get public shares from database is called once, when creating the repository
Expand All @@ -279,7 +279,7 @@ class OCShareRepositoryTest {

val data = deleteShare(localData, remoteOperationResult)

val observer = mock<Observer<Resource<Void>>>()
val observer = mock<Observer<Resource<Unit>>>()
data.observeForever(observer)

// Get public shares from database is called once, when creating the repository
Expand Down Expand Up @@ -329,7 +329,7 @@ class OCShareRepositoryTest {
private fun insertShare(
localData: MutableLiveData<List<OCShare>>,
remoteOperationResult: RemoteOperationResult<ShareParserResult>
): LiveData<Resource<Void>> {
): LiveData<Resource<Unit>> {
val ocShareRepository = createRepositoryWithData(localData, remoteOperationResult)

return ocShareRepository.insertPublicShareForFile(
Expand All @@ -344,7 +344,7 @@ class OCShareRepositoryTest {
private fun updateShare(
localData: MutableLiveData<List<OCShare>>,
remoteOperationResult: RemoteOperationResult<ShareParserResult>
): LiveData<Resource<Void>> {
): LiveData<Resource<Unit>> {
val ocShareRepository = createRepositoryWithData(localData, remoteOperationResult)

return ocShareRepository.updatePublicShareForFile(
Expand All @@ -360,7 +360,7 @@ class OCShareRepositoryTest {
private fun deleteShare(
localData: MutableLiveData<List<OCShare>>,
remoteOperationResult: RemoteOperationResult<ShareParserResult>
): LiveData<Resource<Void>> {
): LiveData<Resource<Unit>> {
val ocShareRepository = createRepositoryWithData(localData, remoteOperationResult)
return ocShareRepository.deletePublicShare(
1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ class OCShareViewModelTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
value = Resource.success()
}
)

// Viewmodel that will ask ocShareRepository for shares
val ocShareViewModel = createOCShareViewModel(ocShareRepository)

val resource: Resource<Void>? = ocShareViewModel.insertPublicShareForFile(
val resource: Resource<Unit>? = ocShareViewModel.insertPublicShareForFile(
1,
"Photos 2 link",
"1234",
Expand All @@ -123,15 +123,15 @@ class OCShareViewModelTest {
false
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
value = Resource.success()
}
)

// Viewmodel that will ask ocShareRepository for shares
val ocShareViewModel = createOCShareViewModel(ocShareRepository)

val resource: Resource<Void>? = ocShareViewModel.updatePublicShareForFile(
val resource: Resource<Unit>? = ocShareViewModel.updatePublicShareForFile(
1,
"Photos 1 link",
"123456",
Expand All @@ -152,15 +152,15 @@ class OCShareViewModelTest {
3
)
).thenReturn(
MutableLiveData<Resource<Void>>().apply {
MutableLiveData<Resource<Unit>>().apply {
value = Resource.success()
}
)

// Viewmodel that will ask ocShareRepository for shares
val ocShareViewModel = createOCShareViewModel(ocShareRepository)

val resource: Resource<Void>? = ocShareViewModel.deletePublicShare(
val resource: Resource<Unit>? = ocShareViewModel.deletePublicShare(
3
).value

Expand Down

0 comments on commit 34d458f

Please sign in to comment.