Search in sources :

Example 41 with Name

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

Example 42 with Name

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

the class PeopleServiceTest method testRegistration.

/*
     * List of APIs that are called in tests within this class:
     * mPeopleService.fetchUsernameState(name);
     * mPeopleService.fetchTermsOfService();
     * mPeopleService.fetchPrivacyStatement();
     * mPeopleService.register(details);
     * mPeopleService.addEventCallback(mHandler);
     * mPeopleService.removeEventCallback(mHandler);
     * mPeopleService.getLoginRequired();
     * mPeopleService.logon(loginDetails);
     * mPeopleService.fetchAvailableIdentities(filter);
     * mPeopleService.fetchMyIdentities(filter);
     * mPeopleService.validateIdentityCredentials(false, "facebook", "testUser", "testPass", null);
     * mPeopleService.setIdentityCapabilityStatus("facebook", "testUser", stat);
     * mPeopleService.getRoamingNotificationType();
     * mPeopleService.setForceConnection(true);
     * mPeopleService.getForceConnection()
     * mPeopleService.getRoamingDeviceSetting();
     * mPeopleService.notifyDataSettingChanged(InternetAvail.ALWAYS_CONNECT);
     * mPeopleService.setShowRoamingNotificationAgain(true);
     * mPeopleService.setNetworkAgentState(sas);
     * mPeopleService.getNetworkAgentState();
     * mPeopleService.startActivitySync();
     * mPeopleService.startBackgroundContactSync();
     * mPeopleService.startContactSync();
     * 
     * void checkForUpdates();
     * void setNewUpdateFrequency();
     * PresenceList getPresenceList();
     * 
     */
public void testRegistration() {
    if (!ENABLE_REGISTRATION_TEST) {
        Log.i(LOG_TAG, "Skipping registration tests...");
        return;
    }
    Log.i(LOG_TAG, "**** testRegistration ****\n");
    assertTrue("Unable to create People service", lazyLoadPeopleService());
    String name = "scottkennedy1111";
    Log.i(LOG_TAG, "Fetching username state for a name (" + name + ") - checking correct state is returned");
    mPeopleService.fetchUsernameState(name);
    ServiceStatus status = waitForEvent(WAIT_EVENT_TIMEOUT_MS, TEST_RESPONSE);
    assertEquals("fetchUsernameState() failed with status = " + status.name(), ServiceStatus.ERROR_INTERNAL_SERVER_ERROR, status);
    Log.i(LOG_TAG, "Fetching terms of service...");
    mPeopleService.fetchTermsOfService();
    status = waitForEvent(WAIT_EVENT_TIMEOUT_MS, TEST_RESPONSE);
    assertEquals("fetchTermsOfService() failed with status = " + status.name(), ServiceStatus.ERROR_INTERNAL_SERVER_ERROR, status);
    Log.i(LOG_TAG, "Fetching privacy statement...");
    mPeopleService.fetchPrivacyStatement();
    status = waitForEvent(WAIT_EVENT_TIMEOUT_MS, TEST_RESPONSE);
    assertEquals("fetchPrivacyStatement() failed with status = " + status.name(), ServiceStatus.ERROR_INTERNAL_SERVER_ERROR, status);
    Log.i(LOG_TAG, "Trying to register new account (username: " + name + ")");
    RegistrationDetails details = new RegistrationDetails();
    details.mFullname = "Gerry Rafferty";
    details.mUsername = name;
    details.mPassword = "TestTestTest";
    details.mAcceptedTAndC = true;
    details.mBirthdayDate = "1978-01-01";
    details.mCountrycode = "En";
    details.mEmail = "test@test.com";
    details.mLanguage = "English";
    details.mMobileModelId = 1L;
    details.mMobileOperatorId = 1L;
    details.mMsisdn = "447775128930";
    details.mSendConfirmationMail = false;
    details.mSendConfirmationSms = true;
    details.mSubscribeToNewsLetter = false;
    details.mTimezone = "GMT";
    mPeopleService.register(details);
    status = waitForEvent(WAIT_EVENT_TIMEOUT_MS, TEST_RESPONSE);
    assertEquals("register() failed with status = " + status.name(), ServiceStatus.ERROR_INTERNAL_SERVER_ERROR, status);
    Log.i(LOG_TAG, "**** testRegistration (SUCCESS) ****\n");
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) RegistrationDetails(com.vodafone360.people.datatypes.RegistrationDetails)

Example 43 with Name

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

the class TestModule method createDummyDetailsNickname.

public ContactDetail createDummyDetailsNickname(ContactDetail name) {
    ContactDetail nickname = new ContactDetail();
    nickname.setValue(name.getName().toString(), ContactDetail.DetailKeys.VCARD_NICKNAME, null);
    return nickname;
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail)

Example 44 with Name

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

the class TestModule method modifyDummyDetailsData.

