Search in sources :

Example 31 with BaseDataType

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

the class SyncMeEngineTest method testPushMessage.

@Suppress
@MediumTest
public void testPushMessage() {
    setUpContactSyncMeEngineTestFramework();
    PushEvent evt = new PushEvent();
    evt.mMessageType = PushMessageTypes.PROFILE_CHANGE;
    List<BaseDataType> data = new ArrayList<BaseDataType>();
    data.add(evt);
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    ResponseQueue.getInstance().addToResponseQueue(new DecodedResponse(0, data, mEngine.engineId(), DecodedResponse.ResponseType.PUSH_MESSAGE.ordinal()));
    mEngine.onCommsInMessage();
    // see if anything happens
    assertEquals("Expected SUCCESS, not timeout", ServiceStatus.SUCCESS, mEngineTester.waitForEvent());
    Object retdata = mEngineTester.data();
    assertTrue(retdata == null);
    Log.i(LOG_TAG, "**** testPushMessage (SUCCESS) ****\n");
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) PushEvent(com.vodafone360.people.datatypes.PushEvent) ArrayList(java.util.ArrayList) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 32 with BaseDataType

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

the class EngineTestFramework method reportBackToFramework.

@Override
public void reportBackToFramework(int reqId, EngineId engine) {
    Log.d("TAG", "EngineTestFramework.reportBackToFramework");
    mObserver.reportBackToEngine(reqId, engine);
    final QueueManager reqQ = QueueManager.getInstance();
    final ResponseQueue respQ = ResponseQueue.getInstance();
    if (reqQ.getRequest(reqId) != null) {
        List<BaseDataType> dataTypeList = new ArrayList<BaseDataType>();
        ServerError err = new ServerError(ServerError.ErrorType.UNKNOWN);
        dataTypeList.add(err);
        respQ.addToResponseQueue(new DecodedResponse(reqId, dataTypeList, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) ServerError(com.vodafone360.people.datatypes.ServerError) ArrayList(java.util.ArrayList) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue) QueueManager(com.vodafone360.people.service.io.QueueManager)

Example 33 with BaseDataType

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

the class EngineTestFramework method callRun.

public void callRun(int reqId, List<BaseDataType> data) {
    ResponseQueue.getInstance().addToResponseQueue(new DecodedResponse(reqId, data, mEngine.engineId(), DecodedResponse.ResponseType.UNKNOWN.ordinal()));
    try {
        mEngine.onCommsInMessage();
        mEngine.run();
    } catch (Exception e) {
        onEngineException(e);
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)

Example 34 with BaseDataType

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

the class DownloadServerContactsTest method reportBackWithDeletedDetails.

private void reportBackWithDeletedDetails(int reqId, List<BaseDataType> data) {
    Log.d(LOG_TAG, "reportBackWithDeletedDetails");
    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 curContact = new Contact();
        curContact.contactID = FIRST_MODIFIED_CONTACT_ID + mItemCount - 1;
        contactChanges.mContacts.add(curContact);
        ContactDetail delDetail1 = new ContactDetail();
        delDetail1.key = ContactDetail.DetailKeys.VCARD_NAME;
        delDetail1.deleted = true;
        ContactDetail delDetail2 = new ContactDetail();
        delDetail2.key = ContactDetail.DetailKeys.VCARD_NICKNAME;
        delDetail2.deleted = true;
        ContactDetail delDetail3 = new ContactDetail();
        delDetail3.key = ContactDetail.DetailKeys.VCARD_EMAIL;
        delDetail3.unique_id = NEW_EMAIL_DETAIL_ID + mItemCount - 1;
        delDetail3.deleted = true;
        curContact.details.add(delDetail1);
        curContact.details.add(delDetail2);
        curContact.details.add(delDetail3);
        mItemCount--;
    }
    mPageCount++;
    assertTrue(mItemCount >= 0);
    if (mItemCount == 0) {
        nextState(State.IDLE);
    }
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ContactChanges(com.vodafone360.people.datatypes.ContactChanges) Contact(com.vodafone360.people.datatypes.Contact)

Example 35 with BaseDataType

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

the class DownloadServerContactsTest method reportBackWithNewContacts.

private void reportBackWithNewContacts(int reqId, List<BaseDataType> data) {
    Log.d(LOG_TAG, "reportBackWithNewContacts");
    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 newContact = mTestModule.createDummyContactData();
        if (mLastNewContact == null) {
            mLastNewContact = newContact;
        }
        newContact.contactID = FIRST_MODIFIED_CONTACT_ID + mItemCount - 1;
        newContact.userID = generateTestUserID(newContact.contactID);
        ContactDetail detail1 = new ContactDetail();
        detail1.key = ContactDetail.DetailKeys.VCARD_PHONE;
        detail1.unique_id = OLD_PHONE_DETAIL_ID + mItemCount - 1;
        detail1.value = OLD_PHONE_DETAIL_VALUE;
        newContact.details.add(detail1);
        for (int j = 0; j < newContact.details.size(); j++) {
            ContactDetail detail = newContact.details.get(j);
            switch(detail.key) {
                case VCARD_PHONE:
                case VCARD_EMAIL:
                    if (detail.unique_id == null) {
                        detail.unique_id = ALT_PHONE_DETAIL_ID + j;
                    }
                    break;
            }
        }
        contactChanges.mContacts.add(newContact);
        mItemCount--;
    }
    mPageCount++;
    assertTrue(mItemCount >= 0);
    if (mItemCount == 0) {
        nextState(State.IDLE);
    }
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ContactChanges(com.vodafone360.people.datatypes.ContactChanges) Contact(com.vodafone360.people.datatypes.Contact)

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