use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class NativeExporterTest method testMultipleExportsToNativeWithNewContacts.
/**
* Tests multiple exports to native with only new contacts.
*/
@Suppress
public void testMultipleExportsToNativeWithNewContacts() {
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));
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class NativeImporterTest method testMultipleImportsFromNativeWithUpdatedContact_updatedDetails.
/**
* Tests multiple imports from native with an updated contact via updated details.
*/
public void testMultipleImportsFromNativeWithUpdatedContact_updatedDetails() {
final NativeContactsApiMockup nativeMockup = new NativeContactsApiMockup();
final PeopleContactsApiMockup peopleMockup = new PeopleContactsApiMockup(null);
// add new contacts on native side
feedNativeContactsApi(nativeMockup, 20, null);
long[] nativeIds = nativeMockup.getContactIds(null);
assertEquals(20, nativeIds.length);
// import the new contacts
runNativeImporter(nativeMockup, peopleMockup);
// compare contacts on both sides
assertTrue(compareNativeAndPeopleContactsList(nativeMockup, null, peopleMockup));
// pick an existing contact
final ContactChange[] originalContact = nativeMockup.getContact(10);
// modify its details
for (int i = 0; i < originalContact.length; i++) {
final ContactChange originalChange = originalContact[i];
originalContact[i] = alterContactChangeValue(originalChange, originalChange.getValue() + "x9x");
}
nativeMockup.setContact(10, originalContact);
// import the new contacts
runNativeImporter(nativeMockup, peopleMockup);
// compare contacts on both sides
assertTrue(compareNativeAndPeopleContactsList(nativeMockup, null, peopleMockup));
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class NativeImporterTest method addDetails.
/**
* Adds details to the provided contact.
*
* @param contact
* @return
*/
private ContactChange[] addDetails(NativeContactsApiMockup ncam, ContactChange[] contact) {
long nativeId = contact[0].getNabContactId();
int index = contact.length;
// create the new Contact
ContactChange[] newContact = new ContactChange[contact.length + 2];
// copy original info into it
System.arraycopy(contact, 0, newContact, 0, contact.length);
// add extra details
newContact[index] = new ContactChange(ContactChange.KEY_VCARD_EMAIL, "xxxxx@xxxxx.xx", ContactChange.FLAG_WORK);
newContact[index].setNabContactId(nativeId);
newContact[index].setNabDetailId(ncam.getAndIncNabDetailId());
index++;
newContact[index] = new ContactChange(ContactChange.KEY_VCARD_PHONE, "+9912345678", ContactChange.FLAG_WORK);
newContact[index].setNabContactId(nativeId);
newContact[index].setNabDetailId(ncam.getAndIncNabDetailId());
index++;
return newContact;
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class PeopleContactsApiTest method testGetContact.
/**
* Tests the getContact() method.
*/
public void testGetContact() {
PeopleContactsApi pca = new PeopleContactsApi(mDatabaseHelper);
// the database is empty, it shall not return any contact
assertNull(pca.getContact(10));
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class PeopleContactsApiTest method testUpdateGetNativeContact.
/**
* Tests the updateNativeContact() and getContact() methods.
*/
@Suppress
public void testUpdateGetNativeContact() {
final long NATIVE_ID = 15;
PeopleContactsApi pca = new PeopleContactsApi(mDatabaseHelper);
// the database is empty, it shall not return any ids
assertNull(pca.getNativeContactsIds());
// let's add a contact
ContactChange[] contact = filterContactChanges(ContactChangeHelper.randomContact(ContactChange.INVALID_ID, ContactChange.INVALID_ID, NATIVE_ID));
assertTrue(pca.addNativeContact(contact));
// check that it exists
long[] ids = pca.getNativeContactsIds();
assertEquals(1, ids.length);
assertEquals(NATIVE_ID, ids[0]);
// perform some updates to the contact
final ContactChange[] updatedDetails = ContactChangeHelper.randomContactUpdate(contact);
pca.updateNativeContact(updatedDetails);
// get the contact back
final ContactChange[] savedContact = pca.getContact(NATIVE_ID);
assertNotNull(savedContact);
// check that the needed updates have been performed
checkContactUpdates(contact, updatedDetails, savedContact);
}
Aggregations