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