Search in sources :

Example 6 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.

the class LoginEngine method setRegistrationComplete.

/**
     * Helper function to set the registration complete flag and update the
     * database with the new state.
     * 
     * @param value true if registration is completed
     */
private void setRegistrationComplete(boolean value) {
    LogUtils.logD("LoginEngine.setRegistrationComplete(" + value + ")");
    if (value != mIsRegistrationComplete) {
        StateTable.setRegistrationComplete(value, mDb.getWritableDatabase());
        mIsRegistrationComplete = value;
        if (mIsRegistrationComplete) {
            // Create NAB Account at this point (does nothing on 1.X
            // devices)
            final NativeContactsApi nabApi = NativeContactsApi.getInstance();
            if (!nabApi.isPeopleAccountCreated()) {
                // TODO: React upon failure to create account
                nabApi.addPeopleAccount(LoginPreferences.getUsername());
            }
        }
    }
}
Also used : NativeContactsApi(com.vodafone360.people.engine.contactsync.NativeContactsApi)

Example 7 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.

the class UpdateNativeContactsTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    createDatabase();
    NativeContactsApi.createInstance(getContext());
    if (VersionUtils.is2XPlatform()) {
        // Add Account for the case where we are in 2.X
        NativeContactsApi.getInstance().addPeopleAccount(PEOPLE_ACCOUNT.getName());
        Thread.sleep(100);
    }
    mContactSyncCallback = new ContactSyncCallback();
}
Also used : IContactSyncCallback(com.vodafone360.people.engine.contactsync.IContactSyncCallback)

Example 8 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.

the class NativeImporterTest method filterAccountsByType.

/**
     * Filters the given array of accounts by the given type.
     * 
     * @param accounts the array of accounts to filter 
     * @param type the type of accounts to filter
     * @return an array containing the filtered accounts or null if none
     */
private static Account[] filterAccountsByType(Account[] accounts, String type) {
    if (accounts != null) {
        final int length = accounts.length;
        final ArrayList<Account> matchingAccounts = new ArrayList<Account>(length);
        // find the corresponding accounts
        for (int i = 0; i < length; i++) {
            final Account account = accounts[i];
            if (type.equals(account.getType())) {
                matchingAccounts.add(account);
            }
        }
        if (matchingAccounts.size() > 0) {
            accounts = new Account[matchingAccounts.size()];
            matchingAccounts.toArray(accounts);
            return accounts;
        }
    }
    return null;
}
Also used : Account(com.vodafone360.people.engine.contactsync.NativeContactsApi.Account) ArrayList(java.util.ArrayList)

Example 9 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.

the class NativeContactsApiTest method testAddGetRemoveContacts.

@MediumTest
@Suppress
public void testAddGetRemoveContacts() {
    Account account = null;
    if (mUsing2xApi) {
        // Add Account for the case where we are in 2.X
        mNabApi.addPeopleAccount(PEOPLE_USERNAME);
        account = s360PeopleAccount;
        threadWait(100);
    }
    long[] ids = getContactIdsForAllAccounts();
    assertNull(ids);
    final int numRandomContacts = 10;
    long expectedContactId = ContactChange.INVALID_ID;
    for (int i = 0; i < numRandomContacts; i++) {
        long id = i;
        final ContactChange[] newContactCcList = ContactChangeHelper.randomContact(id, id, -1);
        final ContactChange[] newIds = mNabApi.addContact(account, newContactCcList);
        // expected num ids is + 1 for contact id
        verifyNewContactIds(expectedContactId, newContactCcList, newIds);
        expectedContactId = newIds[0].getNabContactId() + 1;
        // GET CONTACTS AND COMPARE
        ids = getContactIdsForAllAccounts();
        assertNotNull(ids);
        assertEquals(i + 1, ids.length);
        final ContactChange[] fetchedContactCcList = mNabApi.getContact(ids[i]);
        assertNotNull(fetchedContactCcList);
        if (!ContactChangeHelper.areChangeListsEqual(newContactCcList, fetchedContactCcList, false)) {
            Log.e(LOG_TAG, "ADD FAILED: Print of contact to be added follows:");
            ContactChangeHelper.printContactChangeList(newContactCcList);
            Log.e(LOG_TAG, "ADD FAILED: Print of contact fetched follows:");
            ContactChangeHelper.printContactChangeList(fetchedContactCcList);
            // fail test at this point
            assertFalse(true);
        }
    }
    // DELETE
    final int idCount = ids.length;
    for (int i = 0; i < idCount; i++) {
        mNabApi.removeContact(ids[i]);
    }
    ids = getContactIdsForAllAccounts();
    assertNull(ids);
}
Also used : Account(com.vodafone360.people.engine.contactsync.NativeContactsApi.Account) ContactChange(com.vodafone360.people.engine.contactsync.ContactChange) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 10 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account 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)

Aggregations

Account (com.vodafone360.people.engine.contactsync.NativeContactsApi.Account)7 QueueManager (com.vodafone360.people.service.io.QueueManager)5 Request (com.vodafone360.people.service.io.Request)5 ArrayList (java.util.ArrayList)3 MediumTest (android.test.suitebuilder.annotation.MediumTest)2 Suppress (android.test.suitebuilder.annotation.Suppress)2 ContactChange (com.vodafone360.people.engine.contactsync.ContactChange)2 ServiceStatus (com.vodafone360.people.service.ServiceStatus)2 SmallTest (android.test.suitebuilder.annotation.SmallTest)1 RegistrationDetails (com.vodafone360.people.datatypes.RegistrationDetails)1 EngineManager (com.vodafone360.people.engine.EngineManager)1 IContactSyncCallback (com.vodafone360.people.engine.contactsync.IContactSyncCallback)1 NativeContactsApi (com.vodafone360.people.engine.contactsync.NativeContactsApi)1 NativeContactsApiMockup (com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup)1 DynamicArrayLong (com.vodafone360.people.utils.DynamicArrayLong)1