Search in sources :

Example 6 with NativeContactsApiMockup

use of com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup in project 360-Engine-for-Android by 360.

the class NativeExporterTest method testMultipleExportsToNativeWithDeletedContacts.

/**
     * Tests multiple exports to native with deleted contacts.
     */
@Suppress
public void testMultipleExportsToNativeWithDeletedContacts() {
    // add contacts on People side and sync them to native side
    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));
    // delete half of contacts on People side
    peopleMockup.setSyncableDeletedContact(1);
    peopleMockup.setSyncableDeletedContact(2);
    peopleMockup.setSyncableDeletedContact(5);
    peopleMockup.setSyncableDeletedContact(8);
    peopleMockup.setSyncableDeletedContact(9);
    peopleMockup.setSyncableDeletedContact(13);
    peopleMockup.setSyncableDeletedContact(18);
    peopleMockup.setSyncableDeletedContact(19);
    peopleMockup.setSyncableDeletedContact(22);
    peopleMockup.setSyncableDeletedContact(23);
    peopleMockup.setSyncableDeletedContact(24);
    peopleMockup.setSyncableDeletedContact(25);
    peopleMockup.setSyncableDeletedContact(26);
    peopleMockup.setSyncableDeletedContact(28);
    peopleMockup.setSyncableDeletedContact(30);
    nativeIdsFromPeople = peopleMockup.getNativeContactsIds();
    assertEquals(NEW_CONTACTS_COUNT / 2, nativeIdsFromPeople.length);
    localIds = peopleMockup.getNativeSyncableContactIds();
    assertEquals(NEW_CONTACTS_COUNT / 2, localIds.length);
    // perform the export to native
    runNativeExporter(nativeMockup, peopleMockup);
    // check both sides are updated correctly
    nativeIds = nativeMockup.getContactIds(null);
    assertEquals(NEW_CONTACTS_COUNT / 2, 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 7 with NativeContactsApiMockup

use of com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup in project 360-Engine-for-Android by 360.

the class NativeExporterTest method testExportToNativeWithUpdatedContacts_updatedDetails.

/**
     * Tests export to native with updated details to existing contacts.
     */
@Suppress
public void testExportToNativeWithUpdatedContacts_updatedDetails() {
    // add contacts on People side and sync them to native side
    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));
    // pick contacts and modify all their details
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 1));
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 2));
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 5));
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 10));
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 12));
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 18));
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 19));
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 21));
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 23));
    peopleMockup.updateNativeContact(getUpdatedDetails(peopleMockup, 24));
    // perform the export to native
    runNativeExporter(nativeMockup, peopleMockup);
    // check both sides are equivalent
    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 8 with NativeContactsApiMockup

use of com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup in project 360-Engine-for-Android by 360.

the class NativeExporterTest method testExportAccount.

/**
     * Tests that the export is performed on the correct account depending on the Android platform.
     */
public void testExportAccount() {
    final int NEW_CONTACTS_COUNT = 30;
    final NativeContactsApiMockup nativeMockup = new NativeContactsApiMockup();
    final PeopleContactsApiMockup peopleMockup = new PeopleContactsApiMockup(null);
    nativeMockup.feedAccount(NativeImporterTest.GMAIL_ACCOUNT_1);
    nativeMockup.feedAccount(NativeImporterTest.GMAIL_ACCOUNT_2);
    nativeMockup.feedAccount(NativeImporterTest.THIRD_PARTY_ACCOUNT);
    nativeMockup.feedAccount(NativeImporterTest.PEOPLE_ACCOUNT);
    // 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);
    if (VersionUtils.is2XPlatform()) {
        // on Android 2.X, the contacts shall be present in the People Account
        final Account[] accounts = { NativeImporterTest.PEOPLE_ACCOUNT };
        assertTrue(NativeImporterTest.compareNativeAndPeopleContactsList(nativeMockup, accounts, peopleMockup));
    } else {
        // on Android 1.X, the contacts shall be present in the "null" account
        assertTrue(NativeImporterTest.compareNativeAndPeopleContactsList(nativeMockup, null, peopleMockup));
    }
}
Also used : NativeContactsApiMockup(com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup) Account(com.vodafone360.people.engine.contactsync.NativeContactsApi.Account)

Example 9 with NativeContactsApiMockup

use of com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup in project 360-Engine-for-Android by 360.

the class NativeExporterTest method testExportToNativeWithUpdatedContacts_addedDetails.

/**
     * Tests export to native with added details to a existing contacts.
     */
@Suppress
public void testExportToNativeWithUpdatedContacts_addedDetails() {
    // add contacts on People side and sync them to native side
    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));
    // pick few contacts and add details to them
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 1));
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 2));
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 5));
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 10));
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 12));
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 18));
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 19));
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 21));
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 23));
    peopleMockup.updateNativeContact(getNewDetails(peopleMockup, 24));
    // perform the export to native
    runNativeExporter(nativeMockup, peopleMockup);
    // check both sides are equivalent
    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)

Aggregations

NativeContactsApiMockup (com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup)6 Suppress (android.test.suitebuilder.annotation.Suppress)5 ContactChange (com.vodafone360.people.engine.contactsync.ContactChange)4 Account (com.vodafone360.people.engine.contactsync.NativeContactsApi.Account)1 NativeImporter (com.vodafone360.people.engine.contactsync.NativeImporter)1