Search in sources :

Example 36 with Name

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

the class FetchNativeContactsTest method testRunWithOneNewContact.

@MediumTest
@Suppress
public // Breaks tests
void testRunWithOneNewContact() {
    final String fnName = "testRunWithOneNewContact";
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + " *****");
    mTestStep = 1;
    startSubTest(fnName, "Checking people database is empty");
    Cursor peopleCursor = mDb.openContactSummaryCursor(null, null);
    assertEquals(0, peopleCursor.getCount());
    assertTrue(Settings.ENABLE_UPDATE_NATIVE_CONTACTS);
    startSubTest(fnName, "Checking native database is empty");
    Cursor nativeCursor = mCr.query(People.CONTENT_URI, new String[] { People._ID, People.NAME, People.NOTES }, null, null, null);
    assertEquals(0, nativeCursor.getCount());
    startSubTest(fnName, "Add one dummy native contact");
    ContentValues peopleValues = new ContentValues();
    peopleValues.put(Contacts.People.NAME, ADD_CONTACT_TEST_NAME);
    peopleValues.put(Contacts.People.NOTES, ADD_CONTACT_TEST_NOTE);
    Uri personUri1 = mCr.insert(Contacts.People.CONTENT_URI, peopleValues);
    assertTrue("Unable to insert contact into native people table", personUri1 != null);
    final long personId = ContentUris.parseId(personUri1);
    ContentValues phoneValues = new ContentValues();
    phoneValues.put(Contacts.Phones.PERSON_ID, personId);
    phoneValues.put(Contacts.Phones.NUMBER, ADD_PHONE_TEST1);
    phoneValues.put(Contacts.Phones.TYPE, ADD_PHONE_TYPE_TEST1);
    Uri phoneUri1 = mCr.insert(Contacts.Phones.CONTENT_URI, phoneValues);
    assertTrue("Unable to insert contact into native phone table 1", phoneUri1 != null);
    final long phoneId1 = (int) ContentUris.parseId(phoneUri1);
    phoneValues.put(Contacts.Phones.NUMBER, ADD_PHONE_TEST2);
    phoneValues.put(Contacts.Phones.TYPE, ADD_PHONE_TYPE_TEST2);
    phoneValues.put(Contacts.Phones.ISPRIMARY, 1);
    Uri phoneUri2 = mCr.insert(Contacts.Phones.CONTENT_URI, phoneValues);
    assertTrue("Unable to insert contact into native phone table 2", phoneUri2 != null);
    final long phoneId2 = ContentUris.parseId(phoneUri2);
    phoneValues.put(Contacts.Phones.NUMBER, ADD_PHONE_TEST3);
    phoneValues.put(Contacts.Phones.TYPE, ADD_PHONE_TYPE_TEST3);
    phoneValues.remove(Contacts.Phones.ISPRIMARY);
    Uri phoneUri3 = mCr.insert(Contacts.Phones.CONTENT_URI, phoneValues);
    assertTrue("Unable to insert contact into native phone table 3", phoneUri3 != null);
    final long phoneId3 = ContentUris.parseId(phoneUri3);
    ContentValues cmValues = new ContentValues();
    cmValues.put(Contacts.ContactMethods.PERSON_ID, personId);
    cmValues.put(Contacts.ContactMethods.DATA, ADD_CM_TEST1);
    cmValues.put(Contacts.ContactMethods.TYPE, ADD_CM_TYPE_TEST1);
    cmValues.put(Contacts.ContactMethods.KIND, ADD_CM_KIND_TEST1);
    Uri cmUri1 = mCr.insert(Contacts.ContactMethods.CONTENT_URI, cmValues);
    assertTrue("Unable to insert contact into native contact methods table 1", cmUri1 != null);
    final long cmId1 = ContentUris.parseId(cmUri1);
    cmValues.put(Contacts.ContactMethods.DATA, ADD_CM_TEST2);
    cmValues.put(Contacts.ContactMethods.TYPE, ADD_CM_TYPE_TEST2);
    cmValues.put(Contacts.ContactMethods.KIND, ADD_CM_KIND_TEST2);
    cmValues.put(Contacts.ContactMethods.ISPRIMARY, 1);
    Uri cmUri2 = mCr.insert(Contacts.ContactMethods.CONTENT_URI, cmValues);
    assertTrue("Unable to insert contact into native contact methods table 2", cmUri2 != null);
    final long cmId2 = ContentUris.parseId(cmUri2);
    ContentValues orgValues = new ContentValues();
    orgValues.put(Contacts.Organizations.PERSON_ID, personId);
    orgValues.put(Contacts.Organizations.COMPANY, ADD_ORG_COMPANY_TEST1);
    orgValues.put(Contacts.Organizations.TITLE, ADD_ORG_TITLE_TEST1);
    orgValues.put(Contacts.Organizations.TYPE, ADD_ORG_TYPE_TEST1);
    orgValues.put(Contacts.Organizations.LABEL, ADD_ORG_LABEL_TEST1);
    Uri orgUri = mCr.insert(Contacts.Organizations.CONTENT_URI, orgValues);
    assertTrue("Unable to insert contact into native organizations table 1", orgUri != null);
    final long orgId1 = ContentUris.parseId(orgUri);
    startSubTest(fnName, "Running processor");
    runProcessor();
    startSubTest(fnName, "Checking contact has been synced to people");
    peopleCursor.requery();
    assertEquals(1, peopleCursor.getCount());
    assertTrue(peopleCursor.moveToFirst());
    ContactSummary summary = ContactSummaryTable.getQueryData(peopleCursor);
    assertTrue(summary != null);
    Contact newContact = new Contact();
    ServiceStatus status = mDb.fetchContact(summary.localContactID, newContact);
    assertEquals(ServiceStatus.SUCCESS, status);
    boolean doneName = false;
    boolean doneNickname = false;
    boolean doneNote = false;
    boolean donePhone1 = false;
    boolean donePhone2 = false;
    boolean donePhone3 = false;
    boolean doneCm1 = false;
    boolean doneCm2 = false;
    boolean doneOrg1 = false;
    boolean doneTitle1 = false;
    assertTrue(newContact.synctophone);
    assertEquals(personId, newContact.nativeContactId.longValue());
    assertEquals(personId, summary.nativeContactId.longValue());
    for (ContactDetail detail : newContact.details) {
        assertEquals(personId, detail.nativeContactId.longValue());
        detail.syncNativeContactId = fetchSyncNativeId(detail.localDetailID);
        assertEquals("No sync marker, ID = " + detail.nativeDetailId + ", key = " + detail.key, Integer.valueOf(-1), detail.syncNativeContactId);
        Integer detailId = detail.nativeDetailId;
        assertTrue(detailId != null);
        switch(detail.key) {
            case VCARD_NAME:
                assertEquals(personId, detailId.longValue());
                assertEquals(ADD_CONTACT_TEST_NAME, detail.nativeVal1);
                VCardHelper.Name name = detail.getName();
                assertTrue(name != null);
                assertEquals(ADD_CONTACT_TEST_NAME, name.toString());
                doneName = true;
                break;
            case VCARD_NICKNAME:
                assertEquals(personId, detailId.longValue());
                assertEquals(ADD_CONTACT_TEST_NAME, detail.nativeVal1);
                assertEquals(ADD_CONTACT_TEST_NAME, detail.getValue());
                doneNickname = true;
                break;
            case VCARD_NOTE:
                assertEquals(personId, detailId.longValue());
                assertEquals(ADD_CONTACT_TEST_NOTE, detail.nativeVal1);
                assertEquals(ADD_CONTACT_TEST_NOTE, detail.getValue());
                doneNote = true;
                break;
            case VCARD_PHONE:
                if (detailId.longValue() == phoneId1) {
                    donePhone1 = true;
                    assertEquals(ADD_PHONE_TEST1, detail.nativeVal1);
                    assertEquals(ADD_PHONE_TEST1, detail.getValue());
                    assertEquals(ADD_PHONE_PEOPLE_TYPE_TEST1, detail.keyType);
                    assertEquals(Integer.valueOf(ContactDetail.ORDER_NORMAL), detail.order);
                } else if (detailId.longValue() == phoneId2) {
                    donePhone2 = true;
                    assertEquals(ADD_PHONE_TEST2, detail.nativeVal1);
                    assertEquals(ADD_PHONE_TEST2, detail.getValue());
                    assertEquals(ADD_PHONE_PEOPLE_TYPE_TEST2, detail.keyType);
                    assertEquals(Integer.valueOf(ContactDetail.ORDER_PREFERRED), detail.order);
                } else if (detailId.longValue() == phoneId3) {
                    donePhone3 = true;
                    assertEquals(ADD_PHONE_TEST3, detail.nativeVal1);
                    assertEquals(ADD_PHONE_TEST3, detail.getValue());
                    assertEquals(ADD_PHONE_PEOPLE_TYPE_TEST3, detail.keyType);
                    assertEquals(Integer.valueOf(ContactDetail.ORDER_NORMAL), detail.order);
                } else {
                    fail("Unknown phone number in people contact: ID:" + detailId + " does not match " + phoneId1 + "," + phoneId2 + "," + phoneId3);
                }
                break;
            case VCARD_EMAIL:
                assertTrue(detailId != null);
                if (detailId.longValue() == cmId1) {
                    doneCm1 = true;
                    assertEquals(ADD_CM_TEST1, detail.nativeVal1);
                    assertEquals(String.valueOf(ADD_CM_TYPE_TEST1), detail.nativeVal2);
                    assertEquals(String.valueOf(ADD_CM_KIND_TEST1), detail.nativeVal3);
                    assertEquals(ADD_CM_TEST1, detail.getValue());
                    assertEquals(ADD_CM_PEOPLE_TYPE_TEST1, detail.keyType);
                } else {
                    fail("Unknown email in people contact");
                }
                break;
            case VCARD_ADDRESS:
                assertTrue(detailId != null);
                if (detailId.longValue() == cmId2) {
                    doneCm2 = true;
                    assertEquals(ADD_CM_TEST2, detail.nativeVal1);
                    assertEquals(String.valueOf(ADD_CM_TYPE_TEST2), detail.nativeVal2);
                    assertEquals(String.valueOf(ADD_CM_KIND_TEST2), detail.nativeVal3);
                    VCardHelper.PostalAddress address = detail.getPostalAddress();
                    assertTrue(address != null);
                    assertEquals(ADD_CM_TEST2_ADDRESS1, address.addressLine1);
                    assertEquals(ADD_CM_TEST2_ADDRESS2, address.addressLine2);
                    assertEquals(ADD_CM_TEST2_ADDRESS_CITY, address.city);
                    assertEquals(ADD_CM_TEST2_ADDRESS_COUNTY, address.county);
                    assertEquals(ADD_CM_TEST2_ADDRESS_POSTCODE, address.postCode);
                    assertEquals(ADD_CM_TEST2_ADDRESS_COUNTRY, address.country);
                    assertEquals(ADD_CM_PEOPLE_TYPE_TEST2, detail.keyType);
                } else {
                    fail("Unknown address in people contact");
                }
                break;
            case VCARD_ORG:
                assertTrue(detailId != null);
                if (detailId.longValue() == orgId1) {
                    doneOrg1 = true;
                    assertEquals(ADD_ORG_COMPANY_TEST1, detail.nativeVal1);
                    assertEquals(String.valueOf(ADD_ORG_TYPE_TEST1), detail.nativeVal3);
                    VCardHelper.Organisation org = detail.getOrg();
                    assertTrue(org != null);
                    assertEquals(0, org.unitNames.size());
                    assertEquals(ADD_ORG_COMPANY_TEST1, org.name);
                    assertEquals(ADD_ORG_PEOPLE_TYPE_TEST1, detail.keyType);
                } else {
                    fail("Unknown organisation in people contact");
                }
                break;
            case VCARD_TITLE:
                assertTrue(detailId != null);
                if (detailId.longValue() == orgId1) {
                    doneTitle1 = true;
                    assertEquals(ADD_ORG_TITLE_TEST1, detail.nativeVal1);
                    assertEquals(ADD_ORG_TITLE_TEST1, detail.getValue());
                } else {
                    fail("Unknown title in people contact");
                }
                break;
            default:
                fail("Unexpected detail in people contact: " + detail.key);
        }
    }
    assertTrue("Name was missing", doneName);
    assertTrue("Nickname was missing", doneNickname);
    assertTrue("Note was missing", doneNote);
    assertTrue("Phone1 was missing", donePhone1);
    assertTrue("Phone2 was missing", donePhone2);
    assertTrue("Phone3 was missing", donePhone3);
    assertTrue("Email was missing", doneCm1);
    assertTrue("Address was missing", doneCm2);
    assertTrue("Organisation was missing", doneOrg1);
    assertTrue("Title was missing", doneTitle1);
    nativeCursor.close();
    peopleCursor.close();
    Log.i(LOG_TAG, "*************************************************************************");
    Log.i(LOG_TAG, fnName + " has completed successfully");
    Log.i(LOG_TAG, "*************************************************************************");
    Log.i(LOG_TAG, "");
}
Also used : ContentValues(android.content.ContentValues) ContactSummary(com.vodafone360.people.datatypes.ContactSummary) Cursor(android.database.Cursor) Uri(android.net.Uri) Contact(com.vodafone360.people.datatypes.Contact) ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) VCardHelper(com.vodafone360.people.datatypes.VCardHelper) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 37 with Name

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

