Search in sources :

Example 6 with ActivityItem

use of com.vodafone360.people.datatypes.ActivityItem in project 360-Engine-for-Android by 360.

the class NowPlusActivitiesTableTest method testDeleteActivities.

/**
     * this test checks that the deleted activities are not really present in the DB
     */
public void testDeleteActivities() {
    SQLiteDatabase db = mTestDatabase.getWritableDatabase();
    ActivitiesTable.create(db);
    /** Create dummy activities list. **/
    List<ActivityItem> activitiesList = mTestModule.createFakeActivitiesList();
    assertEquals("activitiesList is the wrong size", 25, activitiesList.size());
    /** Add activities list to database. **/
    assertEquals("ActivitiesTable.addActivities was unsuccessfull", ServiceStatus.SUCCESS, ActivitiesTable.addActivities(activitiesList, db, mContext));
    assertEquals("activitiesList is the wrong size", 25, activitiesList.size());
    /** Check if the records are in the database. **/
    List<Long> insertedDbIds = new ArrayList<Long>();
    ActivitiesTable.fetchActivitiesIds(insertedDbIds, YESTERDAY_TIME_MILLIS, db);
    for (ActivityItem item : activitiesList) {
        assertNotNull("item.mActivityId should not be NULL", item.activityId);
        assertNotNull("item.mLocalActivityId should not be NULL", item.localActivityId);
        assertNotNull("item.mTitle should not be NULL", item.title);
    }
    /** Delete all activities regardless of flag. **/
    assertEquals(ServiceStatus.SUCCESS, ActivitiesTable.deleteActivities(null, db));
    /** Check that the database is now empty. **/
    List<Long> actualDBIds = new ArrayList<Long>();
    ActivitiesTable.fetchActivitiesIds(actualDBIds, YESTERDAY_TIME_MILLIS, db);
    assertEquals("Activitiess table is not empty after deletion", 0, actualDBIds.size());
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

Example 7 with ActivityItem

use of com.vodafone360.people.datatypes.ActivityItem 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 *****");
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) TimelineSummaryItem(com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem) Cursor(android.database.Cursor) ActivityItem(com.vodafone360.people.datatypes.ActivityItem) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 8 with ActivityItem

use of com.vodafone360.people.datatypes.ActivityItem in project 360-Engine-for-Android by 360.

the class HessianDecoderTest method testActivityListResponse.

@MediumTest
public void testActivityListResponse() {
    //boolean testPassed = true;
    List<BaseDataType> clist = new ArrayList<BaseDataType>();
    HessianDecoder hess = new HessianDecoder();
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(5, testActivityList, Type.COMMON, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    int size = clist.size();
    assertTrue(size == 2);
    assertTrue(clist.get(0) instanceof ActivityItem);
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) ArrayList(java.util.ArrayList) HessianDecoder(com.vodafone360.people.service.utils.hessian.HessianDecoder) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) IOException(java.io.IOException) ActivityItem(com.vodafone360.people.datatypes.ActivityItem) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 9 with ActivityItem

use of com.vodafone360.people.datatypes.ActivityItem in project 360-Engine-for-Android by 360.

the class NowPlusActivitiesTableTest method testAddActivities.

/**
	 *  The method adds activities into a table and check whether they are really present there
	 */
