use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineNativeTypes in project 360-Engine-for-Android by 360.
the class NowPlusActivitiesTableTest method testFetchTimelineEventsForContact.
// TODO: this method is tested in testAddTimelineEvents(),
// public void testGetTimelineData() {
// Log.i(LOG_TAG, "***** EXECUTING testActivitiesTableCreation *****");
// SQLiteDatabase writableDataBase = mTestDatabase.getWritableDatabase();
// ActivitiesTable.create(writableDataBase);
//
// SQLiteDatabase readableDataBase = mTestDatabase.getReadableDatabase();
//
// ActivitiesTable.getTimelineData(c);
//
// fail("Not yet implemented");
// }
// public void testFillUpdateData() {
//
// Log.i(LOG_TAG, "***** EXECUTING testActivitiesTableCreation *****");
// SQLiteDatabase readableDataBase = mTestDatabase.getReadableDatabase();
// ActivitiesTable.create(readableDataBase);
// Log.i(LOG_TAG, "***** EXECUTING addTimelineEvents , not call log though *****");
// ActivitiesTable.fillUpdateData(item, contactIdx)
//
// fail("Not yet implemented");
// }
/**
* This method checks that timeline events are present in the table
*/
public void testFetchTimelineEventsForContact() {
Log.i(LOG_TAG, "***** testFetchTimelineEventsForContact():create table *****");
SQLiteDatabase dataBase = mTestDatabase.getWritableDatabase();
ActivitiesTable.create(dataBase);
Log.i(LOG_TAG, "***** testFetchLatestStatusTimestampForContact , not call log though *****");
ArrayList<TimelineSummaryItem> timeLines = TestModule.generateFakeTimeLinesList();
ActivitiesTable.addTimelineEvents(timeLines, false, dataBase);
// check if the records are there
SQLiteDatabase readableDataBase = mTestDatabase.getReadableDatabase();
Cursor c = ActivitiesTable.fetchTimelineEventList(YESTERDAY_TIME_MILLIS, new TimelineNativeTypes[] { TimelineNativeTypes.SmsLog, TimelineNativeTypes.MmsLog }, readableDataBase);
ArrayList<TimelineSummaryItem> actualDBTimeLines = new ArrayList<TimelineSummaryItem>();
for (int i = 0; i < timeLines.size(); i++) {
if (c.moveToPosition(i)) {
actualDBTimeLines.add(ActivitiesTable.getTimelineData(c));
}
}
c.close();
c = null;
compareTimeLineIds(timeLines, actualDBTimeLines);
for (TimelineSummaryItem timeLineSummary : actualDBTimeLines) {
TimelineNativeTypes[] typeList = { TimelineNativeTypes.CallLog, TimelineNativeTypes.SmsLog, TimelineNativeTypes.MmsLog };
c = ActivitiesTable.fetchTimelineEventsForContact(YESTERDAY_TIME_MILLIS, timeLineSummary.mLocalContactId, timeLineSummary.mContactName, typeList, null, readableDataBase);
assertEquals("the cursor is empty!", false, c.getCount() == 0);
while (c.moveToNext()) {
TimelineSummaryItem summary = ActivitiesTable.getTimelineData(c);
assertEquals("the timeline is not found!", true, actualDBTimeLines.contains(summary));
}
c.close();
c = null;
}
Log.i(LOG_TAG, "***** testFetchTimelineEventsForContact() SUCCEEDED *****");
}
use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineNativeTypes in project 360-Engine-for-Android by 360.
the class NowPlusActivitiesTableTest method testUpdateTimelineContactNameAndId5.
/**
* this method checks the updated contacts are present in the database
*/
public void testUpdateTimelineContactNameAndId5() {
Log.i(LOG_TAG, "***** testUpdateTimelineContactNameAndId5: create table *****");
SQLiteDatabase writableDataBase = mTestDatabase.getWritableDatabase();
ActivitiesTable.create(writableDataBase);
Log.i(LOG_TAG, "***** testUpdateTimelineContactNameAndId5, not call log though *****");
ArrayList<TimelineSummaryItem> timeLines = TestModule.generateFakeTimeLinesList();
ActivitiesTable.addTimelineEvents(timeLines, false, writableDataBase);
// check if the records are there
SQLiteDatabase readableDataBase = mTestDatabase.getReadableDatabase();
Cursor c = ActivitiesTable.fetchTimelineEventList(YESTERDAY_TIME_MILLIS, new TimelineNativeTypes[] { TimelineNativeTypes.SmsLog, TimelineNativeTypes.MmsLog }, readableDataBase);
ArrayList<TimelineSummaryItem> actualDBTimeLines = new ArrayList<TimelineSummaryItem>();
while (c.moveToNext()) {
actualDBTimeLines.add(ActivitiesTable.getTimelineData(c));
}
compareTimeLineIds(timeLines, actualDBTimeLines);
timeLines = actualDBTimeLines;
final String NAME = "New";
for (TimelineSummaryItem timeLineSummary : timeLines) {
ActivitiesTable.updateTimelineContactNameAndId(timeLineSummary.mContactName, timeLineSummary.mContactName += NAME, timeLineSummary.mLocalContactId, TestModule.generateRandomLong(), writableDataBase);
}
c.requery();
actualDBTimeLines.clear();
c.moveToFirst();
for (int i = 0, count = c.getCount(); i < count; i++, c.moveToNext()) {
actualDBTimeLines.add(ActivitiesTable.getTimelineData(c));
}
compareTimeLineIds(timeLines, actualDBTimeLines);
Log.i(LOG_TAG, "***** testUpdateTimelineContactNameAndId5 SUCCEEDED *****");
}
use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineNativeTypes in project 360-Engine-for-Android by 360.
the class NowPlusActivitiesTableTest method testFetchLatestStatusTimestampForContact.
/**
* this method checks the time stamps in the initial time line list are the same as in the database
*/
@Suppress
public void testFetchLatestStatusTimestampForContact() {
Log.i(LOG_TAG, "***** testFetchLatestStatusTimestampForContact: create table *****");
SQLiteDatabase dataBase = mTestDatabase.getWritableDatabase();
ActivitiesTable.create(dataBase);
Log.i(LOG_TAG, "***** testFetchLatestStatusTimestampForContact , not call log though *****");
ArrayList<TimelineSummaryItem> timeLines = TestModule.generateFakeTimeLinesList();
ActivitiesTable.addTimelineEvents(timeLines, false, dataBase);
// check if the records are there
SQLiteDatabase readableDataBase = mTestDatabase.getReadableDatabase();
Cursor c = ActivitiesTable.fetchTimelineEventList(YESTERDAY_TIME_MILLIS, new TimelineNativeTypes[] { TimelineNativeTypes.SmsLog, TimelineNativeTypes.MmsLog }, readableDataBase);
ArrayList<TimelineSummaryItem> actualDBTimeLines = new ArrayList<TimelineSummaryItem>();
for (int i = 0; i < timeLines.size(); i++) {
if (c.moveToPosition(i)) {
actualDBTimeLines.add(ActivitiesTable.getTimelineData(c));
}
}
c.close();
compareTimeLineIds(timeLines, actualDBTimeLines);
for (TimelineSummaryItem timeLineSummary : actualDBTimeLines) {
ActivityItem actualActivityItem = ActivitiesTable.getLatestStatusForContact(timeLineSummary.mContactId, readableDataBase);
assertEquals("the timestamps are not equal!", timeLineSummary.mTimestamp, actualActivityItem.time);
}
Log.i(LOG_TAG, "***** restFetchLatestStatusTimestampForContact SUCCEEDED *****");
}
use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineNativeTypes in project 360-Engine-for-Android by 360.
the class NowPlusActivitiesTableTest method testAddTimelineEvents.
// ///////////////////////////////////////////////TIMELINES////////////////////////////////////////////////
/**
* This method checks that the added time line events are really present
* in the table.
*/
@Suppress
public void testAddTimelineEvents() {
SQLiteDatabase database = mTestDatabase.getWritableDatabase();
ActivitiesTable.create(database);
ArrayList<TimelineSummaryItem> timelineSummaryItemList = TestModule.generateFakeTimeLinesList();
assertEquals("timelineSummaryItemList has size of 25", 25, timelineSummaryItemList.size());
ActivitiesTable.addTimelineEvents(timelineSummaryItemList, false, database);
assertEquals("timelineSummaryItemList has size of 25", 25, timelineSummaryItemList.size());
/**
* Check if the records are there. *
*/
Cursor cursor = null;
ArrayList<TimelineSummaryItem> actualDBTimeLines = null;
try {
cursor = ActivitiesTable.fetchTimelineEventList(YESTERDAY_TIME_MILLIS, new TimelineNativeTypes[] { TimelineNativeTypes.SmsLog, TimelineNativeTypes.MmsLog }, database);
assertEquals("Cursor contains less items than expected!", timelineSummaryItemList.size(), cursor.getCount());
actualDBTimeLines = new ArrayList<TimelineSummaryItem>();
for (int i = 0; i < timelineSummaryItemList.size(); i++) {
if (cursor.moveToPosition(i)) {
actualDBTimeLines.add(ActivitiesTable.getTimelineData(cursor));
}
}
} finally {
CloseUtils.close(cursor);
}
compareTimeLineIds(timelineSummaryItemList, actualDBTimeLines);
}
use of com.vodafone360.people.database.tables.ActivitiesTable.TimelineNativeTypes in project 360-Engine-for-Android by 360.
the class NowPlusActivitiesTableTest method testUpdateTimelineContactNameAndId3.
/**
* this method checks the updated contacts are present in the database
*/
@Suppress
public void testUpdateTimelineContactNameAndId3() {
Log.i(LOG_TAG, "***** testUpdateTimelineContactNameAndId3: create table *****");
SQLiteDatabase writableDataBase = mTestDatabase.getWritableDatabase();
ActivitiesTable.create(writableDataBase);
Log.i(LOG_TAG, "***** testUpdateTimelineContactNameAndId3 , not call log though *****");
ArrayList<TimelineSummaryItem> timeLines = TestModule.generateFakeTimeLinesList();
ActivitiesTable.addTimelineEvents(timeLines, false, writableDataBase);
// check if the records are there
SQLiteDatabase readableDataBase = mTestDatabase.getReadableDatabase();
Cursor c = ActivitiesTable.fetchTimelineEventList(YESTERDAY_TIME_MILLIS, new TimelineNativeTypes[] { TimelineNativeTypes.SmsLog, TimelineNativeTypes.MmsLog }, readableDataBase);
ArrayList<TimelineSummaryItem> actualDBTimeLines = new ArrayList<TimelineSummaryItem>();
for (int i = 0; i < timeLines.size(); i++) {
if (c.moveToPosition(i)) {
actualDBTimeLines.add(ActivitiesTable.getTimelineData(c));
}
}
compareTimeLineIds(timeLines, actualDBTimeLines);
final String NAME = "New";
for (TimelineSummaryItem timeLineSummary : timeLines) {
timeLineSummary.mContactName += NAME;
ActivitiesTable.updateTimelineContactNameAndId(timeLineSummary.mContactName, timeLineSummary.mLocalContactId, writableDataBase);
}
c.requery();
actualDBTimeLines.clear();
for (int i = 0; i < timeLines.size(); i++) {
if (c.moveToPosition(i)) {
actualDBTimeLines.add(ActivitiesTable.getTimelineData(c));
}
}
compareTimeLineIds(timeLines, actualDBTimeLines);
Log.i(LOG_TAG, "***** testUpdateTimelineContactNameAndId3 SUCCEEDED *****");
}
Aggregations