use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class DownloadServerContactsTest method reportBackWithDeletedDetails.
private void reportBackWithDeletedDetails(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportBackWithDeletedDetails");
Integer pageNo = mProcessor.testGetPageFromReqId(reqId);
int pageSize = mProcessor.getDownloadPageSize();
assertTrue(pageNo != null);
assertEquals(Integer.valueOf(mPageCount), pageNo);
ContactChanges contactChanges = new ContactChanges();
data.add(contactChanges);
contactChanges.mCurrentServerVersion = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionBefore = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionAfter = CURRENT_SERVER_VERSION;
contactChanges.mVersionAnchor = CURRENT_SERVER_VERSION;
assertTrue(pageSize > 0);
if (pageSize > 0) {
contactChanges.mNumberOfPages = 1 + mPageCount + (mItemCount / pageSize);
}
int noOfContacts = Math.min(pageSize, mItemCount);
for (int i = 0; i < noOfContacts; i++) {
Contact curContact = new Contact();
curContact.contactID = FIRST_MODIFIED_CONTACT_ID + mItemCount - 1;
contactChanges.mContacts.add(curContact);
ContactDetail delDetail1 = new ContactDetail();
delDetail1.key = ContactDetail.DetailKeys.VCARD_NAME;
delDetail1.deleted = true;
ContactDetail delDetail2 = new ContactDetail();
delDetail2.key = ContactDetail.DetailKeys.VCARD_NICKNAME;
delDetail2.deleted = true;
ContactDetail delDetail3 = new ContactDetail();
delDetail3.key = ContactDetail.DetailKeys.VCARD_EMAIL;
delDetail3.unique_id = NEW_EMAIL_DETAIL_ID + mItemCount - 1;
delDetail3.deleted = true;
curContact.details.add(delDetail1);
curContact.details.add(delDetail2);
curContact.details.add(delDetail3);
mItemCount--;
}
mPageCount++;
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
nextState(State.IDLE);
}
}
use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class DownloadServerContactsTest method reportBackWithNewContacts.
private void reportBackWithNewContacts(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportBackWithNewContacts");
Integer pageNo = mProcessor.testGetPageFromReqId(reqId);
int pageSize = mProcessor.getDownloadPageSize();
assertTrue(pageNo != null);
assertEquals(Integer.valueOf(mPageCount), pageNo);
ContactChanges contactChanges = new ContactChanges();
data.add(contactChanges);
contactChanges.mCurrentServerVersion = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionBefore = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionAfter = CURRENT_SERVER_VERSION;
contactChanges.mVersionAnchor = CURRENT_SERVER_VERSION;
assertTrue(pageSize > 0);
if (pageSize > 0) {
contactChanges.mNumberOfPages = 1 + mPageCount + (mItemCount / pageSize);
}
int noOfContacts = Math.min(pageSize, mItemCount);
for (int i = 0; i < noOfContacts; i++) {
Contact newContact = mTestModule.createDummyContactData();
if (mLastNewContact == null) {
mLastNewContact = newContact;
}
newContact.contactID = FIRST_MODIFIED_CONTACT_ID + mItemCount - 1;
newContact.userID = generateTestUserID(newContact.contactID);
ContactDetail detail1 = new ContactDetail();
detail1.key = ContactDetail.DetailKeys.VCARD_PHONE;
detail1.unique_id = OLD_PHONE_DETAIL_ID + mItemCount - 1;
detail1.value = OLD_PHONE_DETAIL_VALUE;
newContact.details.add(detail1);
for (int j = 0; j < newContact.details.size(); j++) {
ContactDetail detail = newContact.details.get(j);
switch(detail.key) {
case VCARD_PHONE:
case VCARD_EMAIL:
if (detail.unique_id == null) {
detail.unique_id = ALT_PHONE_DETAIL_ID + j;
}
break;
}
}
contactChanges.mContacts.add(newContact);
mItemCount--;
}
mPageCount++;
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
nextState(State.IDLE);
}
}
use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class DownloadServerContactsTest method reportBackWithDeletedContacts.
private void reportBackWithDeletedContacts(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportBackWithDeletedContacts");
Integer pageNo = mProcessor.testGetPageFromReqId(reqId);
int pageSize = mProcessor.getDownloadPageSize();
assertTrue(pageNo != null);
assertEquals(Integer.valueOf(mPageCount), pageNo);
ContactChanges contactChanges = new ContactChanges();
data.add(contactChanges);
contactChanges.mCurrentServerVersion = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionBefore = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionAfter = CURRENT_SERVER_VERSION;
contactChanges.mVersionAnchor = CURRENT_SERVER_VERSION;
assertTrue(pageSize > 0);
if (pageSize > 0) {
contactChanges.mNumberOfPages = 1 + mPageCount + (mItemCount / pageSize);
}
int noOfContacts = Math.min(pageSize, mItemCount);
for (int i = 0; i < noOfContacts; i++) {
Contact deletedContact = new Contact();
deletedContact.contactID = FIRST_MODIFIED_CONTACT_ID + mItemCount - 1;
deletedContact.deleted = true;
contactChanges.mContacts.add(deletedContact);
mItemCount--;
}
mPageCount++;
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
nextState(State.IDLE);
}
}
use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class NowPlusDatatypesTests method testContactChanges.
public void testContactChanges() {
List<Contact> contacts = new ArrayList<Contact>();
long currentServerVersion = 1;
long versionAnchor = 2;
int numberOfPages = 3;
long serverRevisionBefore = 4;
long serverRevisionAfter = 5;
Hashtable<String, Object> hashUserProfile = new Hashtable<String, Object>();
ContactChanges input = new ContactChanges();
input.mContacts = contacts;
input.mCurrentServerVersion = ((Long) currentServerVersion).intValue();
input.mVersionAnchor = ((Long) versionAnchor).intValue();
input.mNumberOfPages = numberOfPages;
input.mServerRevisionBefore = ((Long) serverRevisionBefore).intValue();
input.mServerRevisionAfter = ((Long) serverRevisionAfter).intValue();
input.mUserProfile = UserProfile.createFromHashtable(hashUserProfile);
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put("contact", contacts);
hash.put("currentserverrevision", currentServerVersion);
hash.put("serverrevisionanchor", versionAnchor);
hash.put("numpages", numberOfPages);
hash.put("serverrevisionbefore", serverRevisionBefore);
hash.put("serverrevisionafter", serverRevisionAfter);
hash.put("userprofile", hashUserProfile);
ContactChanges helper = new ContactChanges();
ContactChanges output = helper.createFromHashtable(hash);
assertEquals(input.getType(), output.getType());
assertEquals(input.toString(), output.toString());
assertEquals(input.mContacts, output.mContacts);
assertEquals(input.mCurrentServerVersion, output.mCurrentServerVersion);
assertEquals(input.mNumberOfPages, output.mNumberOfPages);
assertEquals(input.mServerRevisionBefore, output.mServerRevisionBefore);
assertEquals(input.mServerRevisionAfter, output.mServerRevisionAfter);
}
use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class UploadServerContactsTest method reportModifyContactSuccess.
private void reportModifyContactSuccess(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportModifyContactSuccess");
mProcessor.verifyModifyDetailsState();
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);
assertTrue(actualContact.contactID != null);
assertEquals(null, actualContact.aboutMe);
assertEquals(null, actualContact.profilePath);
assertEquals(null, actualContact.deleted);
assertEquals(null, actualContact.friendOfMine);
assertEquals(null, actualContact.gender);
assertEquals(null, actualContact.groupList);
assertEquals(null, actualContact.sources);
assertEquals(null, actualContact.synctophone);
assertEquals(null, actualContact.updated);
assertEquals(null, actualContact.userID);
assertEquals(2, actualContact.details.size());
// Modified
ContactDetail modDetail = actualContact.details.get(0);
// detail
// always
// first
ContactDetail newDetail = actualContact.details.get(1);
assertEquals(NEW_DETAIL_VALUE, newDetail.value);
assertEquals(NEW_DETAIL_KEY, newDetail.key);
assertEquals(NEW_DETAIL_TYPE, newDetail.keyType);
assertEquals(MOD_DETAIL_VALUE, modDetail.value);
assertEquals(MOD_DETAIL_KEY, modDetail.key);
assertEquals(MOD_DETAIL_TYPE, modDetail.keyType);
mReplyContact = new Contact();
mReplyContact.contactID = actualContact.contactID;
mReplyContact.userID = generateTestUserID(mReplyContact.contactID);
ContactDetail replyDetail1 = new ContactDetail();
ContactDetail replyDetail2 = new ContactDetail();
replyDetail1.key = modDetail.key;
replyDetail1.unique_id = modDetail.unique_id;
replyDetail2.key = newDetail.key;
replyDetail2.unique_id = newDetail.localDetailID + 2;
mReplyContact.details.add(replyDetail1);
mReplyContact.details.add(replyDetail2);
contactChanges.mContacts.add(mReplyContact);
}
mItemCount -= contactChangeList.size();
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
nextState(State.IDLE);
}
}
Aggregations