Search in sources :

Example 91 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class NowPlusContactDetailsTableTest method testContactsMatch.

@MediumTest
public void testContactsMatch() {
    final String fnName = "testContactsMatch";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "Validates doContactsMatch method");
    SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    Contact contact = mTestModule.createDummyContactData();
    contact.localContactID = TestModule.generateRandomLong();
    startSubTest(fnName, "Creating table");
    createTable();
    List<NativeIdInfo> detailIdList = new ArrayList<NativeIdInfo>();
    assertFalse(ContactDetailsTable.doContactsMatch(contact, contact.localContactID, detailIdList, readableDb));
    ServiceStatus status;
    for (ContactDetail cd : contact.details) {
        cd.localContactID = contact.localContactID;
        status = ContactDetailsTable.addContactDetail(cd, true, true, writeableDb);
        assertEquals(ServiceStatus.SUCCESS, status);
    }
    // assertTrue(ContactDetailsTable.doContactsMatch(contact,
    // contact.localContactID, detailIdList, readableDb));
    Log.i(LOG_TAG, "***********************************************");
    Log.i(LOG_TAG, fnName + " has completed successfully");
    Log.i(LOG_TAG, "***********************************************");
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) NativeIdInfo(com.vodafone360.people.database.tables.ContactDetailsTable.NativeIdInfo) ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) Contact(com.vodafone360.people.datatypes.Contact) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 92 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class NowPlusContactDetailsTableTest method testFindNativeContact.