the class FetchNativeContactsTest method testRunWithDeletedDetails.

@MediumTest
@Suppress
public // Breaks tests
void testRunWithDeletedDetails() {
    final String fnName = "testRunWithDeletedDetails";
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + " *****");
    mTestStep = 1;
    startSubTest(fnName, "Checking people database is empty");
    Cursor peopleCursor = mDb.openContactSummaryCursor(null, null);
    assertEquals(0, peopleCursor.getCount());
    assertTrue(Settings.ENABLE_UPDATE_NATIVE_CONTACTS);
    startSubTest(fnName, "Checking native database is empty");
    Cursor nativeCursor = mCr.query(People.CONTENT_URI, new String[] { People._ID, People.NAME, People.NOTES }, null, null, null);
    assertEquals(0, nativeCursor.getCount());
    startSubTest(fnName, "Add one dummy native contact");
    ContentValues peopleValues = new ContentValues();
    peopleValues.put(Contacts.People.NAME, ADD_CONTACT_TEST_NAME);
    peopleValues.put(Contacts.People.NOTES, ADD_CONTACT_TEST_NOTE);
    Uri personUri1 = mCr.insert(Contacts.People.CONTENT_URI, peopleValues);
    assertTrue("Unable to insert contact into native people table", personUri1 != null);
    final long personId = ContentUris.parseId(personUri1);
    ContentValues phoneValues = new ContentValues();
    phoneValues.put(Contacts.Phones.PERSON_ID, personId);
    phoneValues.put(Contacts.Phones.NUMBER, ADD_PHONE_TEST1);
    phoneValues.put(Contacts.Phones.TYPE, ADD_PHONE_TYPE_TEST1);
    Uri phoneUri1 = mCr.insert(Contacts.Phones.CONTENT_URI, phoneValues);
    assertTrue("Unable to insert contact into native phone table 1", phoneUri1 != null);
    final long phoneId1 = (int) ContentUris.parseId(phoneUri1);
    ContentValues cmValues = new ContentValues();
    cmValues.put(Contacts.ContactMethods.PERSON_ID, personId);
    cmValues.put(Contacts.ContactMethods.DATA, ADD_CM_TEST1);
    cmValues.put(Contacts.ContactMethods.TYPE, ADD_CM_TYPE_TEST1);
    cmValues.put(Contacts.ContactMethods.KIND, ADD_CM_KIND_TEST1);
    Uri cmUri1 = mCr.insert(Contacts.ContactMethods.CONTENT_URI, cmValues);
    assertTrue("Unable to insert contact into native contact methods table 1", cmUri1 != null);
    final long cmId1 = ContentUris.parseId(cmUri1);
    cmValues.put(Contacts.ContactMethods.DATA, ADD_CM_TEST2);
    cmValues.put(Contacts.ContactMethods.TYPE, ADD_CM_TYPE_TEST2);
    cmValues.put(Contacts.ContactMethods.KIND, ADD_CM_KIND_TEST2);
    cmValues.put(Contacts.ContactMethods.ISPRIMARY, 1);
    Uri cmUri2 = mCr.insert(Contacts.ContactMethods.CONTENT_URI, cmValues);
    assertTrue("Unable to insert contact into native contact methods table 2", cmUri2 != null);
    final long cmId2 = ContentUris.parseId(cmUri2);
    ContentValues orgValues = new ContentValues();
    orgValues.put(Contacts.Organizations.PERSON_ID, personId);
    orgValues.put(Contacts.Organizations.COMPANY, ADD_ORG_COMPANY_TEST1);
    orgValues.put(Contacts.Organizations.TITLE, ADD_ORG_TITLE_TEST1);
    orgValues.put(Contacts.Organizations.TYPE, ADD_ORG_TYPE_TEST1);
    orgValues.put(Contacts.Organizations.LABEL, ADD_ORG_LABEL_TEST1);
    Uri orgUri = mCr.insert(Contacts.Organizations.CONTENT_URI, orgValues);
    assertTrue("Unable to insert contact into native organizations table 1", orgUri != null);
    final long orgId1 = ContentUris.parseId(orgUri);
    startSubTest(fnName, "Running processor");
    runProcessor();
    startSubTest(fnName, "Checking contact has been synced to people");
    peopleCursor.requery();
    assertEquals(1, peopleCursor.getCount());
    assertTrue(peopleCursor.moveToFirst());
    ContactSummary summary = ContactSummaryTable.getQueryData(peopleCursor);
    assertTrue(summary != null);
    Contact newContact = new Contact();
    ServiceStatus status = mDb.fetchContact(summary.localContactID, newContact);
    assertEquals(ServiceStatus.SUCCESS, status);
    boolean doneNote = false;
    boolean donePhone1 = false;
    boolean doneCm1 = false;
    boolean doneCm2 = false;
    boolean doneOrg1 = false;
    boolean doneTitle1 = false;
    assertTrue(newContact.synctophone);
    assertEquals(personId, newContact.nativeContactId.longValue());
    assertEquals(personId, summary.nativeContactId.longValue());
    for (ContactDetail detail : newContact.details) {
        assertEquals(personId, detail.nativeContactId.longValue());
        detail.syncNativeContactId = fetchSyncNativeId(detail.localDetailID);
        assertEquals("No sync marker, ID = " + detail.nativeDetailId + ", key = " + detail.key, Integer.valueOf(-1), detail.syncNativeContactId);
        Integer detailId = detail.nativeDetailId;
        assertTrue(detailId != null);
        switch(detail.key) {
            case VCARD_NAME:
            case VCARD_NICKNAME:
                assertEquals(personId, detailId.longValue());
                break;
            case VCARD_NOTE:
                assertEquals(personId, detailId.longValue());
                doneNote = true;
                mDb.deleteContactDetail(detail.localDetailID);
                break;
            case VCARD_PHONE:
                if (detailId.longValue() == phoneId1) {
                    donePhone1 = true;
                    mDb.deleteContactDetail(detail.localDetailID);
                } else {
                    fail("Unknown phone number in people contact: ID:" + detailId + " does not match " + phoneId1);
                }
                break;
            case VCARD_EMAIL:
                if (detailId.longValue() == cmId1) {
                    doneCm1 = true;
                    mDb.deleteContactDetail(detail.localDetailID);
                } else {
                    fail("Unknown email in people contact");
                }
                break;
            case VCARD_ADDRESS:
                if (detailId.longValue() == cmId2) {
                    doneCm2 = true;
                    mDb.deleteContactDetail(detail.localDetailID);
                } else {
                    fail("Unknown address in people contact");
                }
                break;
            case VCARD_ORG:
                if (detailId.longValue() == orgId1) {
                    doneOrg1 = true;
                    mDb.deleteContactDetail(detail.localDetailID);
                } else {
                    fail("Unknown organisation in people contact");
                }
                break;
            case VCARD_TITLE:
                if (detailId.longValue() == orgId1) {
                    doneTitle1 = true;
                    mDb.deleteContactDetail(detail.localDetailID);
                } else {
                    fail("Unknown title in people contact");
                }
                break;
            default:
                fail("Unexpected detail in people contact: " + detail.key);
        }
    }
    assertTrue("Note was missing", doneNote);
    assertTrue("Phone1 was missing", donePhone1);
    assertTrue("Email was missing", doneCm1);
    assertTrue("Address was missing", doneCm2);
    assertTrue("Organisation was missing", doneOrg1);
    assertTrue("Position was missing", doneTitle1);
    startSubTest(fnName, "Running processor");
    runProcessor();
    startSubTest(fnName, "Checking contact has been synced to people");
    peopleCursor.requery();
    assertEquals(1, peopleCursor.getCount());
    assertTrue(peopleCursor.moveToFirst());
    summary = ContactSummaryTable.getQueryData(peopleCursor);
    assertTrue(summary != null);
    newContact = new Contact();
    status = mDb.fetchContact(summary.localContactID, newContact);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertTrue(newContact.synctophone);
    assertEquals(personId, newContact.nativeContactId.longValue());
    assertEquals(personId, summary.nativeContactId.longValue());
    boolean doneName = false;
    boolean doneNickname = false;
    for (ContactDetail detail : newContact.details) {
        assertEquals(personId, detail.nativeContactId.longValue());
        detail.syncNativeContactId = fetchSyncNativeId(detail.localDetailID);
        assertEquals("No sync marker, ID = " + detail.nativeDetailId + ", key = " + detail.key, Integer.valueOf(-1), detail.syncNativeContactId);
        Integer detailId = detail.nativeDetailId;
        assertTrue(detailId != null);
        switch(detail.key) {
            case VCARD_NAME:
                assertEquals(personId, detailId.longValue());
                assertEquals(ADD_CONTACT_TEST_NAME, detail.nativeVal1);
                VCardHelper.Name name = detail.getName();
                assertTrue(name != null);
                assertEquals(ADD_CONTACT_TEST_NAME, name.toString());
                doneName = true;
                break;
            case VCARD_NICKNAME:
                assertEquals(personId, detailId.longValue());
                assertEquals(ADD_CONTACT_TEST_NAME, detail.nativeVal1);
                assertEquals(ADD_CONTACT_TEST_NAME, detail.getValue());
                doneNickname = true;
                break;
            default:
                fail("Unexpected contact detail: " + detail.key);
        }
    }
    assertTrue("Name was missing", doneName);
    assertTrue("Nickname was missing", doneNickname);
    nativeCursor.close();
    peopleCursor.close();
    Log.i(LOG_TAG, "*************************************************************************");
    Log.i(LOG_TAG, fnName + " has completed successfully");
    Log.i(LOG_TAG, "*************************************************************************");
    Log.i(LOG_TAG, "");
}
Also used : ContentValues(android.content.ContentValues) ContactSummary(com.vodafone360.people.datatypes.ContactSummary) Cursor(android.database.Cursor) Uri(android.net.Uri) Contact(com.vodafone360.people.datatypes.Contact) ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) VCardHelper(com.vodafone360.people.datatypes.VCardHelper) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 38 with Name

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

