Search in sources :

Example 1 with RegistrationDetails

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

the class NowPlusDBHelperLoginTest method testModifyCredentialsAndKey.

/*
	 * Modify credentials and public key then fetch modified credentials and validate it
	 */
@MediumTest
public void testModifyCredentialsAndKey() {
    Log.i(LOG_TAG, "***** EXECUTING testAddDeleteContactsDetails *****");
    Log.i(LOG_TAG, "Test contact functionality (add delete contacts details)");
    Log.i(LOG_TAG, "Test 1a: Initialise test environment and load database");
    assertTrue(initialise());
    Log.i(LOG_TAG, "Test 1b: Remove user data");
    mDatabaseHelper.removeUserData();
    ServiceStatus status = mTestUtility.waitForEvent(WAIT_EVENT_TIMEOUT_MS, DbTestUtility.CONTACTS_INT_EVENT_MASK);
    assertEquals(ServiceStatus.SUCCESS, status);
    RegistrationDetails registrationDetails = new RegistrationDetails();
    registrationDetails.mUsername = TestModule.generateRandomString();
    registrationDetails.mPassword = TestModule.generateRandomString();
    registrationDetails.mMsisdn = TestModule.generateRandomString();
    LoginDetails loginDetails = new LoginDetails();
    loginDetails.mUsername = registrationDetails.mUsername;
    loginDetails.mPassword = registrationDetails.mPassword;
    loginDetails.mAutoConnect = TestModule.generateRandomBoolean();
    loginDetails.mRememberMe = TestModule.generateRandomBoolean();
    loginDetails.mMobileNo = registrationDetails.mMsisdn;
    loginDetails.mSubscriberId = TestModule.generateRandomString();
    PublicKeyDetails pubKeyDetails = new PublicKeyDetails();
    RSAEncryptionUtils.copyDefaultPublicKey(pubKeyDetails);
    pubKeyDetails.mKeyBase64 = TestModule.generateRandomString();
    LoginDetails fetchedLogin = new LoginDetails();
    PublicKeyDetails fetchedPubKey = new PublicKeyDetails();
    status = mDatabaseHelper.fetchLogonCredentialsAndPublicKey(fetchedLogin, fetchedPubKey);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertNull(fetchedLogin.mUsername);
    assertNull(fetchedLogin.mPassword);
    assertNull(fetchedPubKey.mKeyBase64);
    assertNull(fetchedPubKey.mExponential);
    assertNull(fetchedPubKey.mModulus);
    status = mDatabaseHelper.modifyCredentialsAndPublicKey(loginDetails, pubKeyDetails);
    assertEquals(ServiceStatus.SUCCESS, status);
    status = mDatabaseHelper.fetchLogonCredentialsAndPublicKey(fetchedLogin, fetchedPubKey);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, fetchedLogin.mUsername);
    if (loginDetails.mRememberMe) {
        assertEquals(loginDetails.mPassword, fetchedLogin.mPassword);
    }
    assertEquals(loginDetails.mAutoConnect, fetchedLogin.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, fetchedLogin.mRememberMe);
    assertEquals(loginDetails.mMobileNo, fetchedLogin.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, fetchedLogin.mSubscriberId);
    assertEquals(pubKeyDetails.mExponential.length, fetchedPubKey.mExponential.length);
    for (int i = 0; i < pubKeyDetails.mExponential.length; i++) {
        assertEquals(pubKeyDetails.mExponential[i], fetchedPubKey.mExponential[i]);
    }
    assertEquals(pubKeyDetails.mModulus.length, fetchedPubKey.mModulus.length);
    for (int i = 0; i < fetchedPubKey.mModulus.length; i++) {
        assertEquals(pubKeyDetails.mModulus[i], fetchedPubKey.mModulus[i]);
    }
    assertEquals(pubKeyDetails.mKeyBase64, fetchedPubKey.mKeyBase64);
    shutdown();
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "testModifyFetchCredentials has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : PublicKeyDetails(com.vodafone360.people.datatypes.PublicKeyDetails) ServiceStatus(com.vodafone360.people.service.ServiceStatus) RegistrationDetails(com.vodafone360.people.datatypes.RegistrationDetails) LoginDetails(com.vodafone360.people.datatypes.LoginDetails) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 2 with RegistrationDetails

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

the class NowPlusStateTableTest method testModifyCredentials.

/*
     * Modify credentials then fetch modified credentials and validate it
     */
