Search in sources :

Example 6 with ServerError

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

the class DownloadServerContactsTest 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);
        switch(mState) {
            case RUN_WITH_NO_CHANGES:
                reportBackWithNoChanges(reqId, data);
                break;
            case RUN_WITH_NEW_CONTACTS:
                reportBackWithNewContacts(reqId, data);
                break;
            case RUN_WITH_DELETED_CONTACTS:
                reportBackWithDeletedContacts(reqId, data);
                break;
            case RUN_WITH_MODIFIED_CONTACTS:
                reportBackWithModifiedContacts(reqId, data);
                break;
            case RUN_WITH_DELETED_DETAILS:
                reportBackWithDeletedDetails(reqId, data);
                break;
            default:
                fail("Unexpected request rom 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 7 with ServerError

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

the class ActivitiesEngineTest method reportBackToEngine.

@Override
public void reportBackToEngine(int reqId, EngineId engine) {
    Log.d("TAG", "IdentityEngineTest.reportBackToEngine");
    ResponseQueue respQueue = ResponseQueue.getInstance();
    List<BaseDataType> data = new ArrayList<BaseDataType>();
    switch(mState) {
        case IDLE:
            break;
        case ON_CREATE:
        case ON_DESTROY:
            break;
        case GET_ACTIVITIES_SUCCESS:
            ActivityItem item = new ActivityItem();
            data.add(item);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case GET_TIMELINE_EVENT_FROM_SERVER:
            ActivityItem item2 = new ActivityItem();
            ActivityContact act = new ActivityContact();
            act.mName = "Bill Fleege";
            act.mLocalContactId = new Long(8);
            List<ActivityContact> clist = new ArrayList<ActivityContact>();
            clist.add(act);
            item2.contactList = clist;
            item2.activityFlags = 2;
            item2.type = ActivityItem.Type.CONTACT_JOINED;
            item2.time = System.currentTimeMillis();
            data.add(item2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case GET_POPULATED_ACTIVITIES:
            ActivityItem item3 = new ActivityItem();
            ActivityContact act2 = new ActivityContact();
            act2.mName = "Bill Fleege";
            act2.mLocalContactId = new Long(8);
            List<ActivityContact> clist2 = new ArrayList<ActivityContact>();
            clist2.add(act2);
            item3.contactList = clist2;
            item3.activityFlags = 2;
            item3.type = ActivityItem.Type.CONTACT_JOINED;
            item3.time = System.currentTimeMillis();
            item3.title = "bills new status";
            item3.description = "a description";
            data.add(item3);
            ActivityItem item4 = new ActivityItem();
            item4.contactList = clist2;
            item4.activityFlags = 5;
            item4.type = ActivityItem.Type.CONTACT_JOINED;
            item4.time = System.currentTimeMillis();
            item4.title = "bills new status";
            item4.description = "a description";
            item4.activityId = new Long(23);
            item4.hasChildren = false;
            item4.uri = "uri";
            item4.parentActivity = new Long(0);
            item4.preview = ByteBuffer.allocate(46);
            item4.preview.position(0);
            item4.preview.rewind();
            for (int i = 0; i < 23; i++) {
                item4.preview.putChar((char) i);
            }
            item4.previewMime = "jepg";
            item4.previewUrl = "storeurl";
            item4.store = "google";
            item4.visibilityFlags = 0;
            data.add(item4);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case GET_ACTIVITIES_SERVER_ERR:
            ServerError err = new ServerError("Catastrophe");
            err.errorDescription = "Fail";
            data.add(err);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
            mEng.onCommsInMessage();
            break;
        case GET_ACTIVITIES_UNEXPECTED_RESPONSE:
            StatusMsg msg = new StatusMsg();
            msg.mCode = "ok";
            msg.mDryRun = false;
            msg.mStatus = true;
            data.add(msg);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case SET_STATUS:
            Identity id3 = new Identity();
            data.add(id3);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case ON_SYNC_COMPLETE:
            ServerError err2 = new ServerError("Catastrophe");
            err2.errorDescription = "Fail";
            data.add(err2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
            mEng.onCommsInMessage();
            break;
        case GET_NEXT_RUNTIME:
            break;
        default:
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) StatusMsg(com.vodafone360.people.datatypes.StatusMsg) ServerError(com.vodafone360.people.datatypes.ServerError) ArrayList(java.util.ArrayList) ActivityContact(com.vodafone360.people.datatypes.ActivityContact) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue) Identity(com.vodafone360.people.datatypes.Identity) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

Example 8 with ServerError

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

the class IdentityEngineTest method reportBackToEngine.

@Override
public void reportBackToEngine(int reqId, EngineId engine) {
    Log.d("TAG", "IdentityEngineTest.reportBackToEngine");
    ResponseQueue respQueue = ResponseQueue.getInstance();
    List<BaseDataType> data = new ArrayList<BaseDataType>();
    switch(mState) {
        case IDLE:
            break;
        case FETCH_IDENTITIES:
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
            Identity id = new Identity();
            data.add(id);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
            mEng.onCommsInMessage();
            break;
        case GET_MY_IDENTITIES:
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine Get ids");
            Identity myId = new Identity();
            data.add(myId);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
            mEng.onCommsInMessage();
            break;
        case FETCH_IDENTITIES_FAIL:
            ServerError err = new ServerError("Catastrophe");
            err.errorDescription = "Fail";
            data.add(err);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
            mEng.onCommsInMessage();
            break;
        case SET_IDENTITY_CAPABILTY:
            StatusMsg msg = new StatusMsg();
            msg.mCode = "ok";
            msg.mDryRun = false;
            msg.mStatus = true;
            data.add(msg);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SET_IDENTITY_CAPABILITY_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case VALIDATE_ID_CREDENTIALS_SUCCESS:
            StatusMsg msg2 = new StatusMsg();
            msg2.mCode = "ok";
            msg2.mDryRun = false;
            msg2.mStatus = true;
            data.add(msg2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.VALIDATE_IDENTITY_CREDENTIALS_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case VALIDATE_ID_CREDENTIALS_FAIL:
            ServerError err2 = new ServerError("Catastrophe");
            err2.errorDescription = "Fail";
            data.add(err2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
            mEng.onCommsInMessage();
            break;
        case GET_NEXT_RUNTIME:
            break;
        case GET_CHATABLE_IDENTITIES:
        case FETCH_IDENTITIES_POPULATED:
            Identity id2 = new Identity();
            id2.mActive = true;
            id2.mAuthType = "auth";
            List<String> clist = new ArrayList<String>();
            clist.add("uk");
            clist.add("fr");
            id2.mCountryList = clist;
            id2.mCreated = new Long(0);
            id2.mDisplayName = "Facebook";
            // id2.mIcon2Mime = "jpeg";
            id2.mIconMime = "jpeg";
            try {
                id2.mIcon2Url = new URL("url2");
                id2.mIconUrl = new URL("url");
                id2.mNetworkUrl = new URL("network");
            } catch (Exception e) {
            }
            id2.mIdentityId = "fb";
            id2.mIdentityType = "type";
            id2.mName = "Facebook";
            id2.mNetwork = "Facebook";
            id2.mOrder = 0;
            id2.mPluginId = "";
            id2.mUpdated = new Long(0);
            id2.mUserId = 23;
            id2.mUserName = "user";
            data.add(id2);
            List<IdentityCapability> capList = new ArrayList<IdentityCapability>();
            IdentityCapability idcap = new IdentityCapability();
            idcap.mCapability = IdentityCapability.CapabilityID.sync_contacts;
            idcap.mDescription = "sync cont";
            idcap.mName = "sync cont";
            idcap.mValue = true;
            capList.add(idcap);
            id2.mCapabilities = capList;
            data.add(id2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
            mEng.onCommsInMessage();
            break;
        default:
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) StatusMsg(com.vodafone360.people.datatypes.StatusMsg) ServerError(com.vodafone360.people.datatypes.ServerError) ArrayList(java.util.ArrayList) URL(java.net.URL) IdentityCapability(com.vodafone360.people.datatypes.IdentityCapability) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue) Identity(com.vodafone360.people.datatypes.Identity)

Example 9 with ServerError

use of com.vodafone360.people.datatypes.ServerError 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 ServerError

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

the class HessianDecoderTest method testErrorResponse.

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

Aggregations

BaseDataType (com.vodafone360.people.datatypes.BaseDataType)12 ServerError (com.vodafone360.people.datatypes.ServerError)12 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)12 ArrayList (java.util.ArrayList)11 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)7 Identity (com.vodafone360.people.datatypes.Identity)3 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)3 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)2 Request (com.vodafone360.people.service.io.Request)2 IOException (java.io.IOException)2 MediumTest (android.test.suitebuilder.annotation.MediumTest)1 Suppress (android.test.suitebuilder.annotation.Suppress)1 ActivityContact (com.vodafone360.people.datatypes.ActivityContact)1 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)1 ExternalResponseObject (com.vodafone360.people.datatypes.ExternalResponseObject)1 IdentityCapability (com.vodafone360.people.datatypes.IdentityCapability)1 SimpleText (com.vodafone360.people.datatypes.SimpleText)1 EngineId (com.vodafone360.people.engine.EngineManager.EngineId)1 ServiceStatus (com.vodafone360.people.service.ServiceStatus)1 QueueManager (com.vodafone360.people.service.io.QueueManager)1