Search in sources :

Example 81 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class UploadServerContactsTest method generateReplyContact.

private void generateReplyContact(Contact expContact) {
    mReplyContact = new Contact();
    mReplyContact.contactID = expContact.localContactID + 1;
    if ((expContact.localContactID & 15) != 0) {
        mReplyContact.userID = expContact.localContactID + 2;
    }
    for (ContactDetail detail : expContact.details) {
        ContactDetail newDetail = new ContactDetail();
        generateReplyDetail(newDetail, detail);
        mReplyContact.details.add(newDetail);
    }
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) Contact(com.vodafone360.people.datatypes.Contact)

Example 82 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class NowPlusContactDetailsTableTest method testModifyContactDetail.

@MediumTest
public void testModifyContactDetail() {
    final String fnName = "testModifyContactDetail";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "Modifies a contact detail in the contacts detail table, validating all the way");
    SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    ContactDetail detail = new ContactDetail();
    mTestModule.createDummyDetailsData(detail);
    detail.localContactID = TestModule.generateRandomLong();
    Long serverId = TestModule.generateRandomLong();
    // try to modify detail before creating a table
    ServiceStatus status = ContactDetailsTable.modifyDetail(detail, true, true, writeableDb);
    assertEquals(ServiceStatus.ERROR_DATABASE_CORRUPT, status);
    assertFalse(ContactDetailsTable.syncSetServerId(TestModule.generateRandomLong(), serverId, writeableDb));
    startSubTest(fnName, "Creating table");
    createTable();
    // try to modify detail before adding it
    status = ContactDetailsTable.modifyDetail(detail, true, true, writeableDb);
    assertEquals(ServiceStatus.ERROR_NOT_FOUND, status);
    // try to add detail with localContactID that is set
    status = ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    mTestModule.modifyDummyDetailsData(detail);
    status = ContactDetailsTable.modifyDetail(detail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    // fetch modified detail
    ContactDetail fetchedDetail = ContactDetailsTable.fetchDetail(detail.localDetailID, readableDb);
    assertTrue(DatabaseHelper.doDetailsMatch(detail, fetchedDetail));
    assertTrue(ContactDetailsTable.syncSetServerId(detail.localDetailID, serverId, writeableDb));
    ContactDetail modServIdDetail = ContactDetailsTable.fetchDetail(detail.localDetailID, readableDb);
    assertEquals(serverId, modServIdDetail.unique_id);
    Log.i(LOG_TAG, "***********************************************");
    Log.i(LOG_TAG, fnName + " has completed successfully");
    Log.i(LOG_TAG, "***********************************************");
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 83 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class TestModule method createDummyDetailsNickname.

public ContactDetail createDummyDetailsNickname(ContactDetail name) {
    ContactDetail nickname = new ContactDetail();
    nickname.setValue(name.getName().toString(), ContactDetail.DetailKeys.VCARD_NICKNAME, null);
    return nickname;
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail)

Example 84 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class TestModule method modifyDummyDetailsData.

public void modifyDummyDetailsData(ContactDetail detail) {
    switch(detail.key) {
        case VCARD_NAME:
            VCardHelper.Name name = createDummyName();
            detail.setName(name);
            break;
        case PRESENCE_TEXT:
            detail.setValue(generateRandomString(), detail.key, null);
            break;
        case VCARD_DATE:
            Time time = new Time();
            time.parse("20080605");
            detail.setDate(time, ContactDetail.DetailKeyTypes.BIRTHDAY);
            break;
        case VCARD_IMADDRESS:
            detail.setValue(generateRandomString() + "@mail.co.uk", detail.key, null);
            break;
        case VCARD_EMAIL:
            detail.setEmail(generateRandomString() + "@mail.co.uk", ContactDetail.DetailKeyTypes.HOME);
            break;
        case VCARD_PHONE:
            detail.setTel("07967 123456", ContactDetail.DetailKeyTypes.CELL);
            break;
        case VCARD_BUSINESS:
        case VCARD_ADDRESS:
            VCardHelper.PostalAddress address = new VCardHelper.PostalAddress();
            address.addressLine1 = "123 Any road";
            address.addressLine2 = "Any location";
            address.city = "Any City";
            address.county = "Any County";
            address.postCode = "M6 2AY";
            address.country = "United Kingdom";
            detail.setPostalAddress(address, ContactDetail.DetailKeyTypes.HOME);
            break;
        case VCARD_URL:
        case VCARD_INTERNET_ADDRESS:
            detail.setValue("www." + generateRandomString() + "anyaddress.co.uk", detail.key, null);
            break;
        case VCARD_ROLE:
            detail.setValue(generateRandomString(), detail.key, null);
            break;
        case VCARD_ORG:
            Organisation org = new Organisation();
            org.name = generateRandomString();
            detail.setOrg(org, null);
            break;
        case VCARD_TITLE:
            detail.setValue(generateRandomString(), detail.key, null);
            break;
        case VCARD_NOTE:
            {
                String randomString = new String();
                for (int i = 0; i < generateRandomInt() % 10; i++) {
                    randomString += generateRandomString() + " ";
                }
                detail.setValue(randomString, detail.key, null);
                break;
            }
    }
}
Also used : Organisation(com.vodafone360.people.datatypes.VCardHelper.Organisation) VCardHelper(com.vodafone360.people.datatypes.VCardHelper) Time(android.text.format.Time)

Example 85 with ContactDetail

use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.

the class TestModule method fixPreferred.

public void fixPreferred(Contact testContact) {
    boolean donePhone = false;
    boolean doneEmail = false;
    boolean doneAddress = false;
    boolean doneOrg = false;
    for (ContactDetail detail : testContact.details) {
        switch(detail.key) {
            case VCARD_PHONE:
                if (!donePhone) {
                    donePhone = true;
                    detail.order = ContactDetail.ORDER_PREFERRED;
                } else {
                    detail.order = ContactDetail.ORDER_NORMAL;
                }
                break;
            case VCARD_EMAIL:
                if (!doneEmail) {
                    doneEmail = true;
                    detail.order = ContactDetail.ORDER_PREFERRED;
                } else {
                    detail.order = ContactDetail.ORDER_NORMAL;
                }
                break;
            case VCARD_ADDRESS:
                if (!doneAddress) {
                    doneAddress = true;
                    detail.order = ContactDetail.ORDER_PREFERRED;
                } else {
                    detail.order = ContactDetail.ORDER_NORMAL;
                }
                break;
            case VCARD_ORG:
                if (!doneOrg) {
                    doneOrg = true;
                    detail.order = ContactDetail.ORDER_PREFERRED;
                } else {
                    detail.order = ContactDetail.ORDER_NORMAL;
                }
                break;
        }
    }
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail)

Aggregations

ContactDetail (com.vodafone360.people.datatypes.ContactDetail)109 Contact (com.vodafone360.people.datatypes.Contact)60 ServiceStatus (com.vodafone360.people.service.ServiceStatus)57 ArrayList (java.util.ArrayList)33 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)24 MediumTest (android.test.suitebuilder.annotation.MediumTest)24 Cursor (android.database.Cursor)20 Suppress (android.test.suitebuilder.annotation.Suppress)16 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)15 ContentValues (android.content.ContentValues)11 SmallTest (android.test.suitebuilder.annotation.SmallTest)10 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)10 SQLException (android.database.SQLException)8 Uri (android.net.Uri)7 SQLiteException (android.database.sqlite.SQLiteException)6 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)6 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)6 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)4 ContactChangeInfo (com.vodafone360.people.database.tables.ContactChangeLogTable.ContactChangeInfo)4 Date (java.util.Date)4