mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Minor test refactor
This commit is contained in:
parent
9968b5d6ea
commit
ec8b89b8a4
@ -516,22 +516,14 @@ class ExpirationSettingsViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun mock1on1(mode: ExpiryMode, someAddress: Address) {
|
private fun mock1on1(mode: ExpiryMode, someAddress: Address) {
|
||||||
val config = config(mode)
|
mockStuff(mode)
|
||||||
|
|
||||||
whenever(threadDb.getRecipientForThreadId(Mockito.anyLong())).thenReturn(recipient)
|
|
||||||
whenever(storage.getExpirationConfiguration(Mockito.anyLong())).thenReturn(config)
|
|
||||||
whenever(textSecurePreferences.getLocalNumber()).thenReturn(LOCAL_NUMBER)
|
|
||||||
whenever(recipient.isClosedGroupRecipient).thenReturn(false)
|
|
||||||
whenever(recipient.address).thenReturn(someAddress)
|
whenever(recipient.address).thenReturn(someAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mockGroup(mode: ExpiryMode, isAdmin: Boolean) {
|
private fun mockGroup(mode: ExpiryMode, isAdmin: Boolean) {
|
||||||
val config = config(mode)
|
mockStuff(mode)
|
||||||
|
|
||||||
whenever(threadDb.getRecipientForThreadId(Mockito.anyLong())).thenReturn(recipient)
|
|
||||||
whenever(storage.getExpirationConfiguration(Mockito.anyLong())).thenReturn(config)
|
|
||||||
whenever(textSecurePreferences.getLocalNumber()).thenReturn(LOCAL_NUMBER)
|
|
||||||
whenever(recipient.isClosedGroupRecipient).thenReturn(false)
|
|
||||||
whenever(recipient.address).thenReturn(GROUP_ADDRESS)
|
whenever(recipient.address).thenReturn(GROUP_ADDRESS)
|
||||||
whenever(recipient.isClosedGroupRecipient).thenReturn(true)
|
whenever(recipient.isClosedGroupRecipient).thenReturn(true)
|
||||||
whenever(groupDb.getGroup(any<String>())).thenReturn(Optional.of(groupRecord))
|
whenever(groupDb.getGroup(any<String>())).thenReturn(Optional.of(groupRecord))
|
||||||
@ -542,6 +534,13 @@ class ExpirationSettingsViewModelTest {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun mockStuff(mode: ExpiryMode) {
|
||||||
|
val config = config(mode)
|
||||||
|
whenever(threadDb.getRecipientForThreadId(Mockito.anyLong())).thenReturn(recipient)
|
||||||
|
whenever(storage.getExpirationConfiguration(Mockito.anyLong())).thenReturn(config)
|
||||||
|
whenever(textSecurePreferences.getLocalNumber()).thenReturn(LOCAL_NUMBER)
|
||||||
|
}
|
||||||
|
|
||||||
private fun config(mode: ExpiryMode) = ExpirationConfiguration(
|
private fun config(mode: ExpiryMode) = ExpirationConfiguration(
|
||||||
threadId = THREAD_ID,
|
threadId = THREAD_ID,
|
||||||
expiryMode = mode,
|
expiryMode = mode,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user