use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class NowPlusContactDetailsTableTest method testFetchContactDetailsForNative.
public void testFetchContactDetailsForNative() {
final String fnName = "testFetchContactDetailsForNative";
mTestStep = 1;
Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
startSubTest(fnName, "Creating table");
createTable();
Contact contact = new Contact();
contact.localContactID = TestModule.generateRandomLong();
// create and add NameDetail
ContactDetail nameDetail = mTestModule.createDummyDetailsName();
ContactDetail nicknameDetail = mTestModule.createDummyDetailsNickname(nameDetail);
nicknameDetail.localContactID = contact.localContactID;
nicknameDetail.nativeContactId = TestModule.generateRandomInt();
ServiceStatus status = ContactDetailsTable.addContactDetail(nicknameDetail, true, true, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
List<ContactDetail> addedDetails = new ArrayList<ContactDetail>();
addedDetails.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);
// phoneDetail.nativeContactId = mTestModule.GenerateRandomInt();
phoneDetail.nativeContactId = nicknameDetail.nativeContactId;
status = ContactDetailsTable.addContactDetail(phoneDetail, true, true, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
addedDetails.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);
// emailDetail.nativeContactId = mTestModule.GenerateRandomInt();
emailDetail.nativeContactId = nicknameDetail.nativeContactId;
status = ContactDetailsTable.addContactDetail(emailDetail, true, true, writeableDb);
assertEquals(ServiceStatus.SUCCESS, status);
addedDetails.add(emailDetail);
ContactDetail.DetailKeys[] keyList = { ContactDetail.DetailKeys.VCARD_NICKNAME, ContactDetail.DetailKeys.VCARD_PHONE, ContactDetail.DetailKeys.VCARD_EMAIL };
List<ContactDetail> detailList = new ArrayList<ContactDetail>();
assertTrue(ContactDetailsTable.fetchContactDetailsForNative(detailList, keyList, false, 0, MAX_MODIFY_NOWPLUS_DETAILS_COUNT, readableDb));
for (int i = 0; i < detailList.size(); i++) {
assertTrue(DatabaseHelper.doDetailsMatch(detailList.get(i), addedDetails.get(i)));
}
Log.i(LOG_TAG, "***********************************************");
Log.i(LOG_TAG, fnName + " has completed successfully");
Log.i(LOG_TAG, "***********************************************");
}
use of com.vodafone360.people.service.ServiceStatus 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.service.ServiceStatus 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);
}
}
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class NowPlusContactSummaryTest method testModifyingContactDetails.
/**
* Tests modifying a contact detail of an existing contact.
*/
@SmallTest
public void testModifyingContactDetails() {
Log.i(LOG_TAG, "***** EXECUTING testModifyingContactDetails *****");
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;
contactDetail.setEmail("toto@mail.co.uk", ContactDetail.DetailKeyTypes.HOME);
boolean isMe = false;
assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
Log.i(LOG_TAG, "Modify a contact detail to the previous contact");
contactDetail = new ContactDetail();
contactDetail.localContactID = contact.localContactID;
final String eMail2 = "toto2@mail.co.uk";
contactDetail.setEmail(eMail2, ContactDetail.DetailKeyTypes.HOME);
assertEquals(getDisplayName(contact, isMe), ContactSummaryTable.updateContactDisplayName(contact, mTestDatabase.getWritableDatabase(), isMe));
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class NowPlusContactSummaryTest method testModifyingingContactSummary.
/**
* Tests modifying a contact summary.
*/
@SmallTest
public void testModifyingingContactSummary() {
Log.i(LOG_TAG, "***** EXECUTING testModifyingingContactSummary *****");
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");
ContactSummary contactSummary = new ContactSummary();
ServiceStatus serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
assertEquals(ServiceStatus.SUCCESS, serviceStatus);
compareContactWithContactSummary(contact, contactSummary);
Log.i(LOG_TAG, "Modify a contact");
final Contact contact2 = copyContact(contact);
contact2.synctophone = !contact.synctophone;
serviceStatus = ContactSummaryTable.modifyContact(contact2, mTestDatabase.getWritableDatabase());
assertEquals(ServiceStatus.SUCCESS, serviceStatus);
Log.i(LOG_TAG, "Fetching a ContactSummary from ContactSummaryTable");
contactSummary = new ContactSummary();
serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
assertEquals(ServiceStatus.SUCCESS, serviceStatus);
// by doing so, we should get back to the original if it was correctly
// modified
contactSummary.synctophone = !contactSummary.synctophone;
compareContactWithContactSummary(contact, contactSummary);
}
Aggregations