Search in sources :

Example 36 with BaseDataType

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

the class DownloadServerContactsTest method reportBackWithDeletedContacts.

private void reportBackWithDeletedContacts(int reqId, List<BaseDataType> data) {
    Log.d(LOG_TAG, "reportBackWithDeletedContacts");
    Integer pageNo = mProcessor.testGetPageFromReqId(reqId);
    int pageSize = mProcessor.getDownloadPageSize();
    assertTrue(pageNo != null);
    assertEquals(Integer.valueOf(mPageCount), pageNo);
    ContactChanges contactChanges = new ContactChanges();
    data.add(contactChanges);
    contactChanges.mCurrentServerVersion = CURRENT_SERVER_VERSION;
    contactChanges.mServerRevisionBefore = CURRENT_SERVER_VERSION;
    contactChanges.mServerRevisionAfter = CURRENT_SERVER_VERSION;
    contactChanges.mVersionAnchor = CURRENT_SERVER_VERSION;
    assertTrue(pageSize > 0);
    if (pageSize > 0) {
        contactChanges.mNumberOfPages = 1 + mPageCount + (mItemCount / pageSize);
    }
    int noOfContacts = Math.min(pageSize, mItemCount);
    for (int i = 0; i < noOfContacts; i++) {
        Contact deletedContact = new Contact();
        deletedContact.contactID = FIRST_MODIFIED_CONTACT_ID + mItemCount - 1;
        deletedContact.deleted = true;
        contactChanges.mContacts.add(deletedContact);
        mItemCount--;
    }
    mPageCount++;
    assertTrue(mItemCount >= 0);
    if (mItemCount == 0) {
        nextState(State.IDLE);
    }
}
Also used : ContactChanges(com.vodafone360.people.datatypes.ContactChanges) Contact(com.vodafone360.people.datatypes.Contact)

Example 37 with BaseDataType

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

the class UploadServerContactsTest method reportModifyContactSuccess.

