alexstyl / contactstore

A modern, strongly-typed contacts API for Android.
https://alexstyl.github.io/contactstore
Apache License 2.0
440 stars 15 forks source link

fetchContacts does not return lookupKey when using TestContactStore #62

Closed itsandreramon closed 2 years ago

itsandreramon commented 2 years ago

I am currently trying the test dependency out but observed a weird error when prepopulating the store. I am currently filtering out contacts without a lookup key. While this should technically never be the case, the property is still nullable. Now, when setting a prepopulated contact with a lookup key, the result using fetchContacts returns the exact same contact but without the lookup key, which is null:

    private val store = TestContactStore(
        contactsSnapshot = listOf(
            StoredContact(
                contactId = 0,
                lookupKey = LookupKey(""),
                firstName = "Max",
                lastName = "Mustermann",
                phones = listOf(
                    LabeledValue(
                        value = PhoneNumber("123456789"),
                        label = Label.PhoneNumberMobile,
                    )
                ),
                postalAddresses = listOf(
                    LabeledValue(
                        value = PostalAddress(
                            postCode = "12345",
                            street = "Musterweg 10",
                            city = "Musterstadt",
                            country = "Musterland"
                        ),
                        label = Label.LocationHome
                    )
                )
            )
        )
    )
[PartialContact(contactId=0, displayName='Max Mustermann' lookupKey=null, isStarred=false, columns=[com.alexstyl.contactstore.ContactColumn$Names@197180a5, com.alexstyl.contactstore.ContactColumn$Phones@31028e45, com.alexstyl.contactstore.ContactColumn$Mails@68f75a35, com.alexstyl.contactstore.ContactColumn$PostalAddresses@50e0b472], imageData=N/A, phones=[LabeledValue(value=PhoneNumber(raw=123456789), label=com.alexstyl.contactstore.Label$PhoneNumberMobile@4a86be01, id=null, account=null)], mails=[], events=N/A, postalAddresses=[LabeledValue(value=PostalAddress(street=Musterweg 10, poBox=, neighborhood=, city=Musterstadt, region=, postCode=12345, country=Musterland), label=com.alexstyl.contactstore.Label$LocationHome@50a1af86, id=null, account=null)], webAddresses=N/A, imAddresses=N/A, sipAddresses=N/A, customDataItems=N/A, note=N/A, groups=N/A, relations=N/A, organization=N/A, jobTitle=N/A, firstName=Max, lastName=Mustermann, middleName=, prefix=, suffix=, phoneticLastName=, phoneticFirstName=, phoneticMiddleName=, fullNameStyle=0, phoneticNameStyle=0, nickname=N/A)]