Minor test refactor

This commit is contained in:
andrew 2023-09-21 01:13:34 +09:30
parent 9968b5d6ea
commit ec8b89b8a4

View File

@ -516,22 +516,14 @@ class ExpirationSettingsViewModelTest {
}
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)
}
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.isClosedGroupRecipient).thenReturn(true)
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(
threadId = THREAD_ID,
expiryMode = mode,