private void reportModifyContactSuccess(int reqId, List<BaseDataType> data) {
    Log.d(LOG_TAG, "reportModifyContactSuccess");
    mProcessor.verifyModifyDetailsState();
    List<Contact> contactChangeList = new ArrayList<Contact>();
    mProcessor.testFetchContactChangeList(contactChangeList);
    assertEquals(Math.min(mItemCount, mProcessor.testGetPageSize()), contactChangeList.size());
    ContactChanges contactChanges = new ContactChanges();
    contactChanges.mServerRevisionAfter = 1;
    contactChanges.mServerRevisionBefore = 0;
    data.add(contactChanges);
    for (int i = 0; i < contactChangeList.size(); i++) {
        Contact actualContact = contactChangeList.get(i);
        assertTrue(actualContact.contactID != null);
        assertEquals(null, actualContact.aboutMe);
        assertEquals(null, actualContact.profilePath);
        assertEquals(null, actualContact.deleted);
        assertEquals(null, actualContact.friendOfMine);
        assertEquals(null, actualContact.gender);
        assertEquals(null, actualContact.groupList);
        assertEquals(null, actualContact.sources);
        assertEquals(null, actualContact.synctophone);
        assertEquals(null, actualContact.updated);
        assertEquals(null, actualContact.userID);
        assertEquals(2, actualContact.details.size());
        // Modified
        ContactDetail modDetail = actualContact.details.get(0);
        // detail
        // always
        // first
        ContactDetail newDetail = actualContact.details.get(1);
        assertEquals(NEW_DETAIL_VALUE, newDetail.value);
        assertEquals(NEW_DETAIL_KEY, newDetail.key);
        assertEquals(NEW_DETAIL_TYPE, newDetail.keyType);
        assertEquals(MOD_DETAIL_VALUE, modDetail.value);
        assertEquals(MOD_DETAIL_KEY, modDetail.key);
        assertEquals(MOD_DETAIL_TYPE, modDetail.keyType);
        mReplyContact = new Contact();
        mReplyContact.contactID = actualContact.contactID;
        mReplyContact.userID = generateTestUserID(mReplyContact.contactID);
        ContactDetail replyDetail1 = new ContactDetail();
        ContactDetail replyDetail2 = new ContactDetail();
        replyDetail1.key = modDetail.key;
        replyDetail1.unique_id = modDetail.unique_id;
        replyDetail2.key = newDetail.key;
        replyDetail2.unique_id = newDetail.localDetailID + 2;
        mReplyContact.details.add(replyDetail1);
        mReplyContact.details.add(replyDetail2);
        contactChanges.mContacts.add(mReplyContact);
    }
    mItemCount -= contactChangeList.size();
    assertTrue(mItemCount >= 0);
    if (mItemCount == 0) {
        nextState(State.IDLE);
    }
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ArrayList(java.util.ArrayList) ContactChanges(com.vodafone360.people.datatypes.ContactChanges) Contact(com.vodafone360.people.datatypes.Contact)

Example 38 with BaseDataType

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

the class HessianDecoder method parsePushMessage.

private void parsePushMessage(List<BaseDataType> list, Hashtable<String, Object> hash) {
    RpgPushMessage push = RpgPushMessage.createFromHashtable(hash);
    parsePushPayload(push, list);
}
Also used : RpgPushMessage(com.vodafone360.people.service.io.rpg.RpgPushMessage)

Example 39 with BaseDataType

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

the class SyncMeEngine method processPushEvent.

/**
 * This method process the "pc" push event.
 * @param resp Response - server response normally containing a "pc"
 *            PushEvent data type
 * @return boolean - TRUE if a push event was found in the response
 */
private boolean processPushEvent(final DecodedResponse resp) {
    if (resp.mDataTypes == null || resp.mDataTypes.size() == 0) {
        return false;
    }
    BaseDataType dataType = resp.mDataTypes.get(0);
    if ((dataType == null) || dataType.getType() != BaseDataType.PUSH_EVENT_DATA_TYPE) {
        return false;
    }
    PushEvent pushEvent = (PushEvent) dataType;
    LogUtils.logV("SyncMeEngine processPushMessage():" + pushEvent.mMessageType);
    switch(pushEvent.mMessageType) {
        case PROFILE_CHANGE:
            addGetMeProfileContactRequest();
            break;
        default:
            break;
    }
    return true;
}
Also used : PushEvent(com.vodafone360.people.datatypes.PushEvent) BaseDataType(com.vodafone360.people.datatypes.BaseDataType)

Example 40 with BaseDataType

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

the class IdentityEngine method handleGetAvailableIdentitiesResponse.

/**
 * Handle Server response to request for available Identities. The response
 * should be a list of Identity items. The request is completed with
 * ServiceStatus.SUCCESS or ERROR_UNEXPECTED_RESPONSE if the data-type
 * retrieved are not Identity items.
 *
 * @param data List of BaseDataTypes generated from Server response.
 */
private void handleGetAvailableIdentitiesResponse(List<BaseDataType> data) {
    LogUtils.logD("IdentityEngine: handleServerGetAvailableIdentitiesResponse");
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.AVAILABLE_IDENTITY_DATA_TYPE, data);
    if (errorStatus == ServiceStatus.SUCCESS) {
        synchronized (mAvailableIdentityList) {
            mAvailableIdentityList.clear();
            for (BaseDataType item : data) {
                Identity identity = (Identity) item;
                if (!identity.isIdentityFieldBlankorNull()) {
                    mAvailableIdentityList.add(identity);
                }
            }
        }
    }
    pushIdentitiesToUi(ServiceUiRequest.GET_AVAILABLE_IDENTITIES);
    LogUtils.logD("IdentityEngine: handleGetAvailableIdentitiesResponse complete request.");
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) Identity(com.vodafone360.people.datatypes.Identity)

Aggregations

BaseDataType (com.vodafone360.people.datatypes.BaseDataType)29 ArrayList (java.util.ArrayList)25 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)21 ServiceStatus (com.vodafone360.people.service.ServiceStatus)15 ServerError (com.vodafone360.people.datatypes.ServerError)12 MediumTest (android.test.suitebuilder.annotation.MediumTest)9 Contact (com.vodafone360.people.datatypes.Contact)9 IOException (java.io.IOException)9 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)8 Identity (com.vodafone360.people.datatypes.Identity)7 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)7 HessianDecoder (com.vodafone360.people.service.utils.hessian.HessianDecoder)7 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)6 ExternalResponseObject (com.vodafone360.people.datatypes.ExternalResponseObject)5 PushEvent (com.vodafone360.people.datatypes.PushEvent)5 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)5 Bundle (android.os.Bundle)3 Suppress (android.test.suitebuilder.annotation.Suppress)3 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)3 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)3