public void testAddActivities() {
    Log.i(LOG_TAG, "***** testAddActivities *****");
    SQLiteDatabase writableDataBase = mTestDatabase.getWritableDatabase();
    ActivitiesTable.create(writableDataBase);
    List<ActivityItem> activitiesList = mTestModule.createFakeActivitiesList();
    ServiceStatus status = ActivitiesTable.addActivities(activitiesList, writableDataBase, mContext);
    assertEquals("Activities not added to the table", ServiceStatus.SUCCESS, status);
    Log.i(LOG_TAG, "***** testAddActivities: activities added *****");
    // check if the records are there
    List<Long> activitiesIds = new ArrayList<Long>();
    for (ActivityItem item : activitiesList) {
        activitiesIds.add(item.activityId);
    }
    SQLiteDatabase readableDataBase = mTestDatabase.getReadableDatabase();
    List<Long> actualDBIds = new ArrayList<Long>();
    status = null;
    status = ActivitiesTable.fetchActivitiesIds(actualDBIds, YESTERDAY_TIME_MILLIS, readableDataBase);
    assertEquals("Fetching activities from the table failed", ServiceStatus.SUCCESS, status);
    Log.i(LOG_TAG, "***** testAddActivities: activities added *****");
    compareActivityIds(activitiesIds, actualDBIds);
    Log.i(LOG_TAG, "***** SUCCEEDED testAddActivities *****");
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

Example 10 with ActivityItem

use of com.vodafone360.people.datatypes.ActivityItem in project 360-Engine-for-Android by 360.

the class TestModule method createFakeStatusEventList.

/**
	 * TODO: fill in the method properly
	 * @return
	 */
public List<ActivityItem> createFakeStatusEventList() {
    List<ActivityItem> activityList = new ArrayList<ActivityItem>();
    for (int i = 0; i < TABLE_SIZE; i++) {
        ActivityItem activityItem = new ActivityItem();
        /** Unique identifier for the activity. This can be empty when setting 
			 * a new activity (the id is generated on the server side) */
        activityItem.activityId = System.currentTimeMillis();
        /** Timestamp representing the time of the activity. 
			 * This may not be related to creation/updated time. */
        activityItem.time = System.currentTimeMillis();
        /** local id for db */
        //			activityItem.mLocalId; set by DB insertion
        //			activityItem.mMoreInfo; //new Hashtable<ActivityItem, String>
        /** The parent activity for 'grouped' or aggregated activities. This must be empty 
			 * for normal activities that can be retrieved normally. Normally, a GetActivities 
			 * without filter will not yield any 'grouped' or 'child' activities. 
			 * To get activities that have a mParentActivity set, the 'children' filter must 
			 * be used with a value of the parent Activity's id.*/
        //			activityItem.mParentActivity; // null
        /** Indicates wether this activity 'groups' several child activities. When set, 
			 * there must be child activities set that refer the main activity. Normally, 
			 * a GetActivities without filter will not yield any 'grouped' or 'child' activities. 
			 * To get activities that have a parentactivity set, the 'children' filter 
			 * must be used with a value of the parent Activity's id.*/
        //			activityItem.mHasChildren = false;
        /** Defines a binary preview for the activity. The preview can be a small thumbnail 
			 * of the activity. The type of the binary data is defined into the previewmime field.*/
        //			keep null
        //			activityItem.mPreview = ByteBuffer.allocate(bytes.length);
        //			activityItem.mPreviewMime;
        /** Defines an http url that the client can use to retrieve preview binary data. 
			 * Can be used to embed the url into an IMG HTML tag.*/
        //			activityItem.mPreviewUrl
        /** Name of the store type for this message. This field contains information about the 
			 * originator network (local or external community activity). 
			 * By default, should be set to local*/
        activityItem.store = "local";
        activityItem.title = generateRandomString();
        activityItem.description = activityItem.description + activityItem.store;
        /** Defines the type of the activity. */
        activityItem.type = Type.CONTACT_RECEIVED_STATUS_UPDATE;
        /** Defines an internal reference (if any) to the source of the activity. 
			 * The format for the uri is "module:identifier".Some examples of valid uri are:
			 * contact:2737b322c9f6476ca152aa6cf3e5ac12 The activity is linked to some 
			 * changes on a contact identified by id=2737b322c9f6476ca152aa6cf3e5ac12.
			 * file:virtual/flickr/2590004126 The activity is linked to some actions 
			 * on a file identified by id=virtual/flickr/2590004126.
			 * message:9efd255359074dd9bd04cc1c8c4743e5 The activity is linked to a message 
			 * identified by id=9efd255359074dd9bd04cc1c8c4743e5 */
        activityItem.uri = "virtual/flickr/2590004126";
        //can be 0		activityItem.mActivityFlags;
        /** Miscellaneous flags.*/
        activityItem.flagList = new ArrayList<Flag>();
        activityItem.flagList.add(Flag.STATUS);
        activityItem.activityFlags = 0x04;
        /** Defines the contact information of the counter-parties in the activity. 
			 * This field is not mandatory, because some activity types 
			 * are not related to contacts, but required if known.. */
        //keep it simple - empty		activityItem.mContactList = ;
        activityItem.visibility = new ArrayList<Visibility>();
        activityItem.visibility.add(Visibility.ORIGINATOR);
        //keep it 0		activityItem.mVisibilityFlags = 0;
        activityList.add(activityItem);
    }
    return activityList;
}
Also used : ArrayList(java.util.ArrayList) Visibility(com.vodafone360.people.datatypes.ActivityItem.Visibility) Flag(com.vodafone360.people.datatypes.ActivityItem.Flag) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

Aggregations

ActivityItem (com.vodafone360.people.datatypes.ActivityItem)13 ArrayList (java.util.ArrayList)10 ServiceStatus (com.vodafone360.people.service.ServiceStatus)7 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)5 ActivityContact (com.vodafone360.people.datatypes.ActivityContact)5 Cursor (android.database.Cursor)3 MediumTest (android.test.suitebuilder.annotation.MediumTest)3 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)3 ContentValues (android.content.ContentValues)2 Flag (com.vodafone360.people.datatypes.ActivityItem.Flag)2 Visibility (com.vodafone360.people.datatypes.ActivityItem.Visibility)2 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)2 SQLException (android.database.SQLException)1 SQLiteStatement (android.database.sqlite.SQLiteStatement)1 Suppress (android.test.suitebuilder.annotation.Suppress)1 TimelineSummaryItem (com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem)1 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)1 Identity (com.vodafone360.people.datatypes.Identity)1 ServerError (com.vodafone360.people.datatypes.ServerError)1 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)1