Search in sources :

Example 96 with Contact

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

the class PeopleContactsApiTest method testGetContact.

/**
     * Tests the getContact() method.
     */
public void testGetContact() {
    PeopleContactsApi pca = new PeopleContactsApi(mDatabaseHelper);
    // the database is empty, it shall not return any contact
    assertNull(pca.getContact(10));
}
Also used : PeopleContactsApi(com.vodafone360.people.engine.contactsync.PeopleContactsApi)

Example 97 with Contact

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

the class PeopleContactsApiTest method testAddGetNativeContact.

/**
     * Tests the methods sequence addNativeContact() then getNativeContact().
     */
@Suppress
public void testAddGetNativeContact() {
    final long NATIVE_ID = 15;
    PeopleContactsApi pca = new PeopleContactsApi(mDatabaseHelper);
    // the database is empty, it shall not return any ids
    assertNull(pca.getNativeContactsIds());
    // let's add a contact
    ContactChange[] contact = filterContactChanges(ContactChangeHelper.randomContact(ContactChange.INVALID_ID, ContactChange.INVALID_ID, NATIVE_ID));
    assertTrue(pca.addNativeContact(contact));
    // check that it exists
    long[] ids = pca.getNativeContactsIds();
    assertEquals(1, ids.length);
    assertEquals(NATIVE_ID, ids[0]);
    // get the contact back
    final ContactChange[] savedContact = pca.getContact(NATIVE_ID);
    assertNotNull(savedContact);
    // compare with the original one
    assertTrue(ContactChangeHelper.areChangeListsEqual(contact, savedContact, false));
}
Also used : PeopleContactsApi(com.vodafone360.people.engine.contactsync.PeopleContactsApi) ContactChange(com.vodafone360.people.engine.contactsync.ContactChange) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 98 with Contact

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

the class PeopleContactsApiTest method testUpdateGetNativeContact.

/**
     * Tests the updateNativeContact() and getContact() methods.
     */
@Suppress
public void testUpdateGetNativeContact() {
    final long NATIVE_ID = 15;
    PeopleContactsApi pca = new PeopleContactsApi(mDatabaseHelper);
    // the database is empty, it shall not return any ids
    assertNull(pca.getNativeContactsIds());
    // let's add a contact
    ContactChange[] contact = filterContactChanges(ContactChangeHelper.randomContact(ContactChange.INVALID_ID, ContactChange.INVALID_ID, NATIVE_ID));
    assertTrue(pca.addNativeContact(contact));
    // check that it exists
    long[] ids = pca.getNativeContactsIds();
    assertEquals(1, ids.length);
    assertEquals(NATIVE_ID, ids[0]);
    // perform some updates to the contact
    final ContactChange[] updatedDetails = ContactChangeHelper.randomContactUpdate(contact);
    pca.updateNativeContact(updatedDetails);
    // get the contact back
    final ContactChange[] savedContact = pca.getContact(NATIVE_ID);
    assertNotNull(savedContact);
    // check that the needed updates have been performed
    checkContactUpdates(contact, updatedDetails, savedContact);
}
Also used : PeopleContactsApi(com.vodafone360.people.engine.contactsync.PeopleContactsApi) ContactChange(com.vodafone360.people.engine.contactsync.ContactChange) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 99 with Contact

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

the class UpdateNativeContactsTest method feedSyncableContactsInDatabase.

/**
     * Feeds the People database with random contacts.
     * 
     * @param contactsCount the number of contact to create
     */
private void feedSyncableContactsInDatabase(int contactsCount) {
    for (int i = 0; i < contactsCount; i++) {
        final Contact contact = mTestModule.createDummyContactData();
        contact.synctophone = true;
        mDatabaseHelper.addContact(contact);
    }
}
Also used : Contact(com.vodafone360.people.datatypes.Contact)

Example 100 with Contact

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

the class UpdateNativeContactsTest method testExportingContactAllDetails.

/**
     * Tests the export of a new syncable contact with all the possible details combinations.
     */
public void testExportingContactAllDetails() {
    UpdateNativeContacts processor = new UpdateNativeContacts(mContactSyncCallback, mDatabaseHelper);
    // check that there are no contacts to sync
    long[] syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(null, syncableIds);
    // put a contact that need to be synchronized to native side and that contains
    // all the possible details that can be synchronized
    final Contact contact = feedOneSyncableContact();
    // check the count of the contacts to sync
    syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(1, syncableIds.length);
    // run the UpdateNativeContacts processor until it finishes or it times out
    runUpdateNativeContactsProcessor(processor);
    // check that the contact on native side is equivalent
    final NativeContactsApi nca = NativeContactsApi.getInstance();
    long[] ids = null;
    if (VersionUtils.is2XPlatform()) {
        ids = nca.getContactIds(PEOPLE_ACCOUNT);
    } else {
        ids = nca.getContactIds(null);
    }
    assertEquals(1, ids.length);
    // check that no more contact is syncable as the export is done
    syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(null, syncableIds);
    final ContactChange[] contactChanges = nca.getContact(ids[0]);
    assertTrue(compareContactWithContactChange(contact, contactChanges));
}
Also used : UpdateNativeContacts(com.vodafone360.people.engine.contactsync.UpdateNativeContacts) NativeContactsApi(com.vodafone360.people.engine.contactsync.NativeContactsApi) ContactChange(com.vodafone360.people.engine.contactsync.ContactChange) 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