Search in sources :

Example 41 with DecodedResponse

use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse in project 360-Engine-for-Android by 360.

the class LoginEngineTest method reportBackToEngine.

@Override
public void reportBackToEngine(int reqId, EngineId engine) {
    Log.d("TAG", "LoginEngineTest.reportBackToEngine");
    ResponseQueue respQueue = ResponseQueue.getInstance();
    List<BaseDataType> data = new ArrayList<BaseDataType>();
    switch(mState) {
        case IDLE:
            break;
        case LOGIN_REQUEST:
        case SMS_RESPONSE_SIGNIN:
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
            StatusMsg msg = new StatusMsg();
            data.add(msg);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            mState = LoginTestState.LOGIN_REQUEST_VALID;
            break;
        case LOGIN_REQUEST_VALID:
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
            AuthSessionHolder sesh = new AuthSessionHolder();
            data.add(sesh);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            mState = LoginTestState.SMS_RESPONSE_SIGNIN;
            break;
        case REGISTRATION:
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine Registration");
            data.add(mTestModule.createDummyContactData());
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SIGNUP_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case REGISTRATION_ERROR:
            data.add(new ServerError(ServerError.ErrorType.UNKNOWN));
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
            mEng.onCommsInMessage();
            break;
        case GET_T_AND_C:
        case FETCH_PRIVACY:
        case USER_NAME_STATE:
            SimpleText txt = new SimpleText();
            txt.addText("Simple text");
            data.add(txt);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_T_AND_C_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case SERVER_ERROR:
            data.add(new ServerError(ServerError.ErrorType.UNKNOWN));
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
            mEng.onCommsInMessage();
            break;
        default:
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) AuthSessionHolder(com.vodafone360.people.datatypes.AuthSessionHolder) StatusMsg(com.vodafone360.people.datatypes.StatusMsg) SimpleText(com.vodafone360.people.datatypes.SimpleText) ServerError(com.vodafone360.people.datatypes.ServerError) ArrayList(java.util.ArrayList) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue)

Example 42 with DecodedResponse

use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse 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 43 with DecodedResponse

use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse 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 44 with DecodedResponse

use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse 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)

Aggregations

DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)26 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)23 ArrayList (java.util.ArrayList)23 ServiceStatus (com.vodafone360.people.service.ServiceStatus)13 ServerError (com.vodafone360.people.datatypes.ServerError)12 IOException (java.io.IOException)10 MediumTest (android.test.suitebuilder.annotation.MediumTest)9 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)8 PushEvent (com.vodafone360.people.datatypes.PushEvent)7 HessianDecoder (com.vodafone360.people.service.utils.hessian.HessianDecoder)7 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)6 Contact (com.vodafone360.people.datatypes.Contact)5 Suppress (android.test.suitebuilder.annotation.Suppress)4 Identity (com.vodafone360.people.datatypes.Identity)4 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)4 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)3 ExternalResponseObject (com.vodafone360.people.datatypes.ExternalResponseObject)3 Request (com.vodafone360.people.service.io.Request)3 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)2 ContactChangeInfo (com.vodafone360.people.database.tables.ContactChangeLogTable.ContactChangeInfo)2