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);
}
}
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");
}
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);
}
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;
}
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);
}
Aggregations