@MediumTest
public void testModifyCredentials() {
    final String fnName = "testModifyCredentials";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "modfiy and fetchmodified credentials");
    SQLiteDatabase writableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    LoginDetails loginDetails = new LoginDetails();
    RegistrationDetails registrationDetails = new RegistrationDetails();
    registrationDetails.mUsername = TestModule.generateRandomString();
    registrationDetails.mPassword = TestModule.generateRandomString();
    registrationDetails.mMsisdn = TestModule.generateRandomString();
    loginDetails.mUsername = registrationDetails.mUsername;
    loginDetails.mPassword = registrationDetails.mPassword;
    loginDetails.mAutoConnect = true;
    loginDetails.mRememberMe = true;
    loginDetails.mMobileNo = registrationDetails.mMsisdn;
    loginDetails.mSubscriberId = TestModule.generateRandomString();
    // try to modify credentials before creating a table causes uncaught
    // exception
    ServiceStatus status = StateTable.modifyCredentials(loginDetails, writableDb);
    assertEquals(ServiceStatus.ERROR_DATABASE_CORRUPT, status);
    createTable();
    // positive test modify credentials after table was created
    status = StateTable.modifyCredentials(loginDetails, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    LoginDetails fetchedLoginDetails = new LoginDetails();
    status = StateTable.fetchLogonCredentials(fetchedLoginDetails, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, fetchedLoginDetails.mUsername);
    assertEquals(loginDetails.mPassword, fetchedLoginDetails.mPassword);
    assertEquals(loginDetails.mAutoConnect, fetchedLoginDetails.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, fetchedLoginDetails.mRememberMe);
    assertEquals(loginDetails.mMobileNo, fetchedLoginDetails.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, fetchedLoginDetails.mSubscriberId);
    loginDetails.mRememberMe = false;
    status = StateTable.modifyCredentials(loginDetails, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    LoginDetails modifedLoginDetails = new LoginDetails();
    status = StateTable.fetchLogonCredentials(modifedLoginDetails, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, modifedLoginDetails.mUsername);
    // mRemberme was set to false
    assertNull(modifedLoginDetails.mPassword);
    // so password should be null
    assertEquals(loginDetails.mAutoConnect, modifedLoginDetails.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, modifedLoginDetails.mRememberMe);
    assertEquals(loginDetails.mMobileNo, modifedLoginDetails.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, modifedLoginDetails.mSubscriberId);
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "testModifyCredentials has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus) RegistrationDetails(com.vodafone360.people.datatypes.RegistrationDetails) LoginDetails(com.vodafone360.people.datatypes.LoginDetails) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 3 with RegistrationDetails

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

the class NowPlusStateTableTest method testModifyCredentialsAndKey.

/*
     * Modify credentials and public key then fetch modified credentials and
     * validate it
     */
@MediumTest
public void testModifyCredentialsAndKey() {
    final String fnName = "testModifyCredentialsAndKey";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "modfiy and fetchmodified credentials");
    SQLiteDatabase writableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    LoginDetails loginDetails = new LoginDetails();
    RegistrationDetails registrationDetails = new RegistrationDetails();
    registrationDetails.mUsername = TestModule.generateRandomString();
    registrationDetails.mPassword = TestModule.generateRandomString();
    registrationDetails.mMsisdn = TestModule.generateRandomString();
    loginDetails.mUsername = registrationDetails.mUsername;
    loginDetails.mPassword = registrationDetails.mPassword;
    loginDetails.mAutoConnect = true;
    loginDetails.mRememberMe = true;
    loginDetails.mMobileNo = registrationDetails.mMsisdn;
    loginDetails.mSubscriberId = TestModule.generateRandomString();
    PublicKeyDetails pubKeyDetails = new PublicKeyDetails();
    RSAEncryptionUtils.copyDefaultPublicKey(pubKeyDetails);
    // try to modify credentials before creating a table causes uncaught
    // exception
    ServiceStatus status = StateTable.modifyCredentialsAndPublicKey(loginDetails, pubKeyDetails, writableDb);
    assertEquals(ServiceStatus.ERROR_DATABASE_CORRUPT, status);
    createTable();
    // positive test modify credentials after table was created
    status = StateTable.modifyCredentialsAndPublicKey(loginDetails, pubKeyDetails, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    PublicKeyDetails fetchedPubKey = new PublicKeyDetails();
    LoginDetails fetchedLoginDetails = new LoginDetails();
    status = StateTable.fetchLogonCredentialsAndPublicKey(fetchedLoginDetails, fetchedPubKey, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, fetchedLoginDetails.mUsername);
    assertEquals(loginDetails.mPassword, fetchedLoginDetails.mPassword);
    assertEquals(loginDetails.mAutoConnect, fetchedLoginDetails.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, fetchedLoginDetails.mRememberMe);
    assertEquals(loginDetails.mMobileNo, fetchedLoginDetails.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, fetchedLoginDetails.mSubscriberId);
    assertEquals(pubKeyDetails.mExponential.length, fetchedPubKey.mExponential.length);
    for (int i = 0; i < pubKeyDetails.mExponential.length; i++) {
        assertEquals(pubKeyDetails.mExponential[i], fetchedPubKey.mExponential[i]);
    }
    assertEquals(pubKeyDetails.mModulus.length, fetchedPubKey.mModulus.length);
    for (int i = 0; i < fetchedPubKey.mModulus.length; i++) {
        assertEquals(pubKeyDetails.mModulus[i], fetchedPubKey.mModulus[i]);
    }
    loginDetails.mRememberMe = false;
    pubKeyDetails.mKeyBase64 = TestModule.generateRandomString();
    status = StateTable.modifyCredentialsAndPublicKey(loginDetails, pubKeyDetails, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    LoginDetails modifedLoginDetails = new LoginDetails();
    PublicKeyDetails modifiedPubKey = new PublicKeyDetails();
    status = StateTable.fetchLogonCredentialsAndPublicKey(modifedLoginDetails, modifiedPubKey, readableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    assertEquals(loginDetails.mUsername, modifedLoginDetails.mUsername);
    // mRemberme was set to false
    assertNull(modifedLoginDetails.mPassword);
    // so password should be null
    assertEquals(loginDetails.mAutoConnect, modifedLoginDetails.mAutoConnect);
    assertEquals(loginDetails.mRememberMe, modifedLoginDetails.mRememberMe);
    assertEquals(loginDetails.mMobileNo, modifedLoginDetails.mMobileNo);
    assertEquals(loginDetails.mSubscriberId, modifedLoginDetails.mSubscriberId);
    assertEquals(pubKeyDetails.mExponential.length, modifiedPubKey.mExponential.length);
    for (int i = 0; i < pubKeyDetails.mExponential.length; i++) {
        assertEquals(pubKeyDetails.mExponential[i], fetchedPubKey.mExponential[i]);
    }
    assertEquals(pubKeyDetails.mModulus.length, modifiedPubKey.mModulus.length);
    for (int i = 0; i < fetchedPubKey.mModulus.length; i++) {
        assertEquals(pubKeyDetails.mModulus[i], fetchedPubKey.mModulus[i]);
    }
    assertEquals(pubKeyDetails.mKeyBase64, modifiedPubKey.mKeyBase64);
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "testModifyCredentialsAndKey has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : PublicKeyDetails(com.vodafone360.people.datatypes.PublicKeyDetails) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus) RegistrationDetails(com.vodafone360.people.datatypes.RegistrationDetails) LoginDetails(com.vodafone360.people.datatypes.LoginDetails) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 4 with RegistrationDetails

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

the class LoginEngineTest method testRegistration.

/*
     * addUiRegistrationRequest(non-Javadoc)
     * @seecom.vodafone360.people.tests.engine.IEngineTestFrameworkObserver#
     * reportBackToEngine(int,
     * com.vodafone360.people.engine.EngineManager.EngineId)
     */
@MediumTest
// Breaks tests.
@Suppress
public void testRegistration() {
    mState = LoginTestState.REGISTRATION;
    NetworkAgent.setAgentState(NetworkAgent.AgentState.DISCONNECTED);
    RegistrationDetails details = null;
    try {
        synchronized (mEngineTester) {
            mEng.addUiRegistrationRequest(details);
            ServiceStatus status = mEngineTester.waitForEvent();
            assertEquals(ServiceStatus.ERROR_BAD_SERVER_PARAMETER, status);
        }
    } catch (Exception e) {
        displayException(e);
        fail("testRegistration test 1 failed with exception");
    }
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    try {
        synchronized (mEngineTester) {
            mEng.addUiRegistrationRequest(details);
            ServiceStatus status = mEngineTester.waitForEvent();
            assertEquals(ServiceStatus.ERROR_BAD_SERVER_PARAMETER, status);
        }
    } catch (Exception e) {
        displayException(e);
        fail("testRegistration test 2 failed with exception");
    }
    details = new RegistrationDetails();
    try {
        synchronized (mEngineTester) {
            mEng.addUiRegistrationRequest(details);
            ServiceStatus status = mEngineTester.waitForEvent();
            assertEquals(ServiceStatus.ERROR_BAD_SERVER_PARAMETER, status);
        }
    } catch (Exception e) {
        displayException(e);
        fail("testRegistration test 3 failed with exception");
    }
    details.mUsername = "bwibble";
    details.mPassword = "qqqqqq";
    try {
        synchronized (mEngineTester) {
            mEng.addUiRegistrationRequest(details);
            ServiceStatus status = mEngineTester.waitForEvent();
            assertEquals(ServiceStatus.ERROR_BAD_SERVER_PARAMETER, status);
        }
    } catch (Exception e) {
        displayException(e);
        fail("testRegistration test 4 failed with exception");
    }
    details.mFullname = "Billy Wibble";
    details.mBirthdayDate = "12345678";
    details.mEmail = "billy@wibble.com";
    details.mMsisdn = "123456";
    details.mAcceptedTAndC = true;
    details.mCountrycode = "uk";
    details.mTimezone = "gmt";
    details.mLanguage = "english";
    details.mSendConfirmationMail = true;
    details.mSendConfirmationSms = true;
    details.mSubscribeToNewsLetter = true;
    details.mMobileOperatorId = new Long(1234);
    details.mMobileModelId = new Long(12345);
    try {
        synchronized (mEngineTester) {
            mEng.addUiRegistrationRequest(details);
            ServiceStatus status = mEngineTester.waitForEvent(120000);
            assertEquals(ServiceStatus.ERROR_SMS_CODE_NOT_RECEIVED, status);
        }
    } catch (Exception e) {
        displayException(e);
        fail("testRegistration test 5 failed with exception");
    }
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) RegistrationDetails(com.vodafone360.people.datatypes.RegistrationDetails) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 5 with RegistrationDetails

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

the class NowPlusServiceTestHelper method register.

/*
     * private IRemoteServiceCallback mCallback = new
     * IRemoteServiceCallback.Stub() {
     * @Override public void uiRequestComplete(int requestId, int statusId,
     * Bundle data) throws RemoteException { synchronized(mUiRequestLock) { if
     * (mUiRequestId != null && mUiRequestId.intValue() == requestId) {
     * mUiRequestStatusId = statusId; mUiRequestData = data;
     * mUiRequestLock.notifyAll(); } } }
     * @Override public void onContactSyncEvent(boolean syncActive, Bundle
     * bundleInfo) { Log.d(LOG_TAG, "Sync notification event received: " +
     * syncActive + ", info = " + bundleInfo); }
     * @Override public void onDatabaseChangeEvent(int changeTypeVal) throws
     * RemoteException { Database.DatabaseChangeType type = null; if
     * (changeTypeVal < Database.DatabaseChangeType.values().length) { type =
     * Database.DatabaseChangeType.values()[changeTypeVal]; } Log.d(LOG_TAG,
     * "Database change event received: " + type); mDbChanged = true; }
     * @Override public void onSettingChangeEvent(PersistSettings setting)
     * throws RemoteException { Log.d(LOG_TAG, "Setting change event received: "
     * + setting); } };
     */
//	
// public void Disconnect() {
// Log.i (LOG_TAG, "Disconnect() called");
// }
//	
//	
// public ServiceStatus LogOnTest(LoginDetails details) {
// ServiceStatus status = ServiceStatus.SUCCESS;
// synchronized(mUiRequestLock) {
// status = startSynchronousRequest(ServiceUiRequest.LOGIN);
// try {
// mRemoteService.logOn(details);
// } catch (RemoteException e) {
// status = ServiceStatus.ERROR_SERVICE_DISCONNECTED;
// }
// status = finishSynchronousRequest(status, null);
// }
//	    
// Log.i(LOG_TAG, "Log on result: " + status);
// return status;
// }
//
// public boolean runDatabaseTests() {
// Log.i (LOG_TAG, "runDatabaseTests ()");
//		
// ArrayList<ContactSummary> contactSummaryList = new
// ArrayList<ContactSummary>();
// Log.i(LOG_TAG, "Fetching number of contacts...");
// int count = fetchNoOfContacts();
// Log.i(LOG_TAG, "No of contacts = " + count);
//		
// if (count < 10) {
// Log.i (LOG_TAG,"Fewer than 10 contacts found");
//			
// Log.i(LOG_TAG, "Populating database with dummy contacts...");
//		
// for (int i = 0 ; i < 1 ; i++) {
// Log.i(LOG_TAG, "Populating group " + i + " please wait...");
// if (!populateContacts()) {
// Log.e(LOG_TAG, "Unable to add dummy contacts");
// return false;
// }
// Log.i (LOG_TAG,"Database successfully populated");
// count = fetchNoOfContacts();
// }
// }
// else
// {
// Log.i (LOG_TAG, "Enough contacts already exist, not adding any more");
// }
//
// int startSummaryIndex = 0;
// for (int i = 0 ; i < count ; i+= 500) {
// Log.i(LOG_TAG, "Fetching contact summary list starting at " + i);
// startSummaryIndex = i;
// if (!fetchContactSummaryList(contactSummaryList, startSummaryIndex, 500))
// {
// Log.e(LOG_TAG, "Unable to fetch summary list");
// return false;
// }
//	
// for (ContactSummary s : contactSummaryList) {
// Log.i(LOG_TAG, s.toString());
// }
// }
//		
// Log.i (LOG_TAG, "Creating new contact ...");
//		
// Contact contact = new Contact();
// contact.aboutMe = "Test information\"`!$%^&*()_-+=[]{};:'@#~,<.>/?\\|";
// contact.contactID = 123L;
// contact.deleted = false;
// contact.friendOfMine = false;
// contact.profilePath = "///sdcard/test/path/picture.jpg";
// contact.updated = 0L;
// contact.userID = "982";
// {
// Log.i (LOG_TAG, "Creating contacts details #1 ...");
// ContactDetail detail = new ContactDetail();
// detail.key = ContactDetail.detailKeys.VCARD_NAME;
// detail.value = "Scott Kennedy";
// contact.details.add(detail);
//			
// Log.i (LOG_TAG, "Details Key   : " + detail.key);
// Log.i (LOG_TAG, "Details Value : " + detail.value);
// }
// Log.i (LOG_TAG, "Contact details ...");
// Log.i (LOG_TAG, "aboutMe      : " + contact.aboutMe);
// Log.i (LOG_TAG, "contactId    : " + contact.contactID);
// Log.i (LOG_TAG, "deleted      : " + contact.deleted);
// Log.i (LOG_TAG, "friendOfMine : " + contact.friendOfMine);
// Log.i (LOG_TAG, "profilePath  : " + contact.profilePath);
// Log.i (LOG_TAG, "updated      : " + contact.updated);
// Log.i (LOG_TAG, "userID       : " + contact.userID);
//		
//		
// {
// Log.i (LOG_TAG, "Creating contact details #2 ...");
// ContactDetail detail = new ContactDetail();
// detail.key = ContactDetail.detailKeys.PRESENCE_TEXT;
// detail.value = "test status 1";
// contact.details.add(detail);
//			
// Log.i (LOG_TAG, "Details Key      : " + detail.key);
// Log.i (LOG_TAG, "Details Value    : " + detail.value);
// }
//
// {
// Log.i (LOG_TAG, "Creating contact details #3 ...");
// ContactDetail detail = new ContactDetail();
// detail.key = ContactDetail.detailKeys.PRESENCE_TEXT;
// detail.value = "Test presence text";
// contact.details.add(detail);
// contact.aboutMe = detail.value;
//			
// Log.i (LOG_TAG, "Details Key     : " + detail.key);
// Log.i (LOG_TAG, "Details Value   : " + detail.value);
// Log.i (LOG_TAG, "Contact AboutMe : " + contact.aboutMe);
// }
//
// Log.i(LOG_TAG, "Adding test contact...");
// if (!addContact(contact)) {
// Log.e(LOG_TAG, "Unable to add contact " + contact.toString());
// return false;
// }
// Log.i(LOG_TAG, "Added Contact " + contact.toString());
//
// Contact contact2 = new Contact();
// Log.i(LOG_TAG, "Fetching contact...");
// if (!fetchContact(contact.localContactID, contact2)) {
// Log.e(LOG_TAG, "Unable to fetch added contact " +
// contact.localContactID);
// return false;
// }
// Log.i(LOG_TAG, "Fetched Contact " + contact2.toString());
//		
// Log.i(LOG_TAG, "Deleting contact...");
// ServiceStatus status = deleteContact(contact.localContactID);
// if (ServiceStatus.SUCCESS != status) {
// Log.e(LOG_TAG, "Unable to delete contact " + contact.localContactID);
// return false;
// }
//
// Log.i(LOG_TAG, "Fetching deleted contact...");
// if (fetchContact(contact.localContactID, contact2)) {
// Log.e(LOG_TAG, "Fetched Contact - it was not deleted");
// return false;
// }
//
// Log.i(LOG_TAG, "SummaryList size = "+ contactSummaryList.size());
//		
// if (contactSummaryList.size() > 0)
// {
// Log.i(LOG_TAG, "Adding contact detail...");
// ContactDetail detail = new ContactDetail();
//			
// detail.key = ContactDetail.detailKeys.VCARD_PHONE;
// detail.keyType = ContactDetail.detailKeyTypes.CELL;
// detail.value = "+447955123456";
// long testContactID = contactSummaryList.get(0).localContactID;
// detail.localContactID = testContactID;
//			
// Log.i (LOG_TAG, "Details Key     : " + detail.key);
// Log.i (LOG_TAG, "Detail Key Type : " + detail.keyType);
// Log.i (LOG_TAG, "Detail Value    : " + detail.value);
// if (!addContactDetail(detail)) {
// Log.e(LOG_TAG, "Unable to add contact detail to contact " +
// contact.localContactID);
// return false;
// }
// Log.i (LOG_TAG, "Contact detail added successfully");
//
// if (!displayContactDetail(testContactID, detail.localDetailID)) {
// Log.e(LOG_TAG, "Unable to find new detail after fetch");
// return false;
// }
//			
// Log.i (LOG_TAG, "New details etrieved successfully");
// Log.i(LOG_TAG, "Modifying contact detail...");
// detail.value = "+4479654321";
//			
// Log.i (LOG_TAG, "Modifying detail value to " + detail.value);
// if (!modifyContactDetail(detail)) {
// Log.e(LOG_TAG, "Unable to modify contact detail " +
// detail.localDetailID);
// return false;
// }
//			
// Log.i (LOG_TAG, "Contact detail modified successfully");
//
// if (!displayContactDetail(testContactID, detail.localDetailID)) {
// Log.e(LOG_TAG, "Unable to find modified detail after fetch");
// return false;
// }
// Log.i (LOG_TAG, "Modified details found successfully");
//			
// Log.i(LOG_TAG, "Deleting contact detail...");
// if (!removeContactDetail(detail.localDetailID)) {
// Log.e(LOG_TAG, "Unable to delete contact detail " +
// detail.localDetailID);
// return false;
// }
// Log.i (LOG_TAG, "Contact detail deleted successfully");
//			
// if (displayContactDetail(testContactID, detail.localDetailID)) {
// Log.e(LOG_TAG, "Contact detail has been fetched after delete");
// return false;
// }
// Log.i (LOG_TAG,"Correctly, unable to get non-existent contact detail");
//			
// Log.i(LOG_TAG, "Fetching contact (2)...");
// if (!fetchContact(testContactID, contact2)) {
// Log.e(LOG_TAG, "Unable to fetch contact before adding detail " +
// testContactID);
// return false;
// }
//			
// Log.i (LOG_TAG,"Fetched contact successfully before adding detail");
//
// for (ContactDetail d : contact2.details ) {
// if (d.key == ContactDetail.detailKeys.PRESENCE_TEXT ) {
// Log.i(LOG_TAG, "Removing presence status detail...");
// if (!removeContactDetail(d.localDetailID)) {
// Log.e(LOG_TAG, "Unable to remove presence status detail " +
// d.localDetailID);
// return false;
// }
// Log.i (LOG_TAG, "Presence status detail successfully removed");
// }
// }
//
// {
// Log.i(LOG_TAG, "Fetching contact summary for test contact...");
// final ArrayList<ContactSummary> tempList = new
// ArrayList<ContactSummary>();
// if (!fetchContactSummaryList(tempList, startSummaryIndex, 1) ||
// tempList.size() < 1) {
// Log.e(LOG_TAG, "Unable to fetch contact summary after deleting detail " +
// startSummaryIndex);
// return false;
// }
// if (tempList.get(0).statusText != null) {
// Log.e(LOG_TAG,
// "There is no presence text contact detail so \"ContactSummary.statusText\" field should be null, but ContactSummary.statusText="
// + tempList.get(0).statusText);
// return false;
// }
// }
//
// Log.i(LOG_TAG, "Adding contact detail (4)...");
// detail.key = ContactDetail.detailKeys.PRESENCE_TEXT;
// detail.keyType = ContactDetail.detailKeyTypes.UNKNOWN;
// detail.value = "This is my new presence status";
// detail.localContactID = testContactID;
//			
// Log.i (LOG_TAG, "Detail Key              : " + detail.key);
// Log.i (LOG_TAG, "Detail KeyType          : " + detail.keyType);
// Log.i (LOG_TAG, "Detail Value            : " + detail.value);
// Log.i (LOG_TAG, "Details local contactID : " + detail.localContactID);
// if (!addContactDetail(detail)) {
// Log.e(LOG_TAG, "Unable to add contact detail to contact " +
// contact.localContactID);
// return false;
// }
// Log.i (LOG_TAG, "Contact detail added successfully");
//			
// {
// Log.i(LOG_TAG, "Fetching contact summary for test contact...");
// final ArrayList<ContactSummary> tempList = new
// ArrayList<ContactSummary>();
// if (!fetchContactSummaryList(tempList, startSummaryIndex, 1) ||
// tempList.size() < 1) {
// Log.e(LOG_TAG, "Unable to fetch contact summary after deleting detail " +
// startSummaryIndex);
// return false;
// }
// if (!tempList.get(0).localContactID.equals(detail.localContactID)) {
// Log.e(LOG_TAG,
// "Contact ID mismatch - the test code has failed (Expected id = " +
// detail.localContactID + ", actual ID = " + tempList.get(0).localContactID
// + ")");
// return false;
// }
// if (tempList.get(0).statusText == null ||
// !detail.value.equals(tempList.get(0).statusText)) {
// Log.e(LOG_TAG,
// "The ContactSummary.statusText field was not updated when status text contact detail was added: Expected value: \""
// + detail.value + "\", actual value: \"" + tempList.get(0).statusText +
// "\"");
// return false;
// }
// Log.i (LOG_TAG, "Status text field was updated successfully with \"" +
// tempList.get(0).statusText + "\"");
// }
// }
//		
// return true;
// }
//
// public boolean displayContactDetail(long contactID, long detailID) {
// Contact contact = new Contact();
//		
// Log.i (LOG_TAG, "Calling displayContactDetail ()");
// Log.i (LOG_TAG, "contactID: " + contactID+ ", detailID : " + detailID);
// if (!fetchContact(contactID, contact)) {
// Log.e(LOG_TAG, "Unable to fetch contact with modified detail");
// return false;
// }
// Log.i (LOG_TAG, "Fetched contact with modified details successfully");
//		
// for (ContactDetail d : contact.details) {
// if (d.localDetailID == detailID) {
// Log.i(LOG_TAG, "Fetched Contact Detail" + d.toString());
// return true;
// }
// }
// Log.e (LOG_TAG, "displayContactDetail() has failed!!");
// return false;
// }
//
// public boolean addContact(Contact contact) {
// Log.i(LOG_TAG, "Calling addContact ()");
//		
// try {
// ServiceStatus status =
// ServiceStatus.fromInteger(mRemoteService.addContact(contact));
// if (ServiceStatus.SUCCESS != status) {
// Log.e(LOG_TAG, "Add contact failed: " + status);
// return false;
// }
// } catch (RemoteException e) {
// Log.e(LOG_TAG, "Remote exception has occurred while adding contact");
// return false;
// }
// return true;
// }
//	
// public ServiceStatus deleteContact(long localContactID) {
// Log.i (LOG_TAG, "Calling deletedContact ()");
// Log.i (LOG_TAG, "localContactID : "+ localContactID);
//		
// try {
// ServiceStatus status =
// ServiceStatus.fromInteger(mRemoteService.deleteContact(localContactID));
// if (ServiceStatus.SUCCESS != status) {
// Log.e(LOG_TAG, "Delete Contact Failed: " + status);
// return status;
// }
// Log.i (LOG_TAG, "Contact deleted successfully");
//			
// } catch (RemoteException e) {
// Log.e(LOG_TAG, "Remote exception has occurred while deleting contact");
// return ServiceStatus.ERROR_UNKNOWN;
// }
// return ServiceStatus.SUCCESS;
// }
//
// public boolean populateContacts() {
// Log.i (LOG_TAG,"Calling populateContacts ()");
//		
// try {
// ServiceStatus status =
// ServiceStatus.fromInteger(mRemoteService.testPopulate());
// if (ServiceStatus.SUCCESS != status) {
// Log.e(LOG_TAG, "Test populate failed: " + status);
// return false;
// }
// } catch (RemoteException e) {
// Log.e(LOG_TAG, "Remote exception has occurred while populating");
// return false;
// }
// return true;
// }
//	
// public boolean fetchContact(long localContactID, Contact contact) {
// try {
// ServiceStatus status =
// ServiceStatus.fromInteger(mRemoteService.fetchContact(localContactID,
// contact));
// if (ServiceStatus.SUCCESS != status) {
// Log.e(LOG_TAG, "Fetch contact failed: " + status);
// return false;
// }
// } catch (RemoteException e) {
// Log.e(LOG_TAG, "Remote exception has occurred while fetching contact");
// return false;
// }
// return true;
// }
//
// public int fetchNoOfContacts() {
// Log.i (LOG_TAG,"Calling fetchNoOfContacts ()");
// try {
// int count = mRemoteService.fetchNoOfContacts();
// Log.i (LOG_TAG,"Number Of Contacts Fetched = "+ count);
// return count;
// } catch (RemoteException e) {
// Log.e(LOG_TAG, "Unable to fetch number of contacts");
// return 0;
// }
//		
// }
// public boolean fetchContactSummaryList(ArrayList<ContactSummary> list,
// int first, int count) {
// Log.i (LOG_TAG, "Calling fetchContactSummaryList ()");
// try {
// ServiceStatus status =
// ServiceStatus.fromInteger(mRemoteService.fetchContactList(list, first,
// count));
// if (ServiceStatus.SUCCESS != status) {
// Log.e(LOG_TAG, "Fetch contact list failed: " + status);
// return false;
// }
// } catch (RemoteException e) {
// Log.e(LOG_TAG,
// "Remote exception has occurred while fetching contact list");
// return false;
// }
// return true;
// }
//	
// public boolean addContactDetail(ContactDetail detail) {
// Log.i (LOG_TAG, "Calling addContactDetail ()");
// try {
// ServiceStatus status =
// ServiceStatus.fromInteger(mRemoteService.addContactDetail(detail));
// if (ServiceStatus.SUCCESS != status) {
// Log.e(LOG_TAG, "Add contact detail failed: " + status);
// return false;
// }
// Log.i (LOG_TAG, "Contact detail added successfully");
// } catch (RemoteException e) {
// Log.e(LOG_TAG,
// "Remote exception has occurred while adding contact detail");
// return false;
// }
// return true;
// }
//
// public boolean removeContactDetail(long localDetailID) {
// Log.i (LOG_TAG, "Calling removeContactDetail ()");
// try {
// ServiceStatus status =
// ServiceStatus.fromInteger(mRemoteService.removeContactDetail(localDetailID));
// if (ServiceStatus.SUCCESS != status) {
// Log.e(LOG_TAG, "Remove contact detail failed: " + status);
// return false;
// }
// Log.i (LOG_TAG, "Contact detail removed successfully");
// } catch (RemoteException e) {
// Log.e(LOG_TAG,
// "Remote exception has occurred while removing contact detail");
// return false;
// }
// return true;
// }
//
// public boolean modifyContactDetail(ContactDetail detail) {
// Log.i (LOG_TAG, "Calling modifyContactDetail ()");
// try {
// ServiceStatus status =
// ServiceStatus.fromInteger(mRemoteService.modifyContactDetail(detail));
// if (ServiceStatus.SUCCESS != status) {
// Log.e(LOG_TAG, "Modify contact detail failed: " + status);
// return false;
// }
// Log.i (LOG_TAG, "Modify contact details successful");
// } catch (RemoteException e) {
// Log.e("NowPlusServiceTestHelper",
// "Remote exception has occurred while modifying contact detail");
// return false;
// }
// return true;
// }
//	
public boolean register(RegistrationDetails details) {
    ServiceStatus status = ServiceStatus.SUCCESS;
    synchronized (mUiRequestLock) {
        status = startSynchronousRequest(ServiceUiRequest.REGISTRATION);
        mPeopleService.register(details);
    // status = finishSynchronousRequest(status, null);
    }
    Log.i("NowPlusServiceTestHelper", "Registration result: " + status);
    return (status.equals(ServiceStatus.SUCCESS));
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Aggregations

RegistrationDetails (com.vodafone360.people.datatypes.RegistrationDetails)7 ServiceStatus (com.vodafone360.people.service.ServiceStatus)7 MediumTest (android.test.suitebuilder.annotation.MediumTest)5 LoginDetails (com.vodafone360.people.datatypes.LoginDetails)4 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 PublicKeyDetails (com.vodafone360.people.datatypes.PublicKeyDetails)2 Suppress (android.test.suitebuilder.annotation.Suppress)1