public void modifyDummyDetailsData(ContactDetail detail) {
    switch(detail.key) {
        case VCARD_NAME:
            VCardHelper.Name name = createDummyName();
            detail.setName(name);
            break;
        case PRESENCE_TEXT:
            detail.setValue(generateRandomString(), detail.key, null);
            break;
        case VCARD_DATE:
            Time time = new Time();
            time.parse("20080605");
            detail.setDate(time, ContactDetail.DetailKeyTypes.BIRTHDAY);
            break;
        case VCARD_IMADDRESS:
            detail.setValue(generateRandomString() + "@mail.co.uk", detail.key, null);
            break;
        case VCARD_EMAIL:
            detail.setEmail(generateRandomString() + "@mail.co.uk", ContactDetail.DetailKeyTypes.HOME);
            break;
        case VCARD_PHONE:
            detail.setTel("07967 123456", ContactDetail.DetailKeyTypes.CELL);
            break;
        case VCARD_BUSINESS:
        case VCARD_ADDRESS:
            VCardHelper.PostalAddress address = new VCardHelper.PostalAddress();
            address.addressLine1 = "123 Any road";
            address.addressLine2 = "Any location";
            address.city = "Any City";
            address.county = "Any County";
            address.postCode = "M6 2AY";
            address.country = "United Kingdom";
            detail.setPostalAddress(address, ContactDetail.DetailKeyTypes.HOME);
            break;
        case VCARD_URL:
        case VCARD_INTERNET_ADDRESS:
            detail.setValue("www." + generateRandomString() + "anyaddress.co.uk", detail.key, null);
            break;
        case VCARD_ROLE:
            detail.setValue(generateRandomString(), detail.key, null);
            break;
        case VCARD_ORG:
            Organisation org = new Organisation();
            org.name = generateRandomString();
            detail.setOrg(org, null);
            break;
        case VCARD_TITLE:
            detail.setValue(generateRandomString(), detail.key, null);
            break;
        case VCARD_NOTE:
            {
                String randomString = new String();
                for (int i = 0; i < generateRandomInt() % 10; i++) {
                    randomString += generateRandomString() + " ";
                }
                detail.setValue(randomString, detail.key, null);
                break;
            }
    }
}
Also used : Organisation(com.vodafone360.people.datatypes.VCardHelper.Organisation) VCardHelper(com.vodafone360.people.datatypes.VCardHelper) Time(android.text.format.Time)

Example 45 with Name

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

the class Auth method requestActivationCode.

/**
 * Implementation of "auth/requestactivationcode" API.
 *
 * @param engine Handle to LoginEngine which handles requests using this
 *            API.
 * @param username User-name for this account.
 * @param mobileNumber Mobile number for this activation code to be sent.
 * @return Request ID generated for this request.
 * @return -1 when username is NULL.
 * @throws NullPointerException when engine is NULL
 * @throws NullPointerException when mobileNumber is NULL
 */
public static int requestActivationCode(BaseEngine engine, String username, String mobileNumber) {
    if (engine == null) {
        throw new NullPointerException("Auth.requestActivationCode() engine cannot be NULL");
    }
    if (username == null) {
        LogUtils.logE("Auth.requestActivationCode() username must be specified");
        return -1;
    }
    if (mobileNumber == null) {
        throw new NullPointerException("Auth.requestActivationCode() mobileNumber cannot be NULL");
    }
    Request request = new Request(FUNCTION_REQUEST_ACTIVATION_CODE, Request.Type.STATUS, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_AUTH);
    request.addData(USERNAME, username);
    request.addData(VALUE, mobileNumber);
    request.addData(FLAGS, ACTIVATE_MOBILE_CLIENT_FLAG);
    QueueManager queue = QueueManager.getInstance();
    int requestId = queue.addRequest(request);
    queue.fireQueueStateChanged();
    return requestId;
}
Also used : Request(com.vodafone360.people.service.io.Request) QueueManager(com.vodafone360.people.service.io.QueueManager)

Aggregations

ContactDetail (com.vodafone360.people.datatypes.ContactDetail)23 ServiceStatus (com.vodafone360.people.service.ServiceStatus)20 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)13 Cursor (android.database.Cursor)12 Contact (com.vodafone360.people.datatypes.Contact)12 ArrayList (java.util.ArrayList)11 Name (com.vodafone360.people.datatypes.VCardHelper.Name)9 ContentValues (android.content.ContentValues)7 Uri (android.net.Uri)7 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)7 SQLException (android.database.SQLException)6 Organisation (com.vodafone360.people.datatypes.VCardHelper.Organisation)6 QueueManager (com.vodafone360.people.service.io.QueueManager)6 Request (com.vodafone360.people.service.io.Request)6 TimelineSummaryItem (com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem)5 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)5 Hashtable (java.util.Hashtable)5 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)4 Suppress (android.test.suitebuilder.annotation.Suppress)4 Date (java.util.Date)4