Search in sources :

Example 11 with Identity

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

the class MyIdentitiesCacheTable method setCachedIdentities.

/**
 * Persists the provided identities into the client database.
 *
 * @param database the database where to save the values
 * @param identities the identities to save
 */
public static void setCachedIdentities(SQLiteDatabase database, ArrayList<Identity> identities) {
    final ContentValues contentValues = new ContentValues();
    database.delete(TABLE_NAME, null, null);
    for (Identity identity : identities) {
        database.insert(TABLE_NAME, null, getContentValues(contentValues, identity));
    }
}
Also used : ContentValues(android.content.ContentValues) Identity(com.vodafone360.people.datatypes.Identity)

Example 12 with Identity

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

the class IdentityEngineTest method testAddUiGetMyIdentities.

@MediumTest
// Takes too long.
@Suppress
public void testAddUiGetMyIdentities() {
    mState = IdentityTestState.GET_MY_IDENTITIES;
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    mEng.getMyThirdPartyIdentities();
    // mEng.run();
    ServiceStatus status = mEngineTester.waitForEvent();
    assertEquals(ServiceStatus.SUCCESS, status);
    Object data = mEngineTester.data();
    assertNull(null);
    try {
        ArrayList<Identity> identityList = ((Bundle) data).getParcelableArrayList("data");
        assertEquals(identityList.size(), 1);
    } catch (Exception e) {
        throw (new RuntimeException("Expected identity list with 1 item"));
    }
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) Bundle(android.os.Bundle) Identity(com.vodafone360.people.datatypes.Identity) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 13 with Identity

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

the class IdentityEngineTest method reportBackToEngine.

