Search in sources :

Example 61 with ServiceStatus

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();
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) Contact(com.vodafone360.people.datatypes.Contact) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 62 with ServiceStatus

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();
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Contact(com.vodafone360.people.datatypes.Contact) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 63 with ServiceStatus

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();
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Contact(com.vodafone360.people.datatypes.Contact) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 64 with ServiceStatus

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();
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 65 with ServiceStatus

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();
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ServiceStatus (com.vodafone360.people.service.ServiceStatus)190 Contact (com.vodafone360.people.datatypes.Contact)71 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)63 MediumTest (android.test.suitebuilder.annotation.MediumTest)62 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)43 ArrayList (java.util.ArrayList)43 Suppress (android.test.suitebuilder.annotation.Suppress)40 Cursor (android.database.Cursor)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)17 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)16 Bundle (android.os.Bundle)12 ContentValues (android.content.ContentValues)11 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)11 SQLException (android.database.SQLException)9 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)9 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)9 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)9 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)8 LoginDetails (com.vodafone360.people.datatypes.LoginDetails)8 PersistSettings (com.vodafone360.people.service.PersistSettings)8