Search in sources :

Example 26 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusContactDetailsTableTest method testsyncSetServerIds.

@MediumTest
public void testsyncSetServerIds() {
    final String fnName = "testsyncSetServerIds";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "Validates syncSetServerIds details");
    SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    startSubTest(fnName, "Creating table");
    createTable();
    List<ServerIdInfo> detailServerIdList = new ArrayList<ServerIdInfo>();
    List<ContactDetail> detailsList = new ArrayList<ContactDetail>();
    for (int i = 0; i < NUM_OF_CONTACTS; i++) {
        ContactDetail detail = new ContactDetail();
        detail.localContactID = TestModule.generateRandomLong();
        mTestModule.createDummyDetailsData(detail);
        ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
        ServerIdInfo serverInfo = new ServerIdInfo();
        serverInfo.localId = detail.localDetailID;
        serverInfo.serverId = TestModule.generateRandomLong();
        detailServerIdList.add(serverInfo);
        detailsList.add(detail);
    }
    ServiceStatus status = ContactDetailsTable.syncSetServerIds(detailServerIdList, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    for (int i = 0; i < NUM_OF_CONTACTS; i++) {
        ContactDetail fetchedDetail = ContactDetailsTable.fetchDetail(detailsList.get(i).localDetailID, readableDb);
        assertNotNull(fetchedDetail);
        assertEquals(detailServerIdList.get(i).serverId, fetchedDetail.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) ArrayList(java.util.ArrayList) ServerIdInfo(com.vodafone360.people.database.DatabaseHelper.ServerIdInfo) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 27 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusContactDetailsTableTest method testAddFetchContactDetail.

@MediumTest
public void testAddFetchContactDetail() {
    final String fnName = "testAddFetchContactDetail";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "Adds a contact details to the contacts details table, validating all the way");
    SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    ContactDetail detail = new ContactDetail();
    mTestModule.createDummyDetailsData(detail);
    // try to add a detail before creating a table
    ServiceStatus status = ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
    assertEquals(ServiceStatus.ERROR_NOT_FOUND, status);
    // try to fetch detail before creating a table
    ContactDetail fetchedDetail = ContactDetailsTable.fetchDetail(TestModule.generateRandomLong(), readableDb);
    assertEquals(null, fetchedDetail);
    startSubTest(fnName, "Creating table");
    createTable();
    // try to add detail with localContactID that is null
    status = ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
    assertEquals(ServiceStatus.ERROR_NOT_FOUND, status);
    // try to add detail with localContactID that is set
    detail.localContactID = TestModule.generateRandomLong();
    status = ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    fetchedDetail = ContactDetailsTable.fetchDetail(detail.localDetailID, readableDb);
    assertTrue(DatabaseHelper.doDetailsMatch(detail, fetchedDetail));
    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 28 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusContactDetailsTableTest method testfetchPreferredDetail.

@MediumTest
public void testfetchPreferredDetail() {
    final String fnName = "testPreferredDetail";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "Adds a contact details to the contacts details table, validating all the way");
    startSubTest(fnName, "Creating table");
    createTable();
    SQLiteDatabase writeableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    ContactDetail detail = new ContactDetail();
    detail.key = ContactDetail.DetailKeys.VCARD_PHONE;
    detail.setTel("07967 123456", ContactDetail.DetailKeyTypes.CELL);
    // not preferred detail
    detail.order = 50;
    detail.localContactID = TestModule.generateRandomLong();
    ServiceStatus status = ContactDetailsTable.addContactDetail(detail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    ContactDetail preferredDetail = new ContactDetail();
    preferredDetail.key = ContactDetail.DetailKeys.VCARD_PHONE;
    preferredDetail.setTel("07967 654321", ContactDetail.DetailKeyTypes.CELL);
    preferredDetail.localContactID = detail.localContactID;
    preferredDetail.order = 0;
    status = ContactDetailsTable.addContactDetail(preferredDetail, true, true, writeableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    ContactDetail altDetail = new ContactDetail();
    assertTrue(ContactDetailsTable.fetchPreferredDetail(preferredDetail.localContactID.longValue(), ContactDetail.DetailKeys.VCARD_PHONE.ordinal(), altDetail, readableDb));
    // detail is preferred so should have the same fields
    assertEquals(preferredDetail.localDetailID, altDetail.localDetailID);
    assertEquals(preferredDetail.keyType, altDetail.keyType);
    assertEquals(preferredDetail.value, altDetail.value);
    assertEquals(preferredDetail.order, altDetail.order);
    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 29 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusContactSummaryTest method testSetAllUsersOffline.

public void testSetAllUsersOffline() {
    Log.i(LOG_TAG, "Create ContactSummaryTable");
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Add a contact to ContactSummaryTable");
    final Contact contact = mTestModule.createDummyContactData();
    contact.localContactID = new Long(10);
    contact.nativeContactId = new Integer(11);
    ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Fetching a ContactSummary from ContactSummaryTable");
    final ContactSummary contactSummary = new ContactSummary();
    final ServiceStatus serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
    assertEquals(ServiceStatus.SUCCESS, serviceStatus);
    compareContactWithContactSummary(contact, contactSummary);
    // create a new user
    Hashtable<String, String> status = new Hashtable<String, String>();
    status.put("google", "online");
    status.put("microsoft", "online");
    status.put("mobile", "online");
    status.put("pc", "online");
    User user = new User("any", status);
    user.setLocalContactId(contactSummary.localContactID);
    // set him online
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.updateOnlineStatus(user));
    // fetch again
    final ContactSummary contactSummary2 = new ContactSummary();
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.fetchSummaryItem(user.getLocalContactId(), contactSummary2, mTestDatabase.getReadableDatabase()));
    // check if he's online
    assertEquals(OnlineStatus.ONLINE, contactSummary2.onlineStatus);
    // set offline
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.setOfflineStatus());
    // fetch again
    final ContactSummary contactSummary3 = new ContactSummary();
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.fetchSummaryItem(user.getLocalContactId(), contactSummary3, mTestDatabase.getReadableDatabase()));
    // check if it's offline
    assertEquals(OnlineStatus.OFFLINE, contactSummary3.onlineStatus);
}
Also used : ContactSummary(com.vodafone360.people.datatypes.ContactSummary) User(com.vodafone360.people.engine.presence.User) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Hashtable(java.util.Hashtable) Contact(com.vodafone360.people.datatypes.Contact)

