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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations