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);
}
}
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, "***********************************************");
}
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;
}
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;
}
}
}
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;
}
}
}
Aggregations