Search in sources :

Example 41 with Contact

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

the class NativeExporterTest method testMultipleExportsToNativeWithNewContacts.

/**
 * Tests multiple exports to native with only new contacts.
 */
@Suppress
public void testMultipleExportsToNativeWithNewContacts() {
    final int NEW_CONTACTS_COUNT = 30;
    final NativeContactsApiMockup nativeMockup = new NativeContactsApiMockup();
    final PeopleContactsApiMockup peopleMockup = new PeopleContactsApiMockup(null);
    // add new contacts syncable contact on People side
    feedPeopleContactsApiWithNewSyncableContacts(peopleMockup, NEW_CONTACTS_COUNT);
    long[] nativeIdsFromPeople = peopleMockup.getNativeContactsIds();
    // shall be null because our PeopleContactsApiMockup will add them once synced
    assertEquals(null, nativeIdsFromPeople);
    long[] localIds = peopleMockup.getNativeSyncableContactIds();
    assertEquals(NEW_CONTACTS_COUNT, localIds.length);
    long[] nativeIds = nativeMockup.getContactIds(null);
    assertEquals(null, nativeIds);
    // perform the export to native
    runNativeExporter(nativeMockup, peopleMockup);
    // check both sides are updated correctly
    nativeIdsFromPeople = peopleMockup.getNativeContactsIds();
    assertEquals(NEW_CONTACTS_COUNT, nativeIdsFromPeople.length);
    nativeIds = nativeMockup.getContactIds(null);
    assertEquals(NEW_CONTACTS_COUNT, nativeIds.length);
    localIds = peopleMockup.getNativeSyncableContactIds();
    assertEquals(null, localIds);
    assertTrue(NativeImporterTest.compareNativeAndPeopleContactsList(nativeMockup, null, peopleMockup));
}
Also used : NativeContactsApiMockup(com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 42 with Contact

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

the class NativeImporterTest method testMultipleImportsFromNativeWithUpdatedContact_updatedDetails.

/**
 * Tests multiple imports from native with an updated contact via updated details.
 */
public void testMultipleImportsFromNativeWithUpdatedContact_updatedDetails() {
    final NativeContactsApiMockup nativeMockup = new NativeContactsApiMockup();
    final PeopleContactsApiMockup peopleMockup = new PeopleContactsApiMockup(null);
    // add new contacts on native side
    feedNativeContactsApi(nativeMockup, 20, null);
    long[] nativeIds = nativeMockup.getContactIds(null);
    assertEquals(20, nativeIds.length);
    // import the new contacts
    runNativeImporter(nativeMockup, peopleMockup);
    // compare contacts on both sides
    assertTrue(compareNativeAndPeopleContactsList(nativeMockup, null, peopleMockup));
    // pick an existing contact
    final ContactChange[] originalContact = nativeMockup.getContact(10);
    // modify its details
    for (int i = 0; i < originalContact.length; i++) {
        final ContactChange originalChange = originalContact[i];
        originalContact[i] = alterContactChangeValue(originalChange, originalChange.getValue() + "x9x");
    }
    nativeMockup.setContact(10, originalContact);
    // import the new contacts
    runNativeImporter(nativeMockup, peopleMockup);
    // compare contacts on both sides
    assertTrue(compareNativeAndPeopleContactsList(nativeMockup, null, peopleMockup));
}
Also used : ContactChange(com.vodafone360.people.engine.contactsync.ContactChange)

Example 43 with Contact

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

the class NativeImporterTest method addDetails.

/**
 * Adds details to the provided contact.
 *
 * @param contact
 * @return
 */
private ContactChange[] addDetails(NativeContactsApiMockup ncam, ContactChange[] contact) {
    long nativeId = contact[0].getNabContactId();
    int index = contact.length;
    // create the new Contact
    ContactChange[] newContact = new ContactChange[contact.length + 2];
    // copy original info into it
    System.arraycopy(contact, 0, newContact, 0, contact.length);
    // add extra details
    newContact[index] = new ContactChange(ContactChange.KEY_VCARD_EMAIL, "xxxxx@xxxxx.xx", ContactChange.FLAG_WORK);
    newContact[index].setNabContactId(nativeId);
    newContact[index].setNabDetailId(ncam.getAndIncNabDetailId());
    index++;
    newContact[index] = new ContactChange(ContactChange.KEY_VCARD_PHONE, "+9912345678", ContactChange.FLAG_WORK);
    newContact[index].setNabContactId(nativeId);
    newContact[index].setNabDetailId(ncam.getAndIncNabDetailId());
    index++;
    return newContact;
}
Also used : ContactChange(com.vodafone360.people.engine.contactsync.ContactChange)

Example 44 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 45 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)

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