Search in sources :

Example 6 with BaseDataType

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

the class UploadServerContactsTest method reportDeleteContactDetailSuccess.

private void reportDeleteContactDetailSuccess(int reqId, List<BaseDataType> data) {
    Log.d(LOG_TAG, "reportDeleteContactDetailSuccess");
    mProcessor.verifyDeleteDetailsState();
    Contact contact = new Contact();
    mProcessor.testFetchContactDetailDeleteList(contact);
    assertEquals(2, contact.details.size());
    assertEquals(ContactDetail.DetailKeys.VCARD_NAME, contact.details.get(0).key);
    assertEquals(ContactDetail.DetailKeys.VCARD_PHONE, contact.details.get(1).key);
    ContactDetailDeletion contactDetailDeletion = new ContactDetailDeletion();
    contactDetailDeletion.mServerVersionAfter = 1;
    contactDetailDeletion.mServerVersionBefore = 0;
    data.add(contactDetailDeletion);
    contactDetailDeletion.mContactId = contact.contactID.intValue();
    contactDetailDeletion.mDetails = new ArrayList<ContactDetail>();
    for (ContactDetail detail : contact.details) {
        ContactDetail tempDetail = new ContactDetail();
        tempDetail.key = detail.key;
        tempDetail.unique_id = detail.unique_id;
        contactDetailDeletion.mDetails.add(tempDetail);
    }
    mItemCount--;
    assertTrue(mItemCount >= 0);
    if (mItemCount == 0) {
        nextState(State.IDLE);
    }
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ContactDetailDeletion(com.vodafone360.people.datatypes.ContactDetailDeletion) Contact(com.vodafone360.people.datatypes.Contact)

Example 7 with BaseDataType

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

the class UploadServerContactsTest method reportBackAddContactSuccess.

private void reportBackAddContactSuccess(int reqId, List<BaseDataType> data) {
    Log.d(LOG_TAG, "reportBackAddContactSuccess");
    mProcessor.verifyNewContactsState();
    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);
        Contact expectedContact = new Contact();
        ServiceStatus status = mDb.fetchContact(actualContact.localContactID, expectedContact);
        assertEquals(ServiceStatus.SUCCESS, status);
        assertEquals(expectedContact.details.size(), actualContact.details.size());
        assertEquals(null, actualContact.aboutMe);
        assertEquals(null, actualContact.profilePath);
        assertEquals(null, actualContact.contactID);
        assertEquals(null, actualContact.deleted);
        assertEquals(null, actualContact.friendOfMine);
        assertEquals(null, actualContact.gender);
        assertEquals(null, actualContact.groupList);
        assertEquals(null, actualContact.sources);
        assertEquals(expectedContact.synctophone, actualContact.synctophone);
        assertEquals(null, actualContact.updated);
        assertEquals(null, actualContact.userID);
        final ListIterator<ContactDetail> itActDetails = actualContact.details.listIterator();
        for (ContactDetail expDetail : expectedContact.details) {
            ContactDetail actDetail = itActDetails.next();
            assertTrue(DatabaseHelper.doDetailsMatch(expDetail, actDetail));
            assertFalse(DatabaseHelper.hasDetailChanged(expDetail, actDetail));
        }
        generateReplyContact(expectedContact);
        contactChanges.mContacts.add(mReplyContact);
    }
    mItemCount -= contactChangeList.size();
    assertTrue(mItemCount >= 0);
    if (mItemCount == 0) {
        mInitialCount = mInitialContactGroupCount;
        nextState(State.ADD_NEW_GROUP_LIST);
    }
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) ContactChanges(com.vodafone360.people.datatypes.ContactChanges) Contact(com.vodafone360.people.datatypes.Contact)

Example 8 with BaseDataType

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

the class UploadServerContactsTest method reportBackToEngine.

