Search in sources :

Example 1 with NativeDetail

use of com.vodafone360.people.tests.TestModule.NativeDetail in project 360-Engine-for-Android by 360.

the class FetchNativeContactsTest method checkContacts.

private void checkContacts(List<NativeContactDetails> nativeContactList) {
    for (int i = 0; i < nativeContactList.size(); i++) {
        NativeContactDetails ncd = nativeContactList.get(i);
        ContactIdInfo info = ContactsTable.fetchContactIdFromNative(ncd.mId, mDb.getReadableDatabase());
        Contact contact = new Contact();
        ServiceStatus status = mDb.fetchContact(info.localId, contact);
        assertEquals(ServiceStatus.SUCCESS, status);
        LogUtils.logI("Checking contact local ID " + info.localId + ", native ID " + ncd.mId);
        boolean nameDone = false;
        boolean nicknameDone = false;
        boolean noteDone = false;
        int phonesDone = 0;
        int emailsDone = 0;
        int addressesDone = 0;
        int orgsDone = 0;
        int titlesDone = 0;
        for (ContactDetail detail : contact.details) {
            assertEquals(ncd.mId, detail.nativeContactId);
            detail.syncNativeContactId = fetchSyncNativeId(detail.localDetailID);
            assertEquals("No sync marker, ID = " + detail.nativeDetailId + ", key = " + detail.key, Integer.valueOf(-1), detail.syncNativeContactId);
            switch(detail.key) {
                case VCARD_NAME:
                    nameDone = true;
                    assertEquals(ncd.mName.toString(), detail.nativeVal1);
                    break;
                case VCARD_NICKNAME:
                    nicknameDone = true;
                    assertEquals(ncd.mName.toString(), detail.nativeVal1);
                    break;
                case VCARD_NOTE:
                    noteDone = true;
                    assertEquals(ncd.mNote, detail.nativeVal1);
                    break;
                case VCARD_PHONE:
                    phonesDone++;
                    for (NativeDetail nd : ncd.mPhoneList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                case VCARD_EMAIL:
                    emailsDone++;
                    for (NativeDetail nd : ncd.mEmailList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                case VCARD_ADDRESS:
                    addressesDone++;
                    for (NativeDetail nd : ncd.mAddressList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                case VCARD_ORG:
                    orgsDone++;
                    for (NativeDetail nd : ncd.mOrgList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                case VCARD_TITLE:
                    titlesDone++;
                    for (NativeDetail nd : ncd.mTitleList) {
                        if (nd.mId.equals(detail.localDetailID)) {
                            assertEquals(nd.mValue1, detail.nativeVal1);
                            assertEquals(nd.mValue2, detail.nativeVal2);
                            assertEquals(nd.mValue3, detail.nativeVal3);
                            break;
                        }
                    }
                    break;
                default:
                    fail("Unexpected detail: " + detail.key);
            }
        }
        String nameString = ncd.mName.toString();
        if (nameString.length() > 0) {
            assertTrue("Name was not done", nameDone);
            assertTrue("Nickname was not done", nicknameDone);
        }
        if (ncd.mNote != null && ncd.mNote.length() > 0) {
            assertTrue("Note was not done", noteDone);
        }
        assertEquals(ncd.mPhoneList.size(), phonesDone);
        assertEquals(ncd.mEmailList.size(), emailsDone);
        assertEquals(ncd.mAddressList.size(), addressesDone);
        assertEquals(ncd.mOrgList.size(), orgsDone);
        assertEquals(ncd.mTitleList.size(), titlesDone);
    }
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) NativeContactDetails(com.vodafone360.people.tests.TestModule.NativeContactDetails) ContactIdInfo(com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo) ServiceStatus(com.vodafone360.people.service.ServiceStatus) NativeDetail(com.vodafone360.people.tests.TestModule.NativeDetail) Contact(com.vodafone360.people.datatypes.Contact)

Aggregations

ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)1 Contact (com.vodafone360.people.datatypes.Contact)1 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)1 ServiceStatus (com.vodafone360.people.service.ServiceStatus)1 NativeContactDetails (com.vodafone360.people.tests.TestModule.NativeContactDetails)1 NativeDetail (com.vodafone360.people.tests.TestModule.NativeDetail)1