Search in sources :

Example 16 with User

use of com.vodafone360.people.engine.presence.User 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 17 with User

use of com.vodafone360.people.engine.presence.User 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();
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ArrayList(java.util.ArrayList) Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 18 with User

use of com.vodafone360.people.engine.presence.User 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 19 with User

use of com.vodafone360.people.engine.presence.User 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 20 with User

use of com.vodafone360.people.engine.presence.User 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)22 Contact (com.vodafone360.people.datatypes.Contact)12 ArrayList (java.util.ArrayList)12 User (com.vodafone360.people.engine.presence.User)11 Hashtable (java.util.Hashtable)9 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)7 Request (com.vodafone360.people.service.io.Request)7 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 PersistSettings (com.vodafone360.people.service.PersistSettings)6 QueueManager (com.vodafone360.people.service.io.QueueManager)6 SmallTest (android.test.suitebuilder.annotation.SmallTest)4 Identity (com.vodafone360.people.datatypes.Identity)4 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)3 RegistrationDetails (com.vodafone360.people.datatypes.RegistrationDetails)3 NetworkPresence (com.vodafone360.people.engine.presence.NetworkPresence)3 Cursor (android.database.Cursor)2 SQLiteStatement (android.database.sqlite.SQLiteStatement)2 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)2 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)2 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)2