@Override
public void reportBackToEngine(int reqId, EngineId engine) {
    Log.d("TAG", "IdentityEngineTest.reportBackToEngine");
    ResponseQueue respQueue = ResponseQueue.getInstance();
    List<BaseDataType> data = new ArrayList<BaseDataType>();
    switch(mState) {
        case IDLE:
            break;
        case FETCH_IDENTITIES:
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
            Identity id = new Identity();
            data.add(id);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
            mEng.onCommsInMessage();
            break;
        case GET_MY_IDENTITIES:
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine Get ids");
            Identity myId = new Identity();
            data.add(myId);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
            mEng.onCommsInMessage();
            break;
        case FETCH_IDENTITIES_FAIL:
            ServerError err = new ServerError("Catastrophe");
            err.errorDescription = "Fail";
            data.add(err);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
            mEng.onCommsInMessage();
            break;
        case SET_IDENTITY_CAPABILTY:
            StatusMsg msg = new StatusMsg();
            msg.mCode = "ok";
            msg.mDryRun = false;
            msg.mStatus = true;
            data.add(msg);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SET_IDENTITY_CAPABILITY_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case VALIDATE_ID_CREDENTIALS_SUCCESS:
            StatusMsg msg2 = new StatusMsg();
            msg2.mCode = "ok";
            msg2.mDryRun = false;
            msg2.mStatus = true;
            data.add(msg2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.VALIDATE_IDENTITY_CREDENTIALS_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case VALIDATE_ID_CREDENTIALS_FAIL:
            ServerError err2 = new ServerError("Catastrophe");
            err2.errorDescription = "Fail";
            data.add(err2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
            mEng.onCommsInMessage();
            break;
        case GET_NEXT_RUNTIME:
            break;
        case GET_CHATABLE_IDENTITIES:
        case FETCH_IDENTITIES_POPULATED:
            Identity id2 = new Identity();
            id2.mActive = true;
            id2.mAuthType = "auth";
            List<String> clist = new ArrayList<String>();
            clist.add("uk");
            clist.add("fr");
            id2.mCountryList = clist;
            id2.mCreated = new Long(0);
            id2.mDisplayName = "Facebook";
            // id2.mIcon2Mime = "jpeg";
            id2.mIconMime = "jpeg";
            try {
                id2.mIcon2Url = new URL("url2");
                id2.mIconUrl = new URL("url");
                id2.mNetworkUrl = new URL("network");
            } catch (Exception e) {
            }
            id2.mIdentityId = "fb";
            id2.mIdentityType = "type";
            id2.mName = "Facebook";
            id2.mNetwork = "Facebook";
            id2.mOrder = 0;
            id2.mPluginId = "";
            id2.mUpdated = new Long(0);
            id2.mUserId = 23;
            id2.mUserName = "user";
            data.add(id2);
            List<IdentityCapability> capList = new ArrayList<IdentityCapability>();
            IdentityCapability idcap = new IdentityCapability();
            idcap.mCapability = IdentityCapability.CapabilityID.sync_contacts;
            idcap.mDescription = "sync cont";
            idcap.mName = "sync cont";
            idcap.mValue = true;
            capList.add(idcap);
            id2.mCapabilities = capList;
            data.add(id2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
            mEng.onCommsInMessage();
            break;
        default:
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) StatusMsg(com.vodafone360.people.datatypes.StatusMsg) ServerError(com.vodafone360.people.datatypes.ServerError) ArrayList(java.util.ArrayList) URL(java.net.URL) IdentityCapability(com.vodafone360.people.datatypes.IdentityCapability) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue) Identity(com.vodafone360.people.datatypes.Identity)

Example 14 with Identity

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

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

the class NowPlusDatatypesTests method testIdentity.

public void testIdentity() {
    Identity input = new Identity();
    input.mPluginId = "pluginid";
    input.mNetwork = "network";
    input.mIdentityId = "identityId";
    input.mDisplayName = "displayname";
    input.mCreated = new Long(12);
    input.mUpdated = new Long(23);
    input.mActive = true;
    input.mAuthType = "none";
    input.mIdentityType = "chat";
    input.mUserId = new Integer(1234);
    input.mUserName = "bob";
    input.mCountryList = new ArrayList<String>();
    input.mName = "bob";
    String urlString = "http://www.mobica.com/";
    try {
        input.mNetworkUrl = new URL(urlString);
    } catch (MalformedURLException e) {
        input.mNetworkUrl = null;
    }
    assertFalse("Input identity Name or Network is Empty or NULL", input.isIdentityFieldBlankorNull());
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    hash.put("pluginid", input.mPluginId);
    hash.put("network", input.mNetwork);
    hash.put("identityid", input.mIdentityId);
    hash.put("displayname", input.mDisplayName);
    hash.put("networkurl", urlString);
    hash.put("created", input.mCreated);
    hash.put("updated", input.mUpdated);
    hash.put("active", true);
    hash.put("authtype", input.mAuthType);
    hash.put("identitytype", input.mIdentityType);
    hash.put("userid", new Long(1234));
    hash.put("username", input.mUserName);
    hash.put("countrylist", input.mCountryList);
    hash.put("name", input.mName);
    Identity helper = new Identity();
    Identity output = helper.createFromHashtable(hash);
    assertFalse("Output identity Name or Network is Empty or NULL", output.isIdentityFieldBlankorNull());
    assertEquals(input.getType(), output.getType());
    assertEquals(input.toString(), output.toString());
    assertTrue(input.isSameAs(output));
}
Also used : MalformedURLException(java.net.MalformedURLException) Hashtable(java.util.Hashtable) Identity(com.vodafone360.people.datatypes.Identity) URL(java.net.URL)

Aggregations

Identity (com.vodafone360.people.datatypes.Identity)17 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)7 ServiceStatus (com.vodafone360.people.service.ServiceStatus)6 ArrayList (java.util.ArrayList)6 Bundle (android.os.Bundle)5 MediumTest (android.test.suitebuilder.annotation.MediumTest)4 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)4 Hashtable (java.util.Hashtable)4 Suppress (android.test.suitebuilder.annotation.Suppress)3 IdentityCapability (com.vodafone360.people.datatypes.IdentityCapability)3 ServerError (com.vodafone360.people.datatypes.ServerError)3 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)3 QueueManager (com.vodafone360.people.service.io.QueueManager)3 Request (com.vodafone360.people.service.io.Request)3 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)2 IOException (java.io.IOException)2 URL (java.net.URL)2 ContentValues (android.content.ContentValues)1 Cursor (android.database.Cursor)1 ActivityContact (com.vodafone360.people.datatypes.ActivityContact)1