the class NowPlusDatatypesTests method testItemList.

public void testItemList() {
    ItemList groupPriv = new ItemList(ItemList.Type.group_privacy);
    int groupType = 1;
    boolean isReadOnly = true;
    boolean requiresLocalisation = true;
    boolean isSystemGroup = true;
    boolean isSmartGroup = true;
    long id = 3;
    long userId = 4;
    String name = "foo";
    Hashtable<String, Object> hashGroup = new Hashtable<String, Object>();
    hashGroup.put("grouptype", groupType);
    hashGroup.put("isreadonly", isReadOnly);
    hashGroup.put("requireslocalisation", requiresLocalisation);
    hashGroup.put("issystemgroup", isSystemGroup);
    hashGroup.put("issmartgroup", isSmartGroup);
    hashGroup.put("id", id);
    hashGroup.put("userid", userId);
    hashGroup.put("name", name);
    Vector<Hashtable<String, Object>> vect = new Vector<Hashtable<String, Object>>();
    vect.add(hashGroup);
    Hashtable<String, Object> hashItemListGroup = new Hashtable<String, Object>();
    hashItemListGroup.put("itemlist", vect);
    groupPriv.populateFromHashtable(hashItemListGroup);
    GroupItem helper = new GroupItem();
    GroupItem input = helper.createFromHashtable(hashGroup);
    GroupItem output = (GroupItem) groupPriv.mItemList.get(0);
    assertEquals(input.getType(), output.getType());
    assertEquals(input.toString(), output.toString());
    assertEquals(input.mGroupType, output.mGroupType);
    assertEquals(input.mIsReadOnly, output.mIsReadOnly);
    assertEquals(input.mRequiresLocalisation, output.mRequiresLocalisation);
    assertEquals(input.mIsSystemGroup, output.mIsSystemGroup);
    assertEquals(input.mIsSmartGroup, output.mIsSmartGroup);
    assertEquals(input.mId, output.mId);
    assertEquals(input.mUserId, output.mUserId);
    assertEquals(input.mName, output.mName);
}
Also used : Hashtable(java.util.Hashtable) ItemList(com.vodafone360.people.datatypes.ItemList) GroupItem(com.vodafone360.people.datatypes.GroupItem) Vector(java.util.Vector)

