Search in sources :

Example 6 with PushEvent

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

the class ActivitiesEngine method processCommsResponse.

/**
 * Handle response received from transport layer (via EngineManager)
 *
 * @param resp Received Response item either a Status/Timeline related push
 *            message or a response to a get activities request.
 */
@Override
protected void processCommsResponse(DecodedResponse resp) {
    LogUtils.logD("ActivitiesEngine processCommsResponse");
    // handle push response
    if (resp.mReqId == 0 && resp.mDataTypes.size() > 0) {
        PushEvent evt = (PushEvent) resp.mDataTypes.get(0);
        handlePushRequest(evt.mMessageType);
    } else {
        dequeueRequest(resp.mReqId);
        handleGetActivitiesResponse(resp.mDataTypes);
    }
}
Also used : PushEvent(com.vodafone360.people.datatypes.PushEvent)

Example 7 with PushEvent

use of com.vodafone360.people.datatypes.PushEvent 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 8 with PushEvent

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

the class NowPlusDatatypesTests method testCreatePushEvent.

public void testCreatePushEvent() {
    RpgPushMessage msg = new RpgPushMessage();
    msg.mType = PushMessageTypes.CONTACTS_CHANGE;
    EngineId engId = EngineId.ACTIVITIES_ENGINE;
    PushEvent input = (PushEvent) PushEvent.createPushEvent(msg, engId);
    assertEquals(BaseDataType.PUSH_EVENT_DATA_TYPE, input.getType());
    assertEquals(msg.mType, input.mMessageType);
    assertEquals(engId, input.mEngineId);
}
Also used : EngineId(com.vodafone360.people.engine.EngineManager.EngineId) PushEvent(com.vodafone360.people.datatypes.PushEvent) RpgPushMessage(com.vodafone360.people.service.io.rpg.RpgPushMessage)

Example 9 with PushEvent

use of com.vodafone360.people.datatypes.PushEvent 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 10 with PushEvent

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

the class HessianDecoderTest method testPushMessages.

/*
	@MediumTest
	public void testContactChangesResponse(){
		
	}
	*/
@MediumTest
public void testPushMessages() {
    List<BaseDataType> clist = new ArrayList<BaseDataType>();
    HessianDecoder hess = new HessianDecoder();
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(7, testPcPushMsgData, Type.PUSH_MSG, 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 PushEvent);
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(8, testCcPushMsgData, Type.PUSH_MSG, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    size = clist.size();
    assertTrue(size == 1);
    assertTrue(clist.get(0) instanceof PushEvent);
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(9, testSnPushMsgData, Type.PUSH_MSG, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    size = clist.size();
    assertTrue(size == 1);
    assertTrue(clist.get(0) instanceof SystemNotification);
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(10, testSnPushMsgData2, Type.PUSH_MSG, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    size = clist.size();
    assertTrue(size == 1);
    assertTrue(clist.get(0) instanceof SystemNotification);
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(11, testUnknownPushMsgData, Type.PUSH_MSG, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    size = clist.size();
    assertTrue(size == 0);
// assertTrue(clist.get(0) instanceof PushEvent);
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) SystemNotification(com.vodafone360.people.datatypes.SystemNotification) PushEvent(com.vodafone360.people.datatypes.PushEvent) 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

PushEvent (com.vodafone360.people.datatypes.PushEvent)8 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)6 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)4 ArrayList (java.util.ArrayList)4 MediumTest (android.test.suitebuilder.annotation.MediumTest)3 Suppress (android.test.suitebuilder.annotation.Suppress)2 EngineId (com.vodafone360.people.engine.EngineManager.EngineId)2 PushAvailabilityEvent (com.vodafone360.people.datatypes.PushAvailabilityEvent)1 PushChatMessageEvent (com.vodafone360.people.datatypes.PushChatMessageEvent)1 PushClosedConversationEvent (com.vodafone360.people.datatypes.PushClosedConversationEvent)1 ServerError (com.vodafone360.people.datatypes.ServerError)1 SystemNotification (com.vodafone360.people.datatypes.SystemNotification)1 Request (com.vodafone360.people.service.io.Request)1 Type (com.vodafone360.people.service.io.Request.Type)1 RpgPushMessage (com.vodafone360.people.service.io.rpg.RpgPushMessage)1 HessianDecoder (com.vodafone360.people.service.utils.hessian.HessianDecoder)1 IOException (java.io.IOException)1 List (java.util.List)1