Search in sources :

Example 66 with Contact

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

the class NowPlusContactDetailsTableTest method testSyncNativeContactChanges.

/*
	 * test Sync Native Contact Changes
	 */
public void testSyncNativeContactChanges() {
    final String fnName = "testSyncNativeContactChanges";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "Validates sync server native contact details");
    SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    startSubTest(fnName, "Creating table");
    createTable();
    List<ContactDetail> detailsList = new ArrayList<ContactDetail>();
    for (int i = 0; i < NUM_OF_CONTACTS; i++) {
        ContactDetail detail = new ContactDetail();
        detail.localContactID = TestModule.generateRandomLong();
        detail.nativeContactId = TestModule.generateRandomInt();
        detail.nativeVal1 = TestModule.generateRandomString();
        detail.nativeVal2 = TestModule.generateRandomString();
        detail.nativeVal3 = TestModule.generateRandomString();
        mTestModule.createDummyDetailsData(detail);
        ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
        detailsList.add(detail);
    }
    Cursor nat = ContactDetailsTable.syncNativeFetchContactChanges(readableDb, true);
    assertEquals(3, nat.getCount());
    nat.close();
    Cursor cursor = ContactDetailsTable.syncNativeFetchContactChanges(readableDb, false);
    assertEquals(cursor.getCount(), ContactDetailsTable.syncNativeFetchNoOfChanges(readableDb));
    List<Contact> contactList = new ArrayList<Contact>();
    ContactDetailsTable.syncNativeGetNextNewContactDetails(cursor, contactList, NUM_OF_CONTACTS);
    for (int i = 0; i < contactList.size(); i++) {
        assertTrue(DatabaseHelper.doDetailsMatch(detailsList.get(i), contactList.get(i).details.get(0)));
    }
    cursor.close();
    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) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Contact(com.vodafone360.people.datatypes.Contact)

Example 67 with Contact

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

the class NowPlusContactSummaryTest method testAddingContactSummary.

/**
 * Tests adding a contact to the contact summary table.
 */
@SmallTest
public void testAddingContactSummary() {
    Log.i(LOG_TAG, "***** EXECUTING testAddingContactSummary *****");
    Log.i(LOG_TAG, "Create ContactSummaryTable");
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    final Contact contact = mTestModule.createDummyContactData();
    contact.localContactID = new Long(10);
    ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
}
Also used : Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 68 with Contact

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

the class NowPlusContactSummaryTest method testRemovingContactSummary.

/**
 * Tests removing a contact summary.
 */
@SmallTest
public void testRemovingContactSummary() {
    Log.i(LOG_TAG, "***** EXECUTING testRemovingContactSummary *****");
    Log.i(LOG_TAG, "Create ContactSummaryTable");
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Add a contact to ContactSummaryTable");
    final Contact contact = mTestModule.createDummyContactData();
    contact.localContactID = new Long(10);
    contact.nativeContactId = new Integer(11);
    ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Fetching a ContactSummary from ContactSummaryTable to check that it exists");
    ContactSummary contactSummary = new ContactSummary();
    ServiceStatus serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
    assertEquals(ServiceStatus.SUCCESS, serviceStatus);
    Log.i(LOG_TAG, "Delete the contact from ContactSummaryTable");
    serviceStatus = ContactSummaryTable.deleteContact(contact.localContactID, mTestDatabase.getWritableDatabase());
    assertEquals(ServiceStatus.SUCCESS, serviceStatus);
    Log.i(LOG_TAG, "Try to fetching a ContactSummary from ContactSummaryTable to check that it is not possible anymore");
    contactSummary = new ContactSummary();
    serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
    assertTrue(ServiceStatus.SUCCESS != serviceStatus);
}
Also used : ContactSummary(com.vodafone360.people.datatypes.ContactSummary) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 69 with Contact

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

the class NowPlusContactSummaryTest method testAddingContactDetails.

/**
 * Tests adding a contact detail to an existing contact.
 */
@SmallTest
public void testAddingContactDetails() {
    Log.i(LOG_TAG, "***** EXECUTING testAddingContactDetails *****");
    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 = mTestModule.createDummyContactData();
    contact.localContactID = new Long(10);
    contact.nativeContactId = new Integer(11);
    ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Add a contact detail to the previous contact");
    final ContactDetail contactDetail = new ContactDetail();
    contactDetail.localContactID = contact.localContactID;
    boolean isMe = false;
    contactDetail.setEmail("test@example.com", ContactDetail.DetailKeyTypes.HOME);
    assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 70 with Contact

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

the class NowPlusContactSummaryTest method copyContact.

/**
 * Creates a "light" copy of a Contact.
 *
 * @param contact the contact to copy
 * @return the copy of the provided contact
 */
private Contact copyContact(Contact contact) {
    final Contact newContact = new Contact();
    // using Copy() but seems deprecated, may need to be changed later
    // newContact.Copy(contact);
    newContact.friendOfMine = contact.friendOfMine;
    newContact.synctophone = contact.synctophone;
    newContact.localContactID = contact.localContactID;
    newContact.nativeContactId = contact.nativeContactId;
    return newContact;
}
Also used : Contact(com.vodafone360.people.datatypes.Contact)

Aggregations

Contact (com.vodafone360.people.datatypes.Contact)109 ServiceStatus (com.vodafone360.people.service.ServiceStatus)107 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)100 ArrayList (java.util.ArrayList)62 MediumTest (android.test.suitebuilder.annotation.MediumTest)50 Suppress (android.test.suitebuilder.annotation.Suppress)39 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)34 Cursor (android.database.Cursor)31 ContactChange (com.vodafone360.people.engine.contactsync.ContactChange)22 SmallTest (android.test.suitebuilder.annotation.SmallTest)19 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)18 SQLException (android.database.SQLException)15 ContentValues (android.content.ContentValues)14 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)13 Uri (android.net.Uri)11 ContactChangeInfo (com.vodafone360.people.database.tables.ContactChangeLogTable.ContactChangeInfo)11 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)11 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)11 SQLiteException (android.database.sqlite.SQLiteException)9 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)9