@MediumTest
public void testFindNativeContact() {
    final String fnName = "testFindNativeContact";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    startSubTest(fnName, "Creating table");
    createTable();
    // create contact
    Contact contact = new Contact();
    contact.synctophone = true;
    // add contact to to the ContactsTable
    ContactsTable.create(mTestDatabase.getWritableDatabase());
    ServiceStatus status = ContactsTable.addContact(contact, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    // add contact to ContactSummaryTable
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    status = ContactSummaryTable.addContact(contact, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    // create and add NameDetail
    ContactDetail nameDetail = mTestModule.createDummyDetailsName();
    ContactDetail nicknameDetail = mTestModule.createDummyDetailsNickname(nameDetail);
    nicknameDetail.localContactID = contact.localContactID;
    status = ContactDetailsTable.addContactDetail(nicknameDetail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    contact.details.add(nicknameDetail);
    // create and add phoneDetail
    ContactDetail phoneDetail = new ContactDetail();
    phoneDetail.localContactID = contact.localContactID;
    phoneDetail.key = ContactDetail.DetailKeys.VCARD_PHONE;
    String number = "07967 123456";
    phoneDetail.setTel(number, ContactDetail.DetailKeyTypes.CELL);
    status = ContactDetailsTable.addContactDetail(phoneDetail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    contact.details.add(phoneDetail);
    // create and add phoneDetail
    ContactDetail emailDetail = new ContactDetail();
    emailDetail.localContactID = contact.localContactID;
    emailDetail.key = ContactDetail.DetailKeys.VCARD_EMAIL;
    emailDetail.setEmail(TestModule.generateRandomString() + "@mail.co.uk", ContactDetail.DetailKeyTypes.HOME);
    status = ContactDetailsTable.addContactDetail(emailDetail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    contact.details.add(emailDetail);
    assertTrue(ContactDetailsTable.findNativeContact(contact, writeableDb));
    Log.i(LOG_TAG, "***********************************************");
    Log.i(LOG_TAG, fnName + " has completed successfully");
    Log.i(LOG_TAG, "***********************************************");
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Contact(com.vodafone360.people.datatypes.Contact) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 93 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class NowPlusContactDetailsTableTest method testSyncSetNativeIds.

/*
	 * test syncNativeIds
	 */
public void testSyncSetNativeIds() {
    final String fnName = "testSyncSetNativeIds";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "Validates syncSetNativeIds details");
    SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    startSubTest(fnName, "Creating table");
    createTable();
    List<NativeIdInfo> nativeIdList = new ArrayList<NativeIdInfo>();
    List<ContactDetail> detailsList = new ArrayList<ContactDetail>();
    for (int i = 0; i < NUM_OF_CONTACTS; i++) {
        ContactDetail detail = new ContactDetail();
        detail.localContactID = TestModule.generateRandomLong();
        mTestModule.createDummyDetailsData(detail);
        ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
        NativeIdInfo nativeIdInfo = new NativeIdInfo();
        nativeIdInfo.nativeContactId = TestModule.generateRandomInt();
        nativeIdInfo.localId = detail.localDetailID;
        nativeIdList.add(nativeIdInfo);
        detailsList.add(detail);
    }
    ServiceStatus status = ContactDetailsTable.syncSetNativeIds(nativeIdList, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    for (int i = 0; i < NUM_OF_CONTACTS; i++) {
        ContactDetail fetchedDetail = ContactDetailsTable.fetchDetail(nativeIdList.get(i).localId, readableDb);
        assertNotNull(fetchedDetail);
        assertEquals(nativeIdList.get(i).nativeContactId, fetchedDetail.nativeContactId);
    }
    Log.i(LOG_TAG, "***********************************************");
    Log.i(LOG_TAG, fnName + " has completed successfully");
    Log.i(LOG_TAG, "***********************************************");
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) NativeIdInfo(com.vodafone360.people.database.tables.ContactDetailsTable.NativeIdInfo) ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList)

Example 94 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class NowPlusContactSummaryTest method getDisplayName.

/**
 * Simplified logic in comparison to the real code in ContactSummaryTable.getDisplayNameDetail
 * and updateDisplayName which should behave the same way.
 * @param contact The contact to search
 * @param isMe Is the contact the me contact
 * @return The retrieved displayName
 */
private static String getDisplayName(Contact contact, boolean isMe) {
    ContactDetail name = null;
    name = contact.getContactDetail(ContactDetail.DetailKeys.VCARD_NAME);
    if (name != null && name.getName() != null) {
        return name.getName().toString();
    }
    if (isMe) {
        return SyncMeDbUtils.ME_PROFILE_DEFAULT_NAME;
    }
    name = contact.getContactDetail(ContactDetail.DetailKeys.VCARD_ORG);
    if (name != null && !TextUtils.isEmpty(name.getValue())) {
        return name.getValue();
    }
    name = contact.getContactDetail(ContactDetail.DetailKeys.VCARD_EMAIL);
    if (name != null && !TextUtils.isEmpty(name.getValue())) {
        return name.getValue();
    }
    name = contact.getContactDetail(ContactDetail.DetailKeys.VCARD_PHONE);
    if (name != null && !TextUtils.isEmpty(name.getValue())) {
        return name.getValue();
    }
    return ContactDetail.UNKNOWN_NAME;
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail)

Example 95 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class NowPlusContactSummaryTest method testDeletingContactDetails.

/**
 * Tests deleting a contact detail of an existing contact.
 */
@SmallTest
public void testDeletingContactDetails() {
    Log.i(LOG_TAG, "***** EXECUTING testDeletingContactDetails *****");
    Log.i(LOG_TAG, "Create ContactSummaryTable");
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Create also a ContactDetailsTable");
    ContactDetailsTable.create(mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Add a contact to ContactSummaryTable");
    final Contact contact = new Contact();
    contact.localContactID = new Long(10);
    contact.nativeContactId = new Integer(11);
    ServiceStatus serviceStatus = ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
    assertEquals(ServiceStatus.SUCCESS, serviceStatus);
    Log.i(LOG_TAG, "Add a contact detail to the previous contact");
    ContactDetail contactDetail = new ContactDetail();
    contactDetail.localContactID = contact.localContactID;
    final String eMail = "toto@mail.co.uk";
    contactDetail.setEmail(eMail, ContactDetail.DetailKeyTypes.HOME);
    boolean isMe = false;
    assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
    Log.i(LOG_TAG, "Delete a contact detail from the previous contact");
    assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ContactDetail (com.vodafone360.people.datatypes.ContactDetail)109 Contact (com.vodafone360.people.datatypes.Contact)60 ServiceStatus (com.vodafone360.people.service.ServiceStatus)57 ArrayList (java.util.ArrayList)33 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)24 MediumTest (android.test.suitebuilder.annotation.MediumTest)24 Cursor (android.database.Cursor)20 Suppress (android.test.suitebuilder.annotation.Suppress)16 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)15 ContentValues (android.content.ContentValues)11 SmallTest (android.test.suitebuilder.annotation.SmallTest)10 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)10 SQLException (android.database.SQLException)8 Uri (android.net.Uri)7 SQLiteException (android.database.sqlite.SQLiteException)6 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)6 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)6 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)4 ContactChangeInfo (com.vodafone360.people.database.tables.ContactChangeLogTable.ContactChangeInfo)4 Date (java.util.Date)4