use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactDetailsTableTest method testContactsMatch.
@MediumTest
public void testContactsMatch() {
final String fnName = "testContactsMatch";
mTestStep = 1;
Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
Log.i(LOG_TAG, "Validates doContactsMatch method");
SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
Contact contact = mTestModule.createDummyContactData();
contact.localContactID = TestModule.generateRandomLong();
startSubTest(fnName, "Creating table");
createTable();
List<NativeIdInfo> detailIdList = new ArrayList<NativeIdInfo>();
assertFalse(ContactDetailsTable.doContactsMatch(contact, contact.localContactID, detailIdList, readableDb));
ServiceStatus status;
for (ContactDetail cd : contact.details) {
cd.localContactID = contact.localContactID;
status = ContactDetailsTable.addContactDetail(cd, true, true, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
}
// assertTrue(ContactDetailsTable.doContactsMatch(contact,
// contact.localContactID, detailIdList, readableDb));
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 testFindNativeContact.
@MediumTest
public void testFindNativeContact() {
final String fnName = "testFindNativeContact";
mTestStep = 1;
Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
startSubTest(fnName, "Creating table");
createTable();
// create contact
Contact contact = new Contact();
contact.synctophone = true;
// add contact to to the ContactsTable
ContactsTable.create(mTestDatabase.getWritableDatabase());
ServiceStatus status = ContactsTable.addContact(contact, readableDb);
assertEquals(ServiceStatus.SUCCESS, status);
// add contact to ContactSummaryTable
ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
status = ContactSummaryTable.addContact(contact, readableDb);
assertEquals(ServiceStatus.SUCCESS, status);
// create and add NameDetail
ContactDetail nameDetail = mTestModule.createDummyDetailsName();
ContactDetail nicknameDetail = mTestModule.createDummyDetailsNickname(nameDetail);
nicknameDetail.localContactID = contact.localContactID;
status = ContactDetailsTable.addContactDetail(nicknameDetail, true, true, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
contact.details.add(nicknameDetail);
// create and add phoneDetail
ContactDetail phoneDetail = new ContactDetail();
phoneDetail.localContactID = contact.localContactID;
phoneDetail.key = ContactDetail.DetailKeys.VCARD_PHONE;
String number = "07967 123456";
phoneDetail.setTel(number, ContactDetail.DetailKeyTypes.CELL);
status = ContactDetailsTable.addContactDetail(phoneDetail, true, true, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
contact.details.add(phoneDetail);
// create and add phoneDetail
ContactDetail emailDetail = new ContactDetail();
emailDetail.localContactID = contact.localContactID;
emailDetail.key = ContactDetail.DetailKeys.VCARD_EMAIL;
emailDetail.setEmail(TestModule.generateRandomString() + "@mail.co.uk", ContactDetail.DetailKeyTypes.HOME);
status = ContactDetailsTable.addContactDetail(emailDetail, true, true, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
contact.details.add(emailDetail);
assertTrue(ContactDetailsTable.findNativeContact(contact, writeableDb));
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 testSyncSetNativeIds.
/*
* test syncNativeIds
*/
public void testSyncSetNativeIds() {
final String fnName = "testSyncSetNativeIds";
mTestStep = 1;
Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
Log.i(LOG_TAG, "Validates syncSetNativeIds details");
SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
startSubTest(fnName, "Creating table");
createTable();
List<NativeIdInfo> nativeIdList = new ArrayList<NativeIdInfo>();
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);
NativeIdInfo nativeIdInfo = new NativeIdInfo();
nativeIdInfo.nativeContactId = TestModule.generateRandomInt();
nativeIdInfo.localId = detail.localDetailID;
nativeIdList.add(nativeIdInfo);
detailsList.add(detail);
}
ServiceStatus status = ContactDetailsTable.syncSetNativeIds(nativeIdList, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
for (int i = 0; i < NUM_OF_CONTACTS; i++) {
ContactDetail fetchedDetail = ContactDetailsTable.fetchDetail(nativeIdList.get(i).localId, readableDb);
assertNotNull(fetchedDetail);
assertEquals(nativeIdList.get(i).nativeContactId, fetchedDetail.nativeContactId);
}
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 getDisplayName.
/**
* Simplified logic in comparison to the real code in ContactSummaryTable.getDisplayNameDetail
* and updateDisplayName which should behave the same way.
* @param contact The contact to search
* @param isMe Is the contact the me contact
* @return The retrieved displayName
*/
private static String getDisplayName(Contact contact, boolean isMe) {
ContactDetail name = null;
name = contact.getContactDetail(ContactDetail.DetailKeys.VCARD_NAME);
if (name != null && name.getName() != null) {
return name.getName().toString();
}
if (isMe) {
return SyncMeDbUtils.ME_PROFILE_DEFAULT_NAME;
}
name = contact.getContactDetail(ContactDetail.DetailKeys.VCARD_ORG);
if (name != null && !TextUtils.isEmpty(name.getValue())) {
return name.getValue();
}
name = contact.getContactDetail(ContactDetail.DetailKeys.VCARD_EMAIL);
if (name != null && !TextUtils.isEmpty(name.getValue())) {
return name.getValue();
}
name = contact.getContactDetail(ContactDetail.DetailKeys.VCARD_PHONE);
if (name != null && !TextUtils.isEmpty(name.getValue())) {
return name.getValue();
}
return ContactDetail.UNKNOWN_NAME;
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactSummaryTest method testDeletingContactDetails.
/**
* Tests deleting a contact detail of an existing contact.
*/
@SmallTest
public void testDeletingContactDetails() {
Log.i(LOG_TAG, "***** EXECUTING testDeletingContactDetails *****");
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);
Log.i(LOG_TAG, "Add a contact detail to the previous contact");
ContactDetail contactDetail = new ContactDetail();
contactDetail.localContactID = contact.localContactID;
final String eMail = "toto@mail.co.uk";
contactDetail.setEmail(eMail, ContactDetail.DetailKeyTypes.HOME);
boolean isMe = false;
assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
Log.i(LOG_TAG, "Delete a contact detail from the previous contact");
assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
}
Aggregations