Search in sources :

Example 6 with StatusMsg

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

the class UploadServerContactsTest method reportDeleteGroupListSuccess.

private void reportDeleteGroupListSuccess(int reqId, List<BaseDataType> data) {
    Log.d(LOG_TAG, "reportDeleteGroupListSuccess");
    mProcessor.verifyGroupDelsState();
    final List<Long> contactIdList = new ArrayList<Long>();
    Long activeGroupId = mProcessor.testFetchDeleteGroupList(contactIdList);
    if (mItemCount == 1) {
        assertEquals(Long.valueOf(TEST_GROUP_2), activeGroupId);
    } else if (mItemCount == 2) {
        assertEquals(Long.valueOf(TEST_GROUP_1), activeGroupId);
    } else {
        fail("Unexpected number of groups in delete group list");
    }
    StatusMsg statusMsg = new StatusMsg();
    statusMsg.mStatus = true;
    data.add(statusMsg);
    mItemCount--;
    assertTrue(mItemCount >= 0);
    if (mItemCount == 0) {
        nextState(State.IDLE);
    }
}
Also used : StatusMsg(com.vodafone360.people.datatypes.StatusMsg) ArrayList(java.util.ArrayList)

Example 7 with StatusMsg

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

the class UploadServerContacts method processGroupDeletionsResp.

/**
     * Called when a server response is received during a group/contact delete
     * relation sync. The server change log is updated. Possibly server errors
     * are also handled.
     * 
     * @param resp Response from server.
     */
private void processGroupDeletionsResp(final DecodedResponse resp) {
    ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.STATUS_MSG_DATA_TYPE, resp.mDataTypes);
    if (status == ServiceStatus.SUCCESS) {
        if (resp.mDataTypes.size() == 0) {
            LogUtils.logE("UploadServerContacts." + "processGroupDeletionsResp() " + "Response cannot be empty");
            complete(ServiceStatus.ERROR_COMMS_BAD_RESPONSE);
            return;
        }
        StatusMsg result = (StatusMsg) resp.mDataTypes.get(0);
        if (!result.mStatus.booleanValue()) {
            LogUtils.logE("UploadServerContacts." + "processGroupDeletionsResp() Error deleting group " + "relation, error = " + result.mError);
            complete(ServiceStatus.ERROR_COMMS_BAD_RESPONSE);
        }
        LogUtils.logV("UploadServerContacts." + "processGroupDeletionsResp() Deleted relation");
        long startTime = System.nanoTime();
        mDb.deleteContactChanges(mContactChangeInfoList);
        mDbSyncTime += (System.nanoTime() - startTime);
        mContactChangeInfoList.clear();
        updateProgress();
        sendNextDelGroupRelationsPage();
        return;
    }
    LogUtils.logE("UploadServerContacts.processGroupDeletionsResp() " + "Error deleting group relation, error = " + status);
    complete(status);
}
Also used : StatusMsg(com.vodafone360.people.datatypes.StatusMsg) ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 8 with StatusMsg

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

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

the class IdentityEngineTest method testSetIdentityCapability.

@MediumTest
// Breaks tests.
@Suppress
public void testSetIdentityCapability() {
    mState = IdentityTestState.SET_IDENTITY_CAPABILTY;
    String network = "facebook";
    // Bundle fbund = new Bundle();
    // fbund.putBoolean("sync_contacts", true);
    String identityId = "mikeyb";
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    // AA mEng.addUiSetIdentityCapabilityStatus(network, identityId, fbund);
    mEng.addUiSetIdentityStatus(network, identityId, true);
    ServiceStatus status = mEngineTester.waitForEvent();
    assertEquals(ServiceStatus.SUCCESS, status);
    Object data = mEngineTester.data();
    assertTrue(data != null);
    try {
        ArrayList<StatusMsg> identityList = ((Bundle) data).getParcelableArrayList("data");
        assertTrue(identityList.size() == 1);
    } catch (Exception e) {
        throw (new RuntimeException("Expected identity list with 1 item"));
    }
}
Also used : StatusMsg(com.vodafone360.people.datatypes.StatusMsg) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Bundle(android.os.Bundle) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 10 with StatusMsg

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

the class NowPlusDatatypesTests method testStatusMsg.

public void testStatusMsg() {
    boolean status = true;
    boolean dryRun = true;
    StatusMsg input = new StatusMsg();
    input.mStatus = (Boolean) status;
    input.mDryRun = (Boolean) dryRun;
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    hash.put("status", status);
    hash.put("dryrun", dryRun);
    StatusMsg helper = new StatusMsg();
    StatusMsg output = helper.createFromHashtable(hash);
    assertEquals(BaseDataType.STATUS_MSG_DATA_TYPE, output.getType());
    assertEquals(input.toString(), output.toString());
    assertEquals(input.mStatus, output.mStatus);
    assertEquals(input.mDryRun, output.mDryRun);
}
Also used : StatusMsg(com.vodafone360.people.datatypes.StatusMsg) Hashtable(java.util.Hashtable)

Aggregations

StatusMsg (com.vodafone360.people.datatypes.StatusMsg)8 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)5 ServiceStatus (com.vodafone360.people.service.ServiceStatus)4 ArrayList (java.util.ArrayList)4 Bundle (android.os.Bundle)3 ServerError (com.vodafone360.people.datatypes.ServerError)3 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)3 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)3 Identity (com.vodafone360.people.datatypes.Identity)2 SimpleText (com.vodafone360.people.datatypes.SimpleText)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 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)1 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)1 ContactDetailDeletion (com.vodafone360.people.datatypes.ContactDetailDeletion)1 ContactListResponse (com.vodafone360.people.datatypes.ContactListResponse)1 Conversation (com.vodafone360.people.datatypes.Conversation)1 ExternalResponseObject (com.vodafone360.people.datatypes.ExternalResponseObject)1