Example 30 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusContactSummaryTest method testUpdateOnlineStatus.

public void testUpdateOnlineStatus() {
    Log.i(LOG_TAG, "***** EXECUTING testUpdateOnlineStatus() *****");
    Log.i(LOG_TAG, "Create ContactSummaryTable");
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Add a contact to ContactSummaryTable");
    final Contact contact = mTestModule.createDummyContactData();
    contact.localContactID = new Long(10);
    contact.nativeContactId = new Integer(11);
    ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Fetching a ContactSummary from ContactSummaryTable");
    final ContactSummary contactSummary = new ContactSummary();
    final ServiceStatus serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
    assertEquals(ServiceStatus.SUCCESS, serviceStatus);
    compareContactWithContactSummary(contact, contactSummary);
    // create a new user
    Hashtable<String, String> status = new Hashtable<String, String>();
    status.put("google", "online");
    status.put("microsoft", "online");
    status.put("mobile", "online");
    status.put("pc", "online");
    User user = new User("any", status);
    user.setLocalContactId(contactSummary.localContactID);
    // set him online
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.updateOnlineStatus(user));
    // fetch again
    final ContactSummary contactSummary2 = new ContactSummary();
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.fetchSummaryItem(user.getLocalContactId(), contactSummary2, mTestDatabase.getReadableDatabase()));
    // check if he's online
    assertEquals(OnlineStatus.ONLINE, contactSummary2.onlineStatus);
}
Also used : ContactSummary(com.vodafone360.people.datatypes.ContactSummary) User(com.vodafone360.people.engine.presence.User) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Hashtable(java.util.Hashtable) Contact(com.vodafone360.people.datatypes.Contact)

Aggregations

ServiceStatus (com.vodafone360.people.service.ServiceStatus)190 Contact (com.vodafone360.people.datatypes.Contact)71 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)63 MediumTest (android.test.suitebuilder.annotation.MediumTest)62 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)43 ArrayList (java.util.ArrayList)43 Suppress (android.test.suitebuilder.annotation.Suppress)40 Cursor (android.database.Cursor)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)17 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)16 Bundle (android.os.Bundle)12 ContentValues (android.content.ContentValues)11 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)11 SQLException (android.database.SQLException)9 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)9 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)9 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)9 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)8 LoginDetails (com.vodafone360.people.datatypes.LoginDetails)8 PersistSettings (com.vodafone360.people.service.PersistSettings)8