From ec8b89b8a42f0883b17428bd0495f0e6dfe02ff7 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 21 Sep 2023 01:13:34 +0930 Subject: [PATCH] Minor test refactor --- .../ExpirationSettingsViewModelTest.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/src/test/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModelTest.kt b/app/src/test/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModelTest.kt index d84937312d..7061a81a66 100644 --- a/app/src/test/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModelTest.kt +++ b/app/src/test/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModelTest.kt @@ -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())).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,