use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class NowPlusContactDetailsTableTest method testSyncNativeContactChanges.
/*
* test Sync Native Contact Changes
*/
public void testSyncNativeContactChanges() {
final String fnName = "testSyncNativeContactChanges";
mTestStep = 1;
Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
Log.i(LOG_TAG, "Validates sync server native contact details");
SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
startSubTest(fnName, "Creating table");
createTable();
List<ContactDetail> detailsList = new ArrayList<ContactDetail>();
for (int i = 0; i < NUM_OF_CONTACTS; i++) {
ContactDetail detail = new ContactDetail();
detail.localContactID = TestModule.generateRandomLong();
detail.nativeContactId = TestModule.generateRandomInt();
detail.nativeVal1 = TestModule.generateRandomString();
detail.nativeVal2 = TestModule.generateRandomString();
detail.nativeVal3 = TestModule.generateRandomString();
mTestModule.createDummyDetailsData(detail);
ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
detailsList.add(detail);
}
Cursor nat = ContactDetailsTable.syncNativeFetchContactChanges(readableDb, true);
assertEquals(3, nat.getCount());
nat.close();
Cursor cursor = ContactDetailsTable.syncNativeFetchContactChanges(readableDb, false);
assertEquals(cursor.getCount(), ContactDetailsTable.syncNativeFetchNoOfChanges(readableDb));
List<Contact> contactList = new ArrayList<Contact>();
ContactDetailsTable.syncNativeGetNextNewContactDetails(cursor, contactList, NUM_OF_CONTACTS);
for (int i = 0; i < contactList.size(); i++) {
assertTrue(DatabaseHelper.doDetailsMatch(detailsList.get(i), contactList.get(i).details.get(0)));
}
cursor.close();
Log.i(LOG_TAG, "***********************************************");
Log.i(LOG_TAG, fnName + " has completed successfully");
Log.i(LOG_TAG, "***********************************************");
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class NowPlusContactSummaryTest method testAddingContactSummary.
/**
* Tests adding a contact to the contact summary table.
*/
@SmallTest
public void testAddingContactSummary() {
Log.i(LOG_TAG, "***** EXECUTING testAddingContactSummary *****");
Log.i(LOG_TAG, "Create ContactSummaryTable");
ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
final Contact contact = mTestModule.createDummyContactData();
contact.localContactID = new Long(10);
ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class NowPlusContactSummaryTest method testRemovingContactSummary.
/**
* Tests removing a contact summary.
*/
@SmallTest
public void testRemovingContactSummary() {
Log.i(LOG_TAG, "***** EXECUTING testRemovingContactSummary *****");
Log.i(LOG_TAG, "Create ContactSummaryTable");
ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
Log.i(LOG_TAG, "Add a contact to ContactSummaryTable");
final Contact contact = mTestModule.createDummyContactData();
contact.localContactID = new Long(10);
contact.nativeContactId = new Integer(11);
ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
Log.i(LOG_TAG, "Fetching a ContactSummary from ContactSummaryTable to check that it exists");
ContactSummary contactSummary = new ContactSummary();
ServiceStatus serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
assertEquals(ServiceStatus.SUCCESS, serviceStatus);
Log.i(LOG_TAG, "Delete the contact from ContactSummaryTable");
serviceStatus = ContactSummaryTable.deleteContact(contact.localContactID, mTestDatabase.getWritableDatabase());
assertEquals(ServiceStatus.SUCCESS, serviceStatus);
Log.i(LOG_TAG, "Try to fetching a ContactSummary from ContactSummaryTable to check that it is not possible anymore");
contactSummary = new ContactSummary();
serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
assertTrue(ServiceStatus.SUCCESS != serviceStatus);
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class NowPlusContactSummaryTest method testAddingContactDetails.
/**
* Tests adding a contact detail to an existing contact.
*/
@SmallTest
public void testAddingContactDetails() {
Log.i(LOG_TAG, "***** EXECUTING testAddingContactDetails *****");
Log.i(LOG_TAG, "Create ContactSummaryTable");
ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
Log.i(LOG_TAG, "Create also a ContactDetailsTable");
ContactDetailsTable.create(mTestDatabase.getWritableDatabase());
Log.i(LOG_TAG, "Add a contact to ContactSummaryTable");
final Contact contact = mTestModule.createDummyContactData();
contact.localContactID = new Long(10);
contact.nativeContactId = new Integer(11);
ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
Log.i(LOG_TAG, "Add a contact detail to the previous contact");
final ContactDetail contactDetail = new ContactDetail();
contactDetail.localContactID = contact.localContactID;
boolean isMe = false;
contactDetail.setEmail("test@example.com", ContactDetail.DetailKeyTypes.HOME);
assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
}
use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.
the class NowPlusContactSummaryTest method copyContact.
/**
* Creates a "light" copy of a Contact.
*
* @param contact the contact to copy
* @return the copy of the provided contact
*/
private Contact copyContact(Contact contact) {
final Contact newContact = new Contact();
// using Copy() but seems deprecated, may need to be changed later
// newContact.Copy(contact);
newContact.friendOfMine = contact.friendOfMine;
newContact.synctophone = contact.synctophone;
newContact.localContactID = contact.localContactID;
newContact.nativeContactId = contact.nativeContactId;
return newContact;
}
Aggregations