mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Convert tests from Hamcrest -> AssertK.
This commit is contained in:
committed by
Greyson Parrelli
parent
33c918defd
commit
1509e3ed79
@@ -5,6 +5,9 @@ import android.net.Uri
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.FlakyTest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import assertk.assertions.isNotEqualTo
|
||||
import org.junit.Assert.assertArrayEquals
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotEquals
|
||||
@@ -22,8 +25,6 @@ import org.thoughtcrime.securesms.attachments.UriAttachment
|
||||
import org.thoughtcrime.securesms.mms.MediaStream
|
||||
import org.thoughtcrime.securesms.mms.SentMediaQuality
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider
|
||||
import org.thoughtcrime.securesms.testing.assertIs
|
||||
import org.thoughtcrime.securesms.testing.assertIsNot
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.whispersystems.signalservice.api.crypto.AttachmentCipherInputStream
|
||||
@@ -142,8 +143,8 @@ class AttachmentTableTest {
|
||||
val highInfo = SignalDatabase.attachments.getDataFileInfo(highDatabaseAttachment.attachmentId)!!
|
||||
|
||||
assertNotEquals(standardInfo, highInfo)
|
||||
highInfo.file assertIsNot standardInfo.file
|
||||
highInfo.file.exists() assertIs true
|
||||
assertThat(highInfo.file).isNotEqualTo(standardInfo.file)
|
||||
assertThat(highInfo.file.exists()).isEqualTo(true)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,10 +175,10 @@ class AttachmentTableTest {
|
||||
val highInfo = SignalDatabase.attachments.getDataFileInfo(highDatabaseAttachment.attachmentId)!!
|
||||
val secondHighInfo = SignalDatabase.attachments.getDataFileInfo(secondHighDatabaseAttachment.attachmentId)!!
|
||||
|
||||
highInfo.file assertIsNot standardInfo.file
|
||||
secondHighInfo.file assertIs highInfo.file
|
||||
standardInfo.file.exists() assertIs true
|
||||
highInfo.file.exists() assertIs true
|
||||
assertThat(highInfo.file).isNotEqualTo(standardInfo.file)
|
||||
assertThat(secondHighInfo.file).isEqualTo(highInfo.file)
|
||||
assertThat(standardInfo.file.exists()).isEqualTo(true)
|
||||
assertThat(highInfo.file.exists()).isEqualTo(true)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -8,7 +10,6 @@ import org.signal.core.util.count
|
||||
import org.signal.core.util.readToSingleInt
|
||||
import org.thoughtcrime.securesms.backup.v2.ArchivedMediaObject
|
||||
import org.thoughtcrime.securesms.testing.SignalActivityRule
|
||||
import org.thoughtcrime.securesms.testing.assertIs
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class BackupMediaSnapshotTableTest {
|
||||
@@ -27,7 +28,7 @@ class BackupMediaSnapshotTableTest {
|
||||
|
||||
val count = getSyncedItemCount(pendingSyncTime)
|
||||
|
||||
count.assertIs(0)
|
||||
assertThat(count).isEqualTo(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -38,7 +39,7 @@ class BackupMediaSnapshotTableTest {
|
||||
|
||||
val count = getSyncedItemCount(pendingSyncTime)
|
||||
|
||||
count.assertIs(SEQUENCE_COUNT)
|
||||
assertThat(count).isEqualTo(SEQUENCE_COUNT)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,7 +57,7 @@ class BackupMediaSnapshotTableTest {
|
||||
.run()
|
||||
.readToSingleInt(-1)
|
||||
|
||||
count.assertIs(50)
|
||||
assertThat(count).isEqualTo(50)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,8 +78,8 @@ class BackupMediaSnapshotTableTest {
|
||||
|
||||
val total = getTotalItemCount()
|
||||
|
||||
count.assertIs(50)
|
||||
total.assertIs(SEQUENCE_COUNT)
|
||||
assertThat(count).isEqualTo(50)
|
||||
assertThat(total).isEqualTo(SEQUENCE_COUNT)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,7 +97,7 @@ class BackupMediaSnapshotTableTest {
|
||||
|
||||
val total = getTotalItemCount()
|
||||
|
||||
total.assertIs(50)
|
||||
assertThat(total).isEqualTo(50)
|
||||
}
|
||||
|
||||
private fun getTotalItemCount(): Int {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import android.database.sqlite.SQLiteConstraintException
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import assertk.assertions.isNull
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -12,7 +15,6 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaym
|
||||
import org.thoughtcrime.securesms.database.model.InAppPaymentSubscriberRecord
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.InAppPaymentData
|
||||
import org.thoughtcrime.securesms.testing.SignalActivityRule
|
||||
import org.thoughtcrime.securesms.testing.assertIs
|
||||
import org.whispersystems.signalservice.api.storage.IAPSubscriptionId
|
||||
import org.whispersystems.signalservice.api.subscriptions.SubscriberId
|
||||
import java.util.Currency
|
||||
@@ -191,11 +193,11 @@ class InAppPaymentSubscriberTableTest {
|
||||
.run()
|
||||
.readToSingleInt()
|
||||
|
||||
subscriberCount assertIs 1
|
||||
assertThat(subscriberCount).isEqualTo(1)
|
||||
|
||||
val subscriber = InAppPaymentsRepository.requireSubscriber(InAppPaymentSubscriberRecord.Type.BACKUP)
|
||||
subscriber.iapSubscriptionId?.originalTransactionId assertIs null
|
||||
subscriber.iapSubscriptionId?.purchaseToken assertIs "testToken"
|
||||
subscriber.subscriberId assertIs googleSubscriber.subscriberId
|
||||
assertThat(subscriber.iapSubscriptionId?.originalTransactionId).isNull()
|
||||
assertThat(subscriber.iapSubscriptionId?.purchaseToken).isEqualTo("testToken")
|
||||
assertThat(subscriber.subscriberId).isEqualTo(googleSubscriber.subscriberId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -14,7 +16,6 @@ import org.signal.core.util.deleteAll
|
||||
import org.signal.donations.InAppPaymentType
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.InAppPaymentData
|
||||
import org.thoughtcrime.securesms.testing.SignalActivityRule
|
||||
import org.thoughtcrime.securesms.testing.assertIs
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class InAppPaymentTableTest {
|
||||
@@ -37,13 +38,13 @@ class InAppPaymentTableTest {
|
||||
)
|
||||
|
||||
val paymentBeforeUpdate = SignalDatabase.inAppPayments.getById(inAppPaymentId)
|
||||
paymentBeforeUpdate?.state assertIs InAppPaymentTable.State.CREATED
|
||||
assertThat(paymentBeforeUpdate?.state).isEqualTo(InAppPaymentTable.State.CREATED)
|
||||
|
||||
SignalDatabase.inAppPayments.update(
|
||||
inAppPayment = paymentBeforeUpdate!!.copy(state = InAppPaymentTable.State.PENDING)
|
||||
)
|
||||
|
||||
val paymentAfterUpdate = SignalDatabase.inAppPayments.getById(inAppPaymentId)
|
||||
paymentAfterUpdate?.state assertIs InAppPaymentTable.State.PENDING
|
||||
assertThat(paymentAfterUpdate?.state).isEqualTo(InAppPaymentTable.State.PENDING)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import assertk.assertions.isFalse
|
||||
import assertk.assertions.isTrue
|
||||
import org.junit.Test
|
||||
import org.signal.core.util.forEach
|
||||
import org.signal.core.util.requireLong
|
||||
@@ -13,7 +17,6 @@ import org.signal.core.util.select
|
||||
import org.signal.core.util.updateAll
|
||||
import org.thoughtcrime.securesms.crash.CrashConfig
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.testing.assertIs
|
||||
|
||||
class LogDatabaseTest {
|
||||
|
||||
@@ -37,7 +40,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime
|
||||
)
|
||||
|
||||
foundMatch assertIs true
|
||||
assertThat(foundMatch).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,7 +61,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime
|
||||
)
|
||||
|
||||
foundMatch assertIs true
|
||||
assertThat(foundMatch).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +82,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime
|
||||
)
|
||||
|
||||
foundMatch assertIs true
|
||||
assertThat(foundMatch).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,7 +103,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime
|
||||
)
|
||||
|
||||
foundMatch assertIs true
|
||||
assertThat(foundMatch).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,7 +124,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime
|
||||
)
|
||||
|
||||
foundMatch assertIs true
|
||||
assertThat(foundMatch).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,7 +145,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime
|
||||
)
|
||||
|
||||
foundMatch assertIs true
|
||||
assertThat(foundMatch).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -163,7 +166,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime
|
||||
)
|
||||
|
||||
foundMatch assertIs false
|
||||
assertThat(foundMatch).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -184,7 +187,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime
|
||||
)
|
||||
|
||||
foundMatch assertIs false
|
||||
assertThat(foundMatch).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -205,7 +208,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime
|
||||
)
|
||||
|
||||
foundMatch assertIs false
|
||||
assertThat(foundMatch).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -231,7 +234,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime - 100
|
||||
)
|
||||
|
||||
foundMatch assertIs false
|
||||
assertThat(foundMatch).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,7 +248,7 @@ class LogDatabaseTest {
|
||||
promptThreshold = currentTime - 100
|
||||
)
|
||||
|
||||
foundMatch assertIs false
|
||||
assertThat(foundMatch).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -279,9 +282,9 @@ class LogDatabaseTest {
|
||||
.run()
|
||||
.forEach {
|
||||
if (it.requireNonNullString(LogDatabase.CrashTable.NAME) == "TestName") {
|
||||
it.requireLong(LogDatabase.CrashTable.LAST_PROMPTED_AT) assertIs currentTime
|
||||
assertThat(it.requireLong(LogDatabase.CrashTable.LAST_PROMPTED_AT)).isEqualTo(currentTime)
|
||||
} else {
|
||||
it.requireLong(LogDatabase.CrashTable.LAST_PROMPTED_AT) assertIs 0
|
||||
assertThat(it.requireLong(LogDatabase.CrashTable.LAST_PROMPTED_AT)).isEqualTo(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.hasSize
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -18,7 +20,6 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.testing.GroupTestingUtils
|
||||
import org.thoughtcrime.securesms.testing.SignalActivityRule
|
||||
import org.thoughtcrime.securesms.testing.assertIsSize
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class NameCollisionTablesTest {
|
||||
@@ -43,7 +44,7 @@ class NameCollisionTablesTest {
|
||||
SignalDatabase.threads.getOrCreateThreadIdFor(Recipient.resolved(threadRecipientId))
|
||||
val actual = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(threadRecipientId)
|
||||
|
||||
actual assertIsSize 0
|
||||
assertThat(actual).hasSize(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,8 +56,8 @@ class NameCollisionTablesTest {
|
||||
val actualAlice = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(alice)
|
||||
val actualBob = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(bob)
|
||||
|
||||
actualAlice assertIsSize 2
|
||||
actualBob assertIsSize 2
|
||||
assertThat(actualAlice).hasSize(2)
|
||||
assertThat(actualBob).hasSize(2)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,8 +69,8 @@ class NameCollisionTablesTest {
|
||||
val actualAlice = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(alice)
|
||||
val actualBob = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(bob)
|
||||
|
||||
actualAlice assertIsSize 0
|
||||
actualBob assertIsSize 0
|
||||
assertThat(actualAlice).hasSize(0)
|
||||
assertThat(actualBob).hasSize(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,9 +84,9 @@ class NameCollisionTablesTest {
|
||||
val actualBob = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(bob)
|
||||
val actualCharlie = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(charlie)
|
||||
|
||||
actualAlice assertIsSize 0
|
||||
actualBob assertIsSize 2
|
||||
actualCharlie assertIsSize 2
|
||||
assertThat(actualAlice).hasSize(0)
|
||||
assertThat(actualBob).hasSize(2)
|
||||
assertThat(actualCharlie).hasSize(2)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +100,7 @@ class NameCollisionTablesTest {
|
||||
|
||||
val actualAlice = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(alice)
|
||||
|
||||
actualAlice assertIsSize 2
|
||||
assertThat(actualAlice).hasSize(2)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,7 +111,7 @@ class NameCollisionTablesTest {
|
||||
|
||||
val actualCollisions = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(alice)
|
||||
|
||||
actualCollisions assertIsSize 0
|
||||
assertThat(actualCollisions).hasSize(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,7 +125,7 @@ class NameCollisionTablesTest {
|
||||
|
||||
val actualCollisions = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(alice)
|
||||
|
||||
actualCollisions assertIsSize 0
|
||||
assertThat(actualCollisions).hasSize(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -137,7 +138,7 @@ class NameCollisionTablesTest {
|
||||
|
||||
val actualCollisions = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(bob)
|
||||
|
||||
actualCollisions assertIsSize 2
|
||||
assertThat(actualCollisions).hasSize(2)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -154,7 +155,7 @@ class NameCollisionTablesTest {
|
||||
|
||||
val collisions = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(info.recipientId)
|
||||
|
||||
collisions assertIsSize 2
|
||||
assertThat(collisions).hasSize(2)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,7 +174,7 @@ class NameCollisionTablesTest {
|
||||
|
||||
val collisions = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(info.recipientId)
|
||||
|
||||
collisions assertIsSize 0
|
||||
assertThat(collisions).hasSize(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -190,7 +191,7 @@ class NameCollisionTablesTest {
|
||||
|
||||
val collisions = SignalDatabase.nameCollisions.getCollisionsForThreadRecipientId(info.recipientId)
|
||||
|
||||
collisions assertIsSize 0
|
||||
assertThat(collisions).hasSize(0)
|
||||
}
|
||||
|
||||
private fun setUpRecipient(recipientId: RecipientId): RecipientId {
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import assertk.assertions.isTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -14,7 +17,6 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.storage.StorageRecordUpdate
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncModels
|
||||
import org.thoughtcrime.securesms.testing.SignalActivityRule
|
||||
import org.thoughtcrime.securesms.testing.assertIs
|
||||
import org.thoughtcrime.securesms.util.MessageTableTestUtils
|
||||
import org.whispersystems.signalservice.api.storage.SignalContactRecord
|
||||
import org.whispersystems.signalservice.api.storage.toSignalContactRecord
|
||||
@@ -52,10 +54,10 @@ class RecipientTableTest_applyStorageSyncContactUpdate {
|
||||
val newVerifiedStatus: IdentityTable.VerifiedStatus = identities.getIdentityRecord(other.id).get().verifiedStatus
|
||||
|
||||
// THEN
|
||||
oldVerifiedStatus assertIs IdentityTable.VerifiedStatus.VERIFIED
|
||||
newVerifiedStatus assertIs IdentityTable.VerifiedStatus.DEFAULT
|
||||
assertThat(oldVerifiedStatus).isEqualTo(IdentityTable.VerifiedStatus.VERIFIED)
|
||||
assertThat(newVerifiedStatus).isEqualTo(IdentityTable.VerifiedStatus.DEFAULT)
|
||||
|
||||
val messages = MessageTableTestUtils.getMessages(SignalDatabase.threads.getThreadIdFor(other.id)!!)
|
||||
messages.first().isIdentityDefault assertIs true
|
||||
assertThat(messages.first().isIdentityDefault).isTrue()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.thoughtcrime.securesms.database
|
||||
import android.database.Cursor
|
||||
import androidx.core.content.contentValuesOf
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import org.hamcrest.MatcherAssert
|
||||
import org.hamcrest.Matchers
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.containsExactlyInAnyOrder
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
@@ -977,13 +977,16 @@ class RecipientTableTest_getAndPossiblyMerge {
|
||||
val updatedProfile1: NotificationProfile = SignalDatabase.notificationProfiles.getProfile(profile1.id)!!
|
||||
val updatedProfile2: NotificationProfile = SignalDatabase.notificationProfiles.getProfile(profile2.id)!!
|
||||
|
||||
MatcherAssert.assertThat("Notification Profile 1 should now only contain ACI $recipientIdAci", updatedProfile1.allowedMembers, Matchers.containsInAnyOrder(recipientIdAci))
|
||||
MatcherAssert.assertThat("Notification Profile 2 should now contain ACI A ($recipientIdAci) and ACI B ($recipientIdAciB)", updatedProfile2.allowedMembers, Matchers.containsInAnyOrder(recipientIdAci, recipientIdAciB))
|
||||
assertThat(updatedProfile1.allowedMembers, "Notification Profile 1 should now only contain ACI $recipientIdAci")
|
||||
.containsExactlyInAnyOrder(recipientIdAci)
|
||||
assertThat(updatedProfile2.allowedMembers, "Notification Profile 2 should now contain ACI A ($recipientIdAci) and ACI B ($recipientIdAciB)")
|
||||
.containsExactlyInAnyOrder(recipientIdAci, recipientIdAciB)
|
||||
|
||||
// Distribution List validation
|
||||
val updatedList: DistributionListRecord = SignalDatabase.distributionLists.getList(distributionListId)!!
|
||||
|
||||
MatcherAssert.assertThat("Distribution list should have updated $recipientIdE164 to $recipientIdAci", updatedList.members, Matchers.containsInAnyOrder(recipientIdAci, recipientIdAciB))
|
||||
assertThat(updatedList.members, "Distribution list should have updated $recipientIdE164 to $recipientIdAci")
|
||||
.containsExactlyInAnyOrder(recipientIdAci, recipientIdAciB)
|
||||
}
|
||||
|
||||
private fun smsMessage(sender: RecipientId, time: Long = 0, body: String = "", groupId: Optional<GroupId> = Optional.empty()): IncomingMessage {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.hamcrest.Matchers.`is`
|
||||
import org.hamcrest.Matchers.notNullValue
|
||||
import org.hamcrest.Matchers.nullValue
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import assertk.assertions.isNull
|
||||
import assertk.assertions.isPresent
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.signal.core.util.Hex
|
||||
import org.signal.libsignal.zkgroup.groups.GroupMasterKey
|
||||
import org.thoughtcrime.securesms.database.MessageTable.InsertResult
|
||||
import org.thoughtcrime.securesms.database.model.GroupsV2UpdateMessageConverter
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.GV2UpdateDescription
|
||||
@@ -19,6 +20,7 @@ import org.thoughtcrime.securesms.database.model.databaseprotos.deleteRequesting
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.groupChange
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.groupContext
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.isAbsent
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.mms.IncomingMessage
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
@@ -70,7 +72,7 @@ class SmsDatabaseTest_collapseJoinRequestEventsIfPossible {
|
||||
)
|
||||
)
|
||||
|
||||
assertThat("result is null when not collapsing", result.orElse(null), nullValue())
|
||||
assertThat(result, "result is null when not collapsing").isAbsent()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +94,7 @@ class SmsDatabaseTest_collapseJoinRequestEventsIfPossible {
|
||||
)
|
||||
)
|
||||
|
||||
assertThat("result is null when not collapsing", result.orElse(null), nullValue())
|
||||
assertThat(result, "result is null when not collapsing").isAbsent()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +125,7 @@ class SmsDatabaseTest_collapseJoinRequestEventsIfPossible {
|
||||
)
|
||||
)
|
||||
|
||||
assertThat("result is null when not collapsing", result.orElse(null), nullValue())
|
||||
assertThat(result, "result is null when not collapsing").isAbsent()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +156,7 @@ class SmsDatabaseTest_collapseJoinRequestEventsIfPossible {
|
||||
)
|
||||
)
|
||||
|
||||
assertThat("result is null when not collapsing", result.orElse(null), nullValue())
|
||||
assertThat(result, "result is null when not collapsing").isAbsent()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,8 +187,12 @@ class SmsDatabaseTest_collapseJoinRequestEventsIfPossible {
|
||||
)
|
||||
)
|
||||
|
||||
assertThat("result is not null when collapsing", result.orElse(null), notNullValue())
|
||||
assertThat("result message id should be same as latest message", result.get().messageId, `is`(latestMessage.messageId))
|
||||
assertThat(result, "result is not null when collapsing")
|
||||
.isPresent()
|
||||
.given { result: InsertResult ->
|
||||
assertThat(result.messageId, "result message id should be same as latest message")
|
||||
.isEqualTo(latestMessage.messageId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,8 +227,12 @@ class SmsDatabaseTest_collapseJoinRequestEventsIfPossible {
|
||||
)
|
||||
)
|
||||
|
||||
assertThat("result is not null when collapsing", result.orElse(null), notNullValue())
|
||||
assertThat("result message id should be same as latest message", result.get().messageId, `is`(latestMessage.messageId))
|
||||
assertThat(result, "result is not null when collapsing")
|
||||
.isPresent()
|
||||
.given { result: InsertResult ->
|
||||
assertThat(result.messageId, "result message id should be same as latest message")
|
||||
.isEqualTo(latestMessage.messageId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,9 +277,13 @@ class SmsDatabaseTest_collapseJoinRequestEventsIfPossible {
|
||||
)
|
||||
)
|
||||
|
||||
assertThat("result is not null when collapsing", result.orElse(null), notNullValue())
|
||||
assertThat("result message id should be same as second latest message", result.get().messageId, `is`(secondLatestMessage.messageId))
|
||||
assertThat("latest message should be deleted", sms.getMessageRecordOrNull(latestMessage.messageId), nullValue())
|
||||
assertThat(result, "result is not null when collapsing")
|
||||
.isPresent()
|
||||
.given { result: InsertResult ->
|
||||
assertThat(result.messageId, "result message id should be same as second latest message")
|
||||
.isEqualTo(secondLatestMessage.messageId)
|
||||
assertThat(sms.getMessageRecordOrNull(latestMessage.messageId), "latest message should be deleted").isNull()
|
||||
}
|
||||
}
|
||||
|
||||
private fun smsMessage(sender: RecipientId, body: String? = ""): IncomingMessage {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.hamcrest.Matchers.containsInAnyOrder
|
||||
import org.hamcrest.Matchers.hasSize
|
||||
import org.hamcrest.Matchers.`is`
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.containsExactlyInAnyOrder
|
||||
import assertk.assertions.hasSize
|
||||
import assertk.assertions.isFalse
|
||||
import assertk.assertions.isTrue
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
@@ -96,11 +97,11 @@ class StorySendTableTest {
|
||||
val recipientIdsForMessage1 = storySends.getRecipientsToSendTo(messageId1, 100, false)
|
||||
val recipientIdsForMessage2 = storySends.getRecipientsToSendTo(messageId2, 200, true)
|
||||
|
||||
assertThat(recipientIdsForMessage1, hasSize(10))
|
||||
assertThat(recipientIdsForMessage1, containsInAnyOrder(*recipients1to10.toTypedArray()))
|
||||
assertThat(recipientIdsForMessage1).hasSize(10)
|
||||
assertThat(recipientIdsForMessage1).containsExactlyInAnyOrder(*recipients1to10.toTypedArray())
|
||||
|
||||
assertThat(recipientIdsForMessage2, hasSize(10))
|
||||
assertThat(recipientIdsForMessage2, containsInAnyOrder(*recipients11to20.toTypedArray()))
|
||||
assertThat(recipientIdsForMessage2).hasSize(10)
|
||||
assertThat(recipientIdsForMessage2).containsExactlyInAnyOrder(*recipients11to20.toTypedArray())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,11 +112,11 @@ class StorySendTableTest {
|
||||
val recipientIdsForMessage1 = storySends.getRecipientsToSendTo(messageId1, 100, false)
|
||||
val recipientIdsForMessage2 = storySends.getRecipientsToSendTo(messageId2, 100, true)
|
||||
|
||||
assertThat(recipientIdsForMessage1, hasSize(5))
|
||||
assertThat(recipientIdsForMessage1, containsInAnyOrder(*recipients1to10.take(5).toTypedArray()))
|
||||
assertThat(recipientIdsForMessage1).hasSize(5)
|
||||
assertThat(recipientIdsForMessage1).containsExactlyInAnyOrder(*recipients1to10.take(5).toTypedArray())
|
||||
|
||||
assertThat(recipientIdsForMessage2, hasSize(10))
|
||||
assertThat(recipientIdsForMessage2, containsInAnyOrder(*recipients6to15.toTypedArray()))
|
||||
assertThat(recipientIdsForMessage2).hasSize(10)
|
||||
assertThat(recipientIdsForMessage2).containsExactlyInAnyOrder(*recipients6to15.toTypedArray())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,13 +132,13 @@ class StorySendTableTest {
|
||||
val recipientIdsForMessage2 = storySends.getRecipientsToSendTo(messageId2, 100, true)
|
||||
val recipientIdsForMessage3 = storySends.getRecipientsToSendTo(messageId3, 100, true)
|
||||
|
||||
assertThat(recipientIdsForMessage1, hasSize(0))
|
||||
assertThat(recipientIdsForMessage1).hasSize(0)
|
||||
|
||||
assertThat(recipientIdsForMessage2, hasSize(1))
|
||||
assertThat(recipientIdsForMessage2, containsInAnyOrder(recipient1))
|
||||
assertThat(recipientIdsForMessage2).hasSize(1)
|
||||
assertThat(recipientIdsForMessage2).containsExactlyInAnyOrder(recipient1)
|
||||
|
||||
assertThat(recipientIdsForMessage3, hasSize(1))
|
||||
assertThat(recipientIdsForMessage3, containsInAnyOrder(recipient2))
|
||||
assertThat(recipientIdsForMessage3).hasSize(1)
|
||||
assertThat(recipientIdsForMessage3).containsExactlyInAnyOrder(recipient2)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,11 +149,11 @@ class StorySendTableTest {
|
||||
val recipientIdsForMessage1 = storySends.getRecipientsToSendTo(messageId1, 100, true)
|
||||
val recipientIdsForMessage2 = storySends.getRecipientsToSendTo(messageId2, 100, false)
|
||||
|
||||
assertThat(recipientIdsForMessage1, hasSize(10))
|
||||
assertThat(recipientIdsForMessage1, containsInAnyOrder(*recipients6to15.toTypedArray()))
|
||||
assertThat(recipientIdsForMessage1).hasSize(10)
|
||||
assertThat(recipientIdsForMessage1).containsExactlyInAnyOrder(*recipients6to15.toTypedArray())
|
||||
|
||||
assertThat(recipientIdsForMessage2, hasSize(5))
|
||||
assertThat(recipientIdsForMessage2, containsInAnyOrder(*recipients1to10.take(5).toTypedArray()))
|
||||
assertThat(recipientIdsForMessage2).hasSize(5)
|
||||
assertThat(recipientIdsForMessage2).containsExactlyInAnyOrder(*recipients1to10.take(5).toTypedArray())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -164,11 +165,11 @@ class StorySendTableTest {
|
||||
val recipientIdsForMessage1 = storySends.getRemoteDeleteRecipients(messageId1, 100)
|
||||
val recipientIdsForMessage2 = storySends.getRemoteDeleteRecipients(messageId2, 200)
|
||||
|
||||
assertThat(recipientIdsForMessage1, hasSize(10))
|
||||
assertThat(recipientIdsForMessage1, containsInAnyOrder(*recipients1to10.toTypedArray()))
|
||||
assertThat(recipientIdsForMessage1).hasSize(10)
|
||||
assertThat(recipientIdsForMessage1).containsExactlyInAnyOrder(*recipients1to10.toTypedArray())
|
||||
|
||||
assertThat(recipientIdsForMessage2, hasSize(10))
|
||||
assertThat(recipientIdsForMessage2, containsInAnyOrder(*recipients11to20.toTypedArray()))
|
||||
assertThat(recipientIdsForMessage2).hasSize(10)
|
||||
assertThat(recipientIdsForMessage2).containsExactlyInAnyOrder(*recipients11to20.toTypedArray())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,11 +180,11 @@ class StorySendTableTest {
|
||||
val recipientIdsForMessage1 = storySends.getRemoteDeleteRecipients(messageId1, 200)
|
||||
val recipientIdsForMessage2 = storySends.getRemoteDeleteRecipients(messageId2, 200)
|
||||
|
||||
assertThat(recipientIdsForMessage1, hasSize(5))
|
||||
assertThat(recipientIdsForMessage1, containsInAnyOrder(*recipients1to10.take(5).toTypedArray()))
|
||||
assertThat(recipientIdsForMessage1).hasSize(5)
|
||||
assertThat(recipientIdsForMessage1).containsExactlyInAnyOrder(*recipients1to10.take(5).toTypedArray())
|
||||
|
||||
assertThat(recipientIdsForMessage2, hasSize(5))
|
||||
assertThat(recipientIdsForMessage2, containsInAnyOrder(*recipients6to15.takeLast(5).toTypedArray()))
|
||||
assertThat(recipientIdsForMessage2).hasSize(5)
|
||||
assertThat(recipientIdsForMessage2).containsExactlyInAnyOrder(*recipients6to15.takeLast(5).toTypedArray())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -195,8 +196,8 @@ class StorySendTableTest {
|
||||
|
||||
val recipientIdsForMessage2 = storySends.getRemoteDeleteRecipients(messageId2, 200)
|
||||
|
||||
assertThat(recipientIdsForMessage2, hasSize(10))
|
||||
assertThat(recipientIdsForMessage2, containsInAnyOrder(*recipients6to15.toTypedArray()))
|
||||
assertThat(recipientIdsForMessage2).hasSize(10)
|
||||
assertThat(recipientIdsForMessage2).containsExactlyInAnyOrder(*recipients6to15.toTypedArray())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -205,7 +206,7 @@ class StorySendTableTest {
|
||||
|
||||
val canReply = storySends.canReply(recipients1to10[0], 200)
|
||||
|
||||
assertThat(canReply, `is`(true))
|
||||
assertThat(canReply).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -214,7 +215,7 @@ class StorySendTableTest {
|
||||
|
||||
val canReply = storySends.canReply(recipients1to10[0], 200)
|
||||
|
||||
assertThat(canReply, `is`(false))
|
||||
assertThat(canReply).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -225,8 +226,8 @@ class StorySendTableTest {
|
||||
val message1OnlyRecipientCanReply = storySends.canReply(recipients1to10[0], 200)
|
||||
val message2RecipientCanReply = storySends.canReply(recipients6to10[0], 200)
|
||||
|
||||
assertThat(message1OnlyRecipientCanReply, `is`(false))
|
||||
assertThat(message2RecipientCanReply, `is`(true))
|
||||
assertThat(message1OnlyRecipientCanReply).isFalse()
|
||||
assertThat(message2RecipientCanReply).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -8,6 +8,9 @@ package org.thoughtcrime.securesms.database.helpers.migration
|
||||
import android.app.Application
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEmpty
|
||||
import assertk.assertions.isEqualTo
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -24,7 +27,6 @@ import org.thoughtcrime.securesms.database.model.InAppPaymentSubscriberRecord
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.FiatValue
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.InAppPaymentData
|
||||
import org.thoughtcrime.securesms.testing.SignalDatabaseRule
|
||||
import org.thoughtcrime.securesms.testing.assertIs
|
||||
import org.whispersystems.signalservice.api.subscriptions.SubscriberId
|
||||
import java.math.BigDecimal
|
||||
import java.util.Currency
|
||||
@@ -46,7 +48,7 @@ class FixInAppCurrencyIfAbleTest {
|
||||
clearCurrencyCode(subscriber)
|
||||
migrate()
|
||||
|
||||
getCurrencyCode(subscriber) assertIs ""
|
||||
assertThat(getCurrencyCode(subscriber)).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,7 +59,7 @@ class FixInAppCurrencyIfAbleTest {
|
||||
clearCurrencyCode(subscriber)
|
||||
migrate()
|
||||
|
||||
getCurrencyCode(subscriber) assertIs ""
|
||||
assertThat(getCurrencyCode(subscriber)).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +69,7 @@ class FixInAppCurrencyIfAbleTest {
|
||||
clearCurrencyCode(subscriber)
|
||||
migrate()
|
||||
|
||||
getCurrencyCode(subscriber) assertIs ""
|
||||
assertThat(getCurrencyCode(subscriber)).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,7 +79,7 @@ class FixInAppCurrencyIfAbleTest {
|
||||
clearCurrencyCode(subscriber)
|
||||
migrate()
|
||||
|
||||
getCurrencyCode(subscriber) assertIs "USD"
|
||||
assertThat(getCurrencyCode(subscriber)).isEqualTo("USD")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user