Example 39 with Name

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

the class NowPlusDatatypesTests method testGroupItem.

public void testGroupItem() {
    int groupType = 1;
    boolean isReadOnly = true;
    boolean requiresLocalisation = true;
    boolean isSystemGroup = true;
    boolean isSmartGroup = true;
    long id = 3;
    long userId = 4;
    String name = "foo";
    GroupItem input = new GroupItem();
    input.mGroupType = (Integer) groupType;
    input.mIsReadOnly = (Boolean) isReadOnly;
    input.mRequiresLocalisation = (Boolean) requiresLocalisation;
    input.mIsSystemGroup = (Boolean) isSystemGroup;
    input.mIsSmartGroup = (Boolean) isSmartGroup;
    input.mId = (Long) id;
    input.mUserId = (Long) userId;
    input.mName = name;
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    hash.put("grouptype", groupType);
    hash.put("isreadonly", isReadOnly);
    hash.put("requireslocalisation", requiresLocalisation);
    hash.put("issystemgroup", isSystemGroup);
    hash.put("issmartgroup", isSmartGroup);
    hash.put("id", id);
    hash.put("userid", userId);
    hash.put("name", name);
    GroupItem helper = new GroupItem();
    GroupItem output = helper.createFromHashtable(hash);
    assertEquals(input.getType(), output.getType());
    assertEquals(input.toString(), output.toString());
    assertEquals(input.mGroupType, output.mGroupType);
    assertEquals(input.mIsReadOnly, output.mIsReadOnly);
    assertEquals(input.mRequiresLocalisation, output.mRequiresLocalisation);
    assertEquals(input.mIsSystemGroup, output.mIsSystemGroup);
    assertEquals(input.mIsSmartGroup, output.mIsSmartGroup);
    assertEquals(input.mId, output.mId);
    assertEquals(input.mUserId, output.mUserId);
    assertEquals(input.mName, output.mName);
}
Also used : Hashtable(java.util.Hashtable) GroupItem(com.vodafone360.people.datatypes.GroupItem)

Example 40 with Name

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

the class NowPlusDatatypesTests method testActivityContact.

public void testActivityContact() {
    ActivityContact input = new ActivityContact();
    input.mAddress = "foo";
    input.mAvatarUrl = "foo";
    input.mContactId = 1L;
    input.mName = "bar";
    input.mNetwork = "mob";
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    hash.put("address", input.mAddress);
    hash.put("avatarurl", input.mAvatarUrl);
    hash.put("contactid", input.mContactId);
    hash.put("name", input.mName);
    hash.put("network", input.mNetwork);
    ActivityContact output = ActivityContact.createFromHashTable(hash);
    assertEquals(input.getType(), output.getType());
    assertEquals(input.toString(), output.toString());
    assertEquals(input.mAddress, output.mAddress);
    assertEquals(input.mAvatarUrl, output.mAvatarUrl);
    assertEquals(input.mContactId, output.mContactId);
    assertEquals(input.mName, output.mName);
    assertEquals(input.mNetwork, output.mNetwork);
}
Also used : ActivityContact(com.vodafone360.people.datatypes.ActivityContact) Hashtable(java.util.Hashtable)

Aggregations

ContactDetail (com.vodafone360.people.datatypes.ContactDetail)23 ServiceStatus (com.vodafone360.people.service.ServiceStatus)20 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)13 Cursor (android.database.Cursor)12 Contact (com.vodafone360.people.datatypes.Contact)12 ArrayList (java.util.ArrayList)11 Name (com.vodafone360.people.datatypes.VCardHelper.Name)9 ContentValues (android.content.ContentValues)7 Uri (android.net.Uri)7 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)7 SQLException (android.database.SQLException)6 Organisation (com.vodafone360.people.datatypes.VCardHelper.Organisation)6 QueueManager (com.vodafone360.people.service.io.QueueManager)6 Request (com.vodafone360.people.service.io.Request)6 TimelineSummaryItem (com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem)5 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)5 Hashtable (java.util.Hashtable)5 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)4 Suppress (android.test.suitebuilder.annotation.Suppress)4 Date (java.util.Date)4