use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactDetailsTableTest method testSyncServerFetchContactChanges.
/*
* test syncServerFetchContactChanges
*/
public void testSyncServerFetchContactChanges() {
final String fnName = "testSyncServerFetchContactChanges";
mTestStep = 1;
Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
Log.i(LOG_TAG, "Validates syncServerFetchContactChanges 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();
mTestModule.createDummyDetailsData(detail);
ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
detailsList.add(detail);
}
Cursor cursor = ContactDetailsTable.syncServerFetchContactChanges(readableDb, true);
assertEquals(NUM_OF_CONTACTS, cursor.getCount());
Cursor cursorOldContacts = ContactDetailsTable.syncServerFetchContactChanges(readableDb, false);
assertEquals(0, cursorOldContacts.getCount());
cursorOldContacts.close();
List<Contact> contactList = new ArrayList<Contact>();
ContactDetailsTable.syncServerGetNextNewContactDetails(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.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactDetailsTableTest method testSyncServerFetchNoOfChanges.
/*
* test syncServerFetchNoOfChanges
*/
public void testSyncServerFetchNoOfChanges() {
final String fnName = "testSyncServerFetchNoOfChanges";
mTestStep = 1;
Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
Log.i(LOG_TAG, "Validates syncServerFetchContactChanges 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.serverContactId = TestModule.generateRandomLong();
mTestModule.createDummyDetailsData(detail);
ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
detailsList.add(detail);
}
Cursor cursor = ContactDetailsTable.syncServerFetchContactChanges(readableDb, false);
assertEquals(cursor.getCount(), ContactDetailsTable.syncServerFetchNoOfChanges(readableDb));
for (ContactDetail contactDetail : detailsList) {
Long serverContactId = TestModule.fetchSyncServerId(contactDetail.localDetailID, readableDb);
assertEquals(contactDetail.serverContactId, serverContactId);
}
Log.i(LOG_TAG, "***********************************************");
Log.i(LOG_TAG, fnName + " has completed successfully");
Log.i(LOG_TAG, "***********************************************");
}
use of com.vodafone360.people.datatypes.ContactDetail 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.ContactDetail 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.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactSummaryTest method testUpdateDisplayName.
/**
* Tests updating a contact's display name.
*/
@SmallTest
public void testUpdateDisplayName() {
Log.i(LOG_TAG, "***** EXECUTING testtestUpdateDisplayName *****");
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 = new Contact();
contact.localContactID = new Long(10);
contact.nativeContactId = new Integer(11);
ServiceStatus serviceStatus = ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
assertEquals(ServiceStatus.SUCCESS, serviceStatus);
// Name
ContactDetail nameDetail = new ContactDetail();
nameDetail.localContactID = contact.localContactID;
VCardHelper.Name name = new VCardHelper.Name();
name.firstname = "John";
name.surname = "Doe";
nameDetail.setName(name);
// ORG
ContactDetail orgDetail = new ContactDetail();
nameDetail.localContactID = contact.localContactID;
VCardHelper.Organisation org = new VCardHelper.Organisation();
org.name = "VF";
org.unitNames.add("Dev");
orgDetail.setOrg(org, ContactDetail.DetailKeyTypes.WORK);
ContactDetail emailDetail = new ContactDetail();
emailDetail.localContactID = contact.localContactID;
emailDetail.setEmail("dev@vf.com", ContactDetail.DetailKeyTypes.WORK);
ContactDetail phoneDetail = new ContactDetail();
phoneDetail.localContactID = contact.localContactID;
phoneDetail.setTel("+123456789", ContactDetail.DetailKeyTypes.HOME);
contact.details.add(nameDetail);
contact.details.add(orgDetail);
contact.details.add(emailDetail);
contact.details.add(phoneDetail);
// Loop for number of details + 1
final int numLoopCycles = contact.details.size() + 1;
int loopCycles = numLoopCycles;
boolean isMe = false;
while (loopCycles-- > 0) {
assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
if (contact.details.size() > 0) {
contact.details.remove(0);
}
}
final Contact meContact = new Contact();
meContact.localContactID = new Long(11);
meContact.nativeContactId = new Integer(12);
isMe = true;
Log.i(LOG_TAG, "Add me Contact to ContactSummaryTable");
serviceStatus = ContactSummaryTable.addContact(meContact, mTestDatabase.getWritableDatabase());
assertEquals(ServiceStatus.SUCCESS, serviceStatus);
meContact.details.add(nameDetail);
meContact.details.add(orgDetail);
meContact.details.add(emailDetail);
meContact.details.add(phoneDetail);
loopCycles = numLoopCycles;
while (loopCycles-- > 0) {
assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
if (contact.details.size() > 0) {
contact.details.remove(0);
}
}
}
Aggregations