Search in sources :

Example 1 with UpdateNativeContacts

use of com.vodafone360.people.engine.contactsync.UpdateNativeContacts 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)

Example 2 with UpdateNativeContacts

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

the class UpdateNativeContactsTest method testExportingDeletedContacts.

/**
     * Tests the export of new syncable contacts.
     */
@Suppress
public void testExportingDeletedContacts() {
    final int CONTACTS_COUNT = 30;
    UpdateNativeContacts processor = new UpdateNativeContacts(mContactSyncCallback, mDatabaseHelper);
    // check that there are no contacts to sync
    long[] syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(null, syncableIds);
    // put some contacts that need to be synchronized to native side
    feedSyncableContactsInDatabase(CONTACTS_COUNT);
    // check the count of the contacts to sync
    syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(CONTACTS_COUNT, syncableIds.length);
    // run the UpdateNativeContacts processor until it finishes or it times out
    runUpdateNativeContactsProcessor(processor);
    // check the contacts count on native side
    final NativeContactsApi nca = NativeContactsApi.getInstance();
    long[] ids = null;
    if (VersionUtils.is2XPlatform()) {
        ids = nca.getContactIds(PEOPLE_ACCOUNT);
    } else {
        ids = nca.getContactIds(null);
    }
    assertEquals(CONTACTS_COUNT, ids.length);
    // check that no more contact is syncable as the export is done
    syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(null, syncableIds);
    // delete 6 of the exported contacts
    mDatabaseHelper.deleteContact(1);
    mDatabaseHelper.deleteContact(3);
    mDatabaseHelper.deleteContact(5);
    mDatabaseHelper.deleteContact(15);
    mDatabaseHelper.deleteContact(20);
    mDatabaseHelper.deleteContact(26);
    // check the count of the contacts to sync
    syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(6, syncableIds.length);
    // run the UpdateNativeContacts processor until it finishes or it times out
    processor = new UpdateNativeContacts(mContactSyncCallback, mDatabaseHelper);
    mContactSyncCallback.mProcessorComplete.clear();
    runUpdateNativeContactsProcessor(processor);
    // check the contacts count on native side
    if (VersionUtils.is2XPlatform()) {
        ids = nca.getContactIds(PEOPLE_ACCOUNT);
    } else {
        ids = nca.getContactIds(null);
    }
    assertEquals(CONTACTS_COUNT - 6, ids.length);
    // check that no more contact is syncable as the export is done
    syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(null, syncableIds);
}
Also used : UpdateNativeContacts(com.vodafone360.people.engine.contactsync.UpdateNativeContacts) NativeContactsApi(com.vodafone360.people.engine.contactsync.NativeContactsApi) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 3 with UpdateNativeContacts

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

the class UpdateNativeContactsTest method testExportingNewContacts.

/**
     * Tests the export of new syncable contacts.
     */
public void testExportingNewContacts() {
    final int CONTACTS_COUNT = 10;
    UpdateNativeContacts processor = new UpdateNativeContacts(mContactSyncCallback, mDatabaseHelper);
    // check that there are no contacts to sync
    long[] syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(null, syncableIds);
    // put some contacts that need to be synchronized to native side
    feedSyncableContactsInDatabase(CONTACTS_COUNT);
    // check the count of the contacts to sync
    syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(CONTACTS_COUNT, syncableIds.length);
    // run the UpdateNativeContacts processor until it finishes or it times out
    runUpdateNativeContactsProcessor(processor);
    // check the contacts count on native side
    final NativeContactsApi nca = NativeContactsApi.getInstance();
    long[] ids = null;
    if (VersionUtils.is2XPlatform()) {
        ids = nca.getContactIds(PEOPLE_ACCOUNT);
    } else {
        ids = nca.getContactIds(null);
    }
    assertEquals(CONTACTS_COUNT, ids.length);
    // check that no more contact is syncable as the export is done
    syncableIds = mDatabaseHelper.getNativeSyncableContactsLocalIds();
    assertEquals(null, syncableIds);
}
Also used : UpdateNativeContacts(com.vodafone360.people.engine.contactsync.UpdateNativeContacts) NativeContactsApi(com.vodafone360.people.engine.contactsync.NativeContactsApi)

Example 4 with UpdateNativeContacts

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

the class UpdateNativeContactsTest method testRunWithEmptyDatabase.

/**
     * Tests running the processor with an empty database.
     */
public void testRunWithEmptyDatabase() {
    UpdateNativeContacts processor = new UpdateNativeContacts(mContactSyncCallback, mDatabaseHelper);
    processor.start();
    assertEquals(1, mContactSyncCallback.mProcessorComplete.size());
    ContactSyncCallback.ProcessorComplete pc = mContactSyncCallback.mProcessorComplete.get(0);
    assertEquals(ServiceStatus.SUCCESS, pc.status);
}
Also used : IContactSyncCallback(com.vodafone360.people.engine.contactsync.IContactSyncCallback) UpdateNativeContacts(com.vodafone360.people.engine.contactsync.UpdateNativeContacts)

Example 5 with UpdateNativeContacts

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

the class DefaultProcessorFactoryTest method testProcessorTypeCreation.

/**
     * Tests the type of the created processor depending on the requested type.
     */
@Suppress
public void testProcessorTypeCreation() {
    DefaultProcessorFactory factory = new DefaultProcessorFactory();
    BaseSyncProcessor processor;
    processor = factory.create(ProcessorFactory.DOWNLOAD_SERVER_CONTACTS, null, null);
    assertTrue(processor instanceof DownloadServerContacts);
    processor = factory.create(ProcessorFactory.FETCH_NATIVE_CONTACTS, null, null);
    assertTrue(processor instanceof FetchNativeContacts);
    processor = factory.create(ProcessorFactory.UPDATE_NATIVE_CONTACTS, null, null);
    assertTrue(processor instanceof UpdateNativeContacts);
    processor = factory.create(ProcessorFactory.UPLOAD_SERVER_CONTACTS, null, null);
    assertTrue(processor instanceof UploadServerContacts);
}
Also used : UpdateNativeContacts(com.vodafone360.people.engine.contactsync.UpdateNativeContacts) FetchNativeContacts(com.vodafone360.people.engine.contactsync.FetchNativeContacts) DefaultProcessorFactory(com.vodafone360.people.engine.contactsync.DefaultProcessorFactory) BaseSyncProcessor(com.vodafone360.people.engine.contactsync.BaseSyncProcessor) UploadServerContacts(com.vodafone360.people.engine.contactsync.UploadServerContacts) DownloadServerContacts(com.vodafone360.people.engine.contactsync.DownloadServerContacts) Suppress(android.test.suitebuilder.annotation.Suppress)

Aggregations

UpdateNativeContacts (com.vodafone360.people.engine.contactsync.UpdateNativeContacts)5 NativeContactsApi (com.vodafone360.people.engine.contactsync.NativeContactsApi)3 Suppress (android.test.suitebuilder.annotation.Suppress)2 Contact (com.vodafone360.people.datatypes.Contact)1 BaseSyncProcessor (com.vodafone360.people.engine.contactsync.BaseSyncProcessor)1 ContactChange (com.vodafone360.people.engine.contactsync.ContactChange)1 DefaultProcessorFactory (com.vodafone360.people.engine.contactsync.DefaultProcessorFactory)1 DownloadServerContacts (com.vodafone360.people.engine.contactsync.DownloadServerContacts)1 FetchNativeContacts (com.vodafone360.people.engine.contactsync.FetchNativeContacts)1 IContactSyncCallback (com.vodafone360.people.engine.contactsync.IContactSyncCallback)1 UploadServerContacts (com.vodafone360.people.engine.contactsync.UploadServerContacts)1