use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class NowPlusContactsTest method testAddDeleteContacts.
@MediumTest
public void testAddDeleteContacts() {
Log.i(LOG_TAG, "***** EXECUTING testAddDeleteContacts *****");
Log.i(LOG_TAG, "Test contact functionality (add delete 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: Delete contacts and check if deletion was correct");
for (int i = 0; i < inputContacts.length; i++) {
// check if deletion works good
status = mDatabaseHelper.deleteContact(inputContacts[i].localContactID);
assertEquals(ServiceStatus.SUCCESS, status);
Contact removedContact = new Contact();
status = mDatabaseHelper.fetchContact(inputContacts[i].localContactID, removedContact);
// contact was deleted so it shouldn't be found
assertEquals(ServiceStatus.ERROR_NOT_FOUND, status);
}
shutdown();
}
use of com.vodafone360.people.service.ServiceStatus 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.service.ServiceStatus 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.service.ServiceStatus 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();
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class NowPlusContactsTest method testModifyContactServerId.
@SmallTest
public void testModifyContactServerId() {
Log.i(LOG_TAG, "***** EXECUTING testModifyContactServerId *****");
Log.i(LOG_TAG, "Test Modify Contact ServerId");
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);
// create and add contact
Contact c = mTestModule.createDummyContactData();
status = mDatabaseHelper.addContact(c);
assertEquals(ServiceStatus.SUCCESS, status);
Long serverId = TestModule.generateRandomLong();
assertTrue(mDatabaseHelper.modifyContactServerId(c.localContactID, serverId, c.userID));
Contact fetchedContact = new Contact();
status = mDatabaseHelper.fetchContact(c.localContactID, fetchedContact);
assertEquals(serverId, fetchedContact.contactID);
shutdown();
}
Aggregations