Search in sources :

Example 51 with BaseDataType

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

Example 52 with BaseDataType

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

the class HessianDecoderTest method testIdentityListResponse.

@MediumTest
public void testIdentityListResponse() {
    // boolean testPassed = true;
    List<BaseDataType> clist = new ArrayList<BaseDataType>();
    HessianDecoder hess = new HessianDecoder();
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(4, testIdentityListData, 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 Identity);
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) ArrayList(java.util.ArrayList) HessianDecoder(com.vodafone360.people.service.utils.hessian.HessianDecoder) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) IOException(java.io.IOException) Identity(com.vodafone360.people.datatypes.Identity) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 53 with BaseDataType

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

the class ActivitiesEngine method handleGetActivitiesResponse.

/**
 * Handle GetActivities response message received from Server
 *
 * @param reqId Request ID contained in response. This should match an ID of
 *            a request we have issued to the Server.
 * @param data List array of ActivityItem items returned from Server.
 */
private void handleGetActivitiesResponse(List<BaseDataType> data) {
    /**
     * Array of Activities retrieved from Server.
     */
    ArrayList<ActivityItem> activityList = new ArrayList<ActivityItem>();
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.ACTIVITY_ITEM_DATA_TYPE, data);
    LogUtils.logE("ActivityEngine.handleGetActivitiesResponse status from generic = " + errorStatus);
    if (ServiceStatus.SUCCESS == errorStatus) {
        for (BaseDataType item : data) {
            if (item.getType() == BaseDataType.ACTIVITY_ITEM_DATA_TYPE) {
                activityList.add((ActivityItem) item);
            } else {
                LogUtils.logE("ActivityEngine.handleGetActivitiesResponse will not handle strange type = " + item.getType());
            }
        }
        errorStatus = updateDatabase(activityList);
    // we set timeout for the next execution
    }
    // this method will then call completeUiRequest(status, null);
    onSyncHelperComplete(errorStatus);
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

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