@Override
public void reportBackToEngine(int reqId, EngineId engine) {
    Log.d(LOG_TAG, "reportBackToEngine");
    ResponseQueue respQueue = ResponseQueue.getInstance();
    List<BaseDataType> data = new ArrayList<BaseDataType>();
    try {
        assertEquals(mEng.engineId(), engine);
        synchronized (mEng.mWaitForReqIdLock) {
            if (mEng.mActiveReqId == null || mEng.mActiveReqId.intValue() != reqId) {
                try {
                    mEng.mWaitForReqIdLock.wait(MAX_WAIT_FOR_REQ_ID);
                } catch (InterruptedException e) {
                }
                assertEquals(Integer.valueOf(reqId), mEng.mActiveReqId);
            }
        }
        switch(mState) {
            case ADD_CONTACT_LIST:
                reportBackAddContactSuccess(reqId, data);
                break;
            case MODIFY_CONTACT_LIST:
                reportModifyContactSuccess(reqId, data);
                break;
            case DELETE_CONTACT_LIST:
                reportDeleteContactSuccess(reqId, data);
                break;
            case DELETE_CONTACT_DETAIL_LIST:
                reportDeleteContactDetailSuccess(reqId, data);
                break;
            case ADD_NEW_GROUP_LIST:
                reportBackAddGroupSuccess(reqId, data);
                break;
            case DELETE_GROUP_LIST:
                reportDeleteGroupListSuccess(reqId, data);
                break;
            default:
                fail("Unexpected request from processor");
        }
    } catch (Throwable err) {
        ServerError serverError = new ServerError(ServerError.ErrorType.INTERNALERROR);
        serverError.errorDescription = err + "\n";
        for (int i = 0; i < err.getStackTrace().length; i++) {
            StackTraceElement v = err.getStackTrace()[i];
            serverError.errorDescription += "\t" + v + "\n";
        }
        Log.e(LOG_TAG, "Exception:\n" + serverError.errorDescription);
        data.clear();
        data.add(serverError);
    }
    respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
    mEng.onCommsInMessage();
    Log.d(LOG_TAG, "reportBackToEngine - message added to response queue");
}
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)

Example 9 with BaseDataType

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

the class PeopleServiceTest method reportBackToFramework.

@Override
public void reportBackToFramework(int reqId, EngineId engine) {
    /*
		 * We are not interested in testing specific engines in those tests then for all kind of 
		 * requests we will return error because it is handled by all engines, just to finish flow.
		 */
    ResponseQueue respQueue = ResponseQueue.getInstance();
    List<BaseDataType> data = new ArrayList<BaseDataType>();
    ServerError se1 = new ServerError(ServerError.ErrorType.INTERNALERROR);
    se1.errorDescription = "Test error produced by test framework, ignore it";
    data.add(se1);
    respQueue.addToResponseQueue(new DecodedResponse(reqId, data, 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)

Example 10 with BaseDataType

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

the class HessianDecoder method parseExternalResponse.

private void parseExternalResponse(List<BaseDataType> clist, InputStream is, int tag) throws IOException {
    mMicroHessianInput.init(is);
    ExternalResponseObject resp = new ExternalResponseObject();
    // now we read and check the response code
    if (mMicroHessianInput.readInt(tag) != 200) {
        return;
    }
    try {
        resp.mMimeType = mMicroHessianInput.readString();
    } catch (IOException ioe) {
        LogUtils.logE("Failed to parse hessian string.");
        return;
    }
    // read data - could be gzipped
    try {
        resp.mBody = mMicroHessianInput.readBytes();
    } catch (IOException ioe) {
        LogUtils.logE("Failed to read bytes.");
        return;
    }
    LogUtils.logI("HessianDecoder.parseExternalResponse()" + " Parsed external object with length: " + resp.mBody.length);
    clist.add(resp);
}
Also used : ExternalResponseObject(com.vodafone360.people.datatypes.ExternalResponseObject) IOException(java.io.IOException)

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