use of com.vodafone360.people.datatypes.ContactDetail 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.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactsTest method testAddDeleteContactsDetails.
@MediumTest
public void testAddDeleteContactsDetails() {
Log.i(LOG_TAG, "***** EXECUTING testAddDeleteContactsDetails *****");
Log.i(LOG_TAG, "Test contact functionality (add delete contacts details)");
Log.i(LOG_TAG, "Test 1a: Initialise test environment and load database");
assertTrue(initialise());
Log.i(LOG_TAG, "Test 1b: Remove user data");
mDatabaseHelper.removeUserData();
ServiceStatus status = mTestUtility.waitForEvent(WAIT_EVENT_TIMEOUT_MS, DbTestUtility.CONTACTS_INT_EVENT_MASK);
assertEquals(ServiceStatus.SUCCESS, status);
Log.i(LOG_TAG, "Test 1c: Add " + NUM_OF_CONTACTS + " random contacts");
// add contacts and check if added contacts are the same as fetched
Contact[] inputContacts = new Contact[NUM_OF_CONTACTS];
Contact addedContact = new Contact();
for (int i = 0; i < NUM_OF_CONTACTS; i++) {
inputContacts[i] = mTestModule.createDummyContactData();
status = mDatabaseHelper.addContact(inputContacts[i]);
assertEquals(ServiceStatus.SUCCESS, status);
status = mDatabaseHelper.fetchContact(inputContacts[i].localContactID, addedContact);
assertEquals(ServiceStatus.SUCCESS, status);
assertTrue(TestModule.doContactsMatch(addedContact, inputContacts[i]));
}
Log.i(LOG_TAG, "Test 1d: Delete contacts detatils and check if deletion was correct");
for (int i = 0; i < inputContacts.length; i++) {
for (int j = 0; j < inputContacts[i].details.size(); j++) {
ContactDetail detail = inputContacts[i].details.get(j);
status = mDatabaseHelper.deleteContactDetail(detail.localDetailID);
assertEquals(ServiceStatus.SUCCESS, status);
}
// check if deletion works good
Contact modifiedContact = new Contact();
status = mDatabaseHelper.fetchContact(inputContacts[i].localContactID, modifiedContact);
assertEquals(ServiceStatus.SUCCESS, status);
assertTrue(TestModule.doContactsMatch(modifiedContact, inputContacts[i]));
}
shutdown();
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactsTest method testSyncAddContactDetailList.
@SmallTest
public void testSyncAddContactDetailList() {
Log.i(LOG_TAG, "***** EXECUTING testSyncAddContactDetailList *****");
Log.i(LOG_TAG, "Test contact add sync contact detail list");
Log.i(LOG_TAG, "Test 1a: Initialise test environment and load database");
assertTrue(initialise());
Log.i(LOG_TAG, "Test 1b: Remove user data");
mDatabaseHelper.removeUserData();
assertEquals(ServiceStatus.SUCCESS, mTestUtility.waitForEvent(WAIT_EVENT_TIMEOUT_MS, DbTestUtility.CONTACTS_INT_EVENT_MASK));
// add contacts and check if added contacts are the same as fetched
Contact addedContact = new Contact();
assertEquals(ServiceStatus.SUCCESS, mDatabaseHelper.addContact(addedContact));
ContactDetail cd = new ContactDetail();
mTestModule.createDummyDetailsData(cd);
cd.localContactID = addedContact.localContactID;
cd.nativeContactId = TestModule.generateRandomInt();
cd.nativeDetailId = TestModule.generateRandomInt();
cd.nativeVal1 = TestModule.generateRandomString();
cd.nativeVal2 = TestModule.generateRandomString();
cd.nativeVal3 = TestModule.generateRandomString();
List<ContactDetail> detailList = new ArrayList<ContactDetail>();
detailList.add(cd);
assertEquals(ServiceStatus.SUCCESS, mDatabaseHelper.syncAddContactDetailList(detailList, false, false));
Contact modifiedContact = new Contact();
assertEquals(ServiceStatus.SUCCESS, mDatabaseHelper.fetchContact(addedContact.localContactID, modifiedContact));
for (ContactDetail fetchedDetail : modifiedContact.details) {
for (ContactDetail contactDetail : detailList) {
if (fetchedDetail.key == contactDetail.key) {
assertEquals(contactDetail.nativeVal1, fetchedDetail.nativeVal1);
assertEquals(contactDetail.nativeVal2, fetchedDetail.nativeVal2);
assertEquals(contactDetail.nativeVal3, fetchedDetail.nativeVal3);
}
}
}
shutdown();
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactsTest method testAddModifyContacts.
@MediumTest
public void testAddModifyContacts() {
Log.i(LOG_TAG, "***** EXECUTING testAddModifyContacts *****");
Log.i(LOG_TAG, "Test contact functionality (add/modify details contacts)");
Log.i(LOG_TAG, "Test 1a: Initialise test environment and load database");
assertTrue(initialise());
Log.i(LOG_TAG, "Test 1b: Remove user data");
mDatabaseHelper.removeUserData();
ServiceStatus status = mTestUtility.waitForEvent(WAIT_EVENT_TIMEOUT_MS, DbTestUtility.CONTACTS_INT_EVENT_MASK);
assertEquals(ServiceStatus.SUCCESS, status);
Log.i(LOG_TAG, "Test 1c: Add " + NUM_OF_CONTACTS + " random contacts");
// add contacts and check if added contacts are the same as fetched
Contact[] inputContacts = new Contact[NUM_OF_CONTACTS];
Contact addedContact = new Contact();
for (int i = 0; i < NUM_OF_CONTACTS; i++) {
inputContacts[i] = mTestModule.createDummyContactData();
status = mDatabaseHelper.addContact(inputContacts[i]);
assertEquals(ServiceStatus.SUCCESS, status);
status = mDatabaseHelper.fetchContact(inputContacts[i].localContactID, addedContact);
assertEquals(ServiceStatus.SUCCESS, status);
assertTrue(TestModule.doContactsMatch(addedContact, inputContacts[i]));
}
Log.i(LOG_TAG, "Test 1d: Modify contacts and check if modification was correct");
for (int i = 0; i < inputContacts.length; i++) {
for (int j = 0; j < inputContacts[i].details.size(); j++) {
ContactDetail detail = inputContacts[i].details.get(j);
mTestModule.modifyDummyDetailsData(detail);
status = mDatabaseHelper.modifyContactDetail(detail);
assertEquals(ServiceStatus.SUCCESS, status);
assertTrue(isContactDetailInSummary(detail));
}
// check if modifyContactDatail works good
Contact modifiedContact = new Contact();
status = mDatabaseHelper.fetchContact(inputContacts[i].localContactID, modifiedContact);
assertEquals(ServiceStatus.SUCCESS, status);
assertTrue(TestModule.doContactsMatch(modifiedContact, inputContacts[i]));
}
Log.i(LOG_TAG, "Test 1d: contacts and check if modification was correct");
for (int i = 0; i < inputContacts.length; i++) {
for (int j = 0; j < inputContacts[i].details.size(); j++) {
ContactDetail detail = inputContacts[i].details.get(j);
mTestModule.modifyDummyDetailsData(detail);
status = mDatabaseHelper.modifyContactDetail(detail);
assertEquals(ServiceStatus.SUCCESS, status);
}
// check if modifyContactDatail works good
Contact modifiedContact = new Contact();
status = mDatabaseHelper.fetchContact(inputContacts[i].localContactID, modifiedContact);
assertEquals(ServiceStatus.SUCCESS, status);
assertTrue(TestModule.doContactsMatch(modifiedContact, inputContacts[i]));
}
shutdown();
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class NowPlusContactsTest method testFindNativeContact.
@SmallTest
public void testFindNativeContact() {
Log.i(LOG_TAG, "***** EXECUTING testFetchContactInfo *****");
Log.i(LOG_TAG, "Test Find Native Contact");
Log.i(LOG_TAG, "Test 1a: Initialise test environment and load database");
assertTrue(initialise());
Log.i(LOG_TAG, "Test 1b: Remove user data");
mDatabaseHelper.removeUserData();
ServiceStatus status = mTestUtility.waitForEvent(WAIT_EVENT_TIMEOUT_MS, DbTestUtility.CONTACTS_INT_EVENT_MASK);
// add contacts and check if added contacts are the same as fetched
Contact nativeContact = new Contact();
nativeContact.synctophone = true;
status = mDatabaseHelper.addContact(nativeContact);
assertEquals(ServiceStatus.SUCCESS, status);
// create and add NameDetail
ContactDetail nameDetail = mTestModule.createDummyDetailsName();
ContactDetail nicknameDetail = mTestModule.createDummyDetailsNickname(nameDetail);
nicknameDetail.localContactID = nativeContact.localContactID;
status = mDatabaseHelper.addContactDetail(nicknameDetail);
assertEquals(ServiceStatus.SUCCESS, status);
// create and add phoneDetail
ContactDetail phoneDetail = new ContactDetail();
phoneDetail.localContactID = nativeContact.localContactID;
phoneDetail.key = ContactDetail.DetailKeys.VCARD_PHONE;
String number = "07967 123456";
phoneDetail.setTel(number, ContactDetail.DetailKeyTypes.CELL);
status = mDatabaseHelper.addContactDetail(phoneDetail);
assertEquals(ServiceStatus.SUCCESS, status);
// create and add phoneDetail
ContactDetail emailDetail = new ContactDetail();
emailDetail.localContactID = nativeContact.localContactID;
emailDetail.key = ContactDetail.DetailKeys.VCARD_EMAIL;
emailDetail.setEmail(TestModule.generateRandomString() + "@mail.co.uk", ContactDetail.DetailKeyTypes.HOME);
status = mDatabaseHelper.addContactDetail(emailDetail);
assertEquals(ServiceStatus.SUCCESS, status);
Contact fetchedContact = new Contact();
status = mDatabaseHelper.fetchContact(nativeContact.localContactID, fetchedContact);
assertTrue(mDatabaseHelper.findNativeContact(fetchedContact));
Contact c = new Contact();
assertFalse(mDatabaseHelper.findNativeContact(c));
shutdown();
}
Aggregations