use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class SyncMeEngineTest method testUpdateMeProfileContactRequest.
@MediumTest
// framework needs to be fixed.
@Suppress
public void testUpdateMeProfileContactRequest() {
setUpContactSyncMeEngineTestFramework();
// re-test with valid Me profile
Contact meProfile = mTestModule.createDummyContactData();
assertEquals("Could not access db", ServiceStatus.SUCCESS, SyncMeDbUtils.setMeProfile(mApplication.getDatabase(), meProfile));
mEngine.addUpdateMeProfileContactRequest();
assertEquals("Expected SUCCESS, not timeout", ServiceStatus.SUCCESS, mEngineTester.waitForEvent());
Object data = mEngineTester.data();
assertTrue(data == null);
Log.i(LOG_TAG, "**** testGetActivities (SUCCESS) ****\n");
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class FetchNativeContacts method onTimeoutEvent.
@Override
public void onTimeoutEvent() {
LogUtils.logD("FetchNativeContacts.onTimeoutEvent()");
// call the tick method of the NativeImporter
final boolean isDone = mNativeImporter.tick();
// get the index of the last processed id
final int position = mNativeImporter.getPosition();
// get the total count of ids to process
final int total = mNativeImporter.getCount();
// get the percentage out of position and total count
final int percentage = (total != 0) ? ((position * 100) / total) : 100;
LogUtils.logD("FetchNativeContacts.onTimeoutEvent() - pos=" + position + ", total=" + total + ", percentage=" + percentage);
// check the NativeImporter progress
if (!isDone) {
// report the current progress
// pass an empty name as currently the last processed contact name by the NativeImporter can't be known
setProgress("", percentage, position, total);
// yield some time to the other engines and request to be called back immediately
setTimeout(0);
} else {
final ServiceStatus status = mNativeImporter.getResult() == NativeImporter.RESULT_OK ? ServiceStatus.SUCCESS : ServiceStatus.ERROR_UNKNOWN;
LogUtils.logD("FetchNativeContacts.onTimeoutEvent() - complete(" + status + ")");
setProgress("", percentage, position, total);
complete(status);
}
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class UploadServerContactsTest method reportDeleteContactDetailSuccess.
private void reportDeleteContactDetailSuccess(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportDeleteContactDetailSuccess");
mProcessor.verifyDeleteDetailsState();
Contact contact = new Contact();
mProcessor.testFetchContactDetailDeleteList(contact);
assertEquals(2, contact.details.size());
assertEquals(ContactDetail.DetailKeys.VCARD_NAME, contact.details.get(0).key);
assertEquals(ContactDetail.DetailKeys.VCARD_PHONE, contact.details.get(1).key);
ContactDetailDeletion contactDetailDeletion = new ContactDetailDeletion();
contactDetailDeletion.mServerVersionAfter = 1;
contactDetailDeletion.mServerVersionBefore = 0;
data.add(contactDetailDeletion);
contactDetailDeletion.mContactId = contact.contactID.intValue();
contactDetailDeletion.mDetails = new ArrayList<ContactDetail>();
for (ContactDetail detail : contact.details) {
ContactDetail tempDetail = new ContactDetail();
tempDetail.key = detail.key;
tempDetail.unique_id = detail.unique_id;
contactDetailDeletion.mDetails.add(tempDetail);
}
mItemCount--;
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
nextState(State.IDLE);
}
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class UploadServerContactsTest method testRunWithAddDeleteContactDetailChange.
@Suppress
public // Breaks tests
void testRunWithAddDeleteContactDetailChange() {
final String fnName = "testRunWithAddDeleteContactDetailChange";
Log.i(LOG_TAG, "***** EXECUTING " + fnName + " *****");
mTestStep = 1;
startSubTest(fnName, "Checking change list is empty");
long noOfChanges = ContactChangeLogTable.fetchNoOfContactDetailChanges(null, mDb.getReadableDatabase());
assertEquals(0, noOfChanges);
noOfChanges = ContactDetailsTable.syncNativeFetchNoOfChanges(mDb.getReadableDatabase());
assertEquals(0, noOfChanges);
startSubTest(fnName, "Adding test contact to database");
Contact contact = mTestModule.createDummyContactData();
contact.contactID = TestModule.generateRandomLong();
contact.userID = generateTestUserID(contact.contactID);
List<Contact> contactList = new ArrayList<Contact>();
contactList.add(contact);
ServiceStatus status = mDb.syncAddContactList(contactList, false, false);
assertEquals(ServiceStatus.SUCCESS, status);
startSubTest(fnName, "Adding new detail to contact");
ContactDetail newDetail = new ContactDetail();
newDetail.value = NEW_DETAIL_VALUE;
newDetail.key = NEW_DETAIL_KEY;
newDetail.keyType = NEW_DETAIL_TYPE;
newDetail.localContactID = contact.localContactID;
status = mDb.addContactDetail(newDetail);
assertEquals(ServiceStatus.SUCCESS, status);
startSubTest(fnName, "Deleting contact detail without unique ID");
status = mDb.deleteContactDetail(contact.details.get(0).localDetailID);
assertEquals(ServiceStatus.SUCCESS, status);
startSubTest(fnName, "Deleting contact detail with unique ID");
status = mDb.deleteContactDetail(newDetail.localDetailID);
assertEquals(ServiceStatus.SUCCESS, status);
startSubTest(fnName, "Running processor");
runProcessor(1, State.DELETE_CONTACT_DETAIL_LIST);
assertEquals(State.IDLE, mState);
noOfChanges = ContactChangeLogTable.fetchNoOfContactDetailChanges(null, mDb.getReadableDatabase());
assertEquals(0, noOfChanges);
noOfChanges = ContactDetailsTable.syncNativeFetchNoOfChanges(mDb.getReadableDatabase());
assertEquals(0, noOfChanges);
startSubTest(fnName, "Running processor with no contact changes");
runProcessor(0, State.IDLE);
Log.i(LOG_TAG, "*************************************************************************");
Log.i(LOG_TAG, fnName + " has completed successfully");
Log.i(LOG_TAG, "*************************************************************************");
Log.i(LOG_TAG, "");
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class UploadServerContactsTest method reportBackAddContactSuccess.
private void reportBackAddContactSuccess(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportBackAddContactSuccess");
mProcessor.verifyNewContactsState();
List<Contact> contactChangeList = new ArrayList<Contact>();
mProcessor.testFetchContactChangeList(contactChangeList);
assertEquals(Math.min(mItemCount, mProcessor.testGetPageSize()), contactChangeList.size());
ContactChanges contactChanges = new ContactChanges();
contactChanges.mServerRevisionAfter = 1;
contactChanges.mServerRevisionBefore = 0;
data.add(contactChanges);
for (int i = 0; i < contactChangeList.size(); i++) {
Contact actualContact = contactChangeList.get(i);
Contact expectedContact = new Contact();
ServiceStatus status = mDb.fetchContact(actualContact.localContactID, expectedContact);
assertEquals(ServiceStatus.SUCCESS, status);
assertEquals(expectedContact.details.size(), actualContact.details.size());
assertEquals(null, actualContact.aboutMe);
assertEquals(null, actualContact.profilePath);
assertEquals(null, actualContact.contactID);
assertEquals(null, actualContact.deleted);
assertEquals(null, actualContact.friendOfMine);
assertEquals(null, actualContact.gender);
assertEquals(null, actualContact.groupList);
assertEquals(null, actualContact.sources);
assertEquals(expectedContact.synctophone, actualContact.synctophone);
assertEquals(null, actualContact.updated);
assertEquals(null, actualContact.userID);
final ListIterator<ContactDetail> itActDetails = actualContact.details.listIterator();
for (ContactDetail expDetail : expectedContact.details) {
ContactDetail actDetail = itActDetails.next();
assertTrue(DatabaseHelper.doDetailsMatch(expDetail, actDetail));
assertFalse(DatabaseHelper.hasDetailChanged(expDetail, actDetail));
}
generateReplyContact(expectedContact);
contactChanges.mContacts.add(mReplyContact);
}
mItemCount -= contactChangeList.size();
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
mInitialCount = mInitialContactGroupCount;
nextState(State.ADD_NEW_GROUP_LIST);
}
}
Aggregations