Collapse KnownRecipient / Story into single model.

This commit is contained in:
Alex Hart
2023-01-18 10:49:47 -04:00
committed by Cody Henthorne
parent 70c6e9e60f
commit 8e313f8387
25 changed files with 93 additions and 137 deletions

View File

@@ -51,16 +51,16 @@ class ContactSearchPagedDataSourceTest {
val expected = listOf(
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.RECENTS),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.INDIVIDUALS)
)
@@ -75,15 +75,15 @@ class ContactSearchPagedDataSourceTest {
val result = testSubject.load(5, 10) { false }
val expected = listOf(
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.INDIVIDUALS),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.KnownRecipient(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, false),
ContactSearchKey.Expand(ContactSearchConfiguration.SectionKey.INDIVIDUALS)
)
@@ -99,17 +99,17 @@ class ContactSearchPagedDataSourceTest {
val expected = listOf(
ContactSearchKey.Header(ContactSearchConfiguration.SectionKey.STORIES),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey.Story(RecipientId.UNKNOWN),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
ContactSearchKey.RecipientSearchKey(RecipientId.UNKNOWN, true),
)
val resultKeys = result.map { it.contactSearchKey }

View File

@@ -108,7 +108,7 @@ class SafetyNumberRepositoryTest {
@Test
fun batchSafetyNumberCheckSync_batchOf1_noChanges() {
val other = recipientPool[1]
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
@@ -127,7 +127,7 @@ class SafetyNumberRepositoryTest {
val other = recipientPool[1]
val otherAci = ACI.from(other.requireServiceId())
val otherNewIdentityKey = IdentityKeyUtil.generateIdentityKeyPair().publicKey
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
@@ -148,7 +148,7 @@ class SafetyNumberRepositoryTest {
val secondOther = recipientPool[2]
val otherAci = ACI.from(other.requireServiceId())
val otherNewIdentityKey = IdentityKeyUtil.generateIdentityKeyPair().publicKey
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id), ContactSearchKey.RecipientSearchKey.KnownRecipient(secondOther.id))
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false), ContactSearchKey.RecipientSearchKey(secondOther.id, false))
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other, secondOther))
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey, secondOther.requireServiceId() to identityPool[secondOther]!!.identityKey)))
@@ -166,7 +166,7 @@ class SafetyNumberRepositoryTest {
@Test
fun batchSafetyNumberCheckSync_batchOf1_abortOnPriorRecentCheck() {
val other = recipientPool[1]
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
@@ -187,7 +187,7 @@ class SafetyNumberRepositoryTest {
*/
@Test
fun batchSafetyNumberCheckSync_batchOf10WithSmallBatchSize_noChanges() {
val keys = recipientPool.map { ContactSearchKey.RecipientSearchKey.KnownRecipient(it.id) }
val keys = recipientPool.map { ContactSearchKey.RecipientSearchKey(it.id, false) }
val others = recipientPool.subList(1, recipientPool.lastIndex)
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(others.map { it.id }) }) }.thenReturn(others)
@@ -205,7 +205,7 @@ class SafetyNumberRepositoryTest {
@Test
fun batchSafetyNumberCheckSync_serverError() {
val other = recipientPool[1]
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
@@ -219,7 +219,7 @@ class SafetyNumberRepositoryTest {
@Test
fun batchSafetyNumberCheckSync_networkError() {
val other = recipientPool[1]
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))
@@ -233,7 +233,7 @@ class SafetyNumberRepositoryTest {
@Test
fun batchSafetyNumberCheckSync_badJson() {
val other = recipientPool[1]
val keys = listOf(ContactSearchKey.RecipientSearchKey.KnownRecipient(other.id))
val keys = listOf(ContactSearchKey.RecipientSearchKey(other.id, false))
staticRecipient.`when`<List<Recipient>> { Recipient.resolvedList(argThat { containsAll(keys.map { it.recipientId }) }) }.thenReturn(listOf(other))
whenever(profileService.performIdentityCheck(mapOf(other.requireServiceId() to identityPool[other]!!.identityKey)))