Search in sources :

Example 1 with ContactsTable

use of com.vodafone360.people.database.tables.ContactsTable in project 360-Engine-for-Android by 360.

the class NowPlusContactDetailsTableTest method testFindNativeContact.

@MediumTest
public void testFindNativeContact() {
    final String fnName = "testFindNativeContact";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    startSubTest(fnName, "Creating table");
    createTable();
    // create contact 
    Contact contact = new Contact();
    contact.synctophone = true;
    // add contact to to the ContactsTable
    ContactsTable.create(mTestDatabase.getWritableDatabase());
    ServiceStatus status = ContactsTable.addContact(contact, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    // add contact to ContactSummaryTable
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    status = ContactSummaryTable.addContact(contact, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    // create and add NameDetail
    ContactDetail nameDetail = mTestModule.createDummyDetailsName();
    ContactDetail nicknameDetail = mTestModule.createDummyDetailsNickname(nameDetail);
    nicknameDetail.localContactID = contact.localContactID;
    status = ContactDetailsTable.addContactDetail(nicknameDetail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    contact.details.add(nicknameDetail);
    // create and add phoneDetail
    ContactDetail phoneDetail = new ContactDetail();
    phoneDetail.localContactID = contact.localContactID;
    phoneDetail.key = ContactDetail.DetailKeys.VCARD_PHONE;
    String number = "07967 123456";
    phoneDetail.setTel(number, ContactDetail.DetailKeyTypes.CELL);
    status = ContactDetailsTable.addContactDetail(phoneDetail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    contact.details.add(phoneDetail);
    // create and add phoneDetail
    ContactDetail emailDetail = new ContactDetail();
    emailDetail.localContactID = contact.localContactID;
    emailDetail.key = ContactDetail.DetailKeys.VCARD_EMAIL;
    emailDetail.setEmail(TestModule.generateRandomString() + "@mail.co.uk", ContactDetail.DetailKeyTypes.HOME);
    status = ContactDetailsTable.addContactDetail(emailDetail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    contact.details.add(emailDetail);
    assertTrue(ContactDetailsTable.findNativeContact(contact, writeableDb));
    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) Contact(com.vodafone360.people.datatypes.Contact) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 MediumTest (android.test.suitebuilder.annotation.MediumTest)1 Contact (com.vodafone360.people.datatypes.Contact)1 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)1 ServiceStatus (com.vodafone360.people.service.ServiceStatus)1