use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class ActivitiesEngineTest method testMessageLog.
/*
* @MediumTest public void testGetTimelineEvent(){ boolean testPass = true;
* mState = ActivityTestState.GET_TIMELINE_EVENT_FROM_SERVER; Contact
* meProfile = mTestModule.createDummyContactData(); ServiceStatus status =
* mApplication.getDatabase().setMeProfile(meProfile); if(status !=
* ServiceStatus.SUCCESS){ throw(new
* RuntimeException("Could not access db")); }
* mEng.addUiGetActivitiesRequest(); status = mEngineTester.waitForEvent();
* if(status != ServiceStatus.SUCCESS){ throw(new
* RuntimeException("Expected SUCCESS")); } Object data =
* mEngineTester.data(); assertTrue(data==null);
* mEng.addUiGetActivitiesRequest(); status = mEngineTester.waitForEvent();
* if(status != ServiceStatus.SUCCESS){ throw(new
* RuntimeException("Expected SUCCESS")); } data = mEngineTester.data();
* assertTrue(data==null); assertTrue("testPushMessage() failed", testPass);
* Log.i(LOG_TAG, "**** testGetTimelineEvent (SUCCESS) ****\n"); }
*/
@MediumTest
// Takes too long.
@Suppress
public void testMessageLog() {
final String ADDRESS = "address";
// final String PERSON = "person";
final String DATE = "date";
final String READ = "read";
final String STATUS = "status";
final String TYPE = "type";
final String BODY = "body";
ContentValues values = new ContentValues();
values.put(ADDRESS, "+61408219690");
values.put(DATE, "1630000000000");
values.put(READ, 1);
values.put(STATUS, -1);
values.put(TYPE, 2);
values.put(BODY, "SMS inserting test");
/* Uri inserted = */
mApplication.getContentResolver().insert(Uri.parse("content://sms"), values);
mState = ActivityTestState.GET_ACTIVITIES_SUCCESS;
// re-test with valid Me profile
Contact meProfile = mTestModule.createDummyContactData();
assertEquals("Could not access db", ServiceStatus.SUCCESS, SyncMeDbUtils.setMeProfile(mApplication.getDatabase(), meProfile));
mEng.addStatusesSyncRequest();
assertEquals("Expected SUCCESS, not timeout", ServiceStatus.SUCCESS, mEngineTester.waitForEvent());
Object data = mEngineTester.data();
assertTrue(data == null);
values.put(DATE, "1650000000000");
/* inserted = */
mApplication.getContentResolver().insert(Uri.parse("content://mms"), values);
mEng.addStatusesSyncRequest();
assertEquals("Could not access db", ServiceStatus.SUCCESS, mEngineTester.waitForEvent());
Log.i(LOG_TAG, "**** testGetActivities (SUCCESS) ****\n");
}
use of com.vodafone360.people.service.ServiceStatus 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");
}
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class LoginEngineTest method testPublicFunctions.
// @MediumTest
// public void testSmsResponse(){
// LoginDetails loginDetails = new LoginDetails();
// loginDetails.mMobileNo = "123456789";
// loginDetails.mUsername = "bob";
// loginDetails.mPassword = "ajob";
//
// mState = LoginTestState.LOGIN_REQUEST;
// NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
// synchronized(mEngineTester){
// mEng.addUiLoginRequest(loginDetails);
//
// ServiceStatus status = mEngineTester.waitForEvent();
// assertEquals(ServiceStatus.SUCCESS, status);
// }
// // test actually receiving the SMS
// mState = LoginTestState.SMS_RESPONSE_SIGNIN;
//
// mEng.handleSmsResponse();
//
// ServiceStatus status = mEngineTester.waitForEvent(30000);
// assertEquals(ServiceStatus.SUCCESS, status);
// }
@MediumTest
public void testPublicFunctions() {
mEng.getLoginRequired();
NetworkAgent.setAgentState(NetworkAgent.AgentState.DISCONNECTED);
mEng.getNewPublicKey();
NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
mEng.getNewPublicKey();
mEng.isDeactivated();
mEng.setActivatedSession(new AuthSessionHolder());
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class SyncMeEngine method processSetMeResponse.
/**
* Processes the response from a SetMe request. If successful, the server
* IDs will be stored in the local database if they have changed. Otherwise
* the processor will complete with a suitable error.
* @param resp Response from server.
*/
private void processSetMeResponse(final DecodedResponse resp) {
LogUtils.logD("SyncMeProfile.processMeProfileUpdateResponse()");
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.CONTACT_CHANGES_DATA_TYPE, resp.mDataTypes);
if (status == ServiceStatus.SUCCESS) {
ContactChanges result = (ContactChanges) resp.mDataTypes.get(0);
SyncMeDbUtils.updateMeProfileDbDetailIds(mDbHelper, mUploadedMeDetails, result);
if (updateRevisionPostUpdate(result.mServerRevisionBefore, result.mServerRevisionAfter, mFromRevision, mDbHelper)) {
mFromRevision = result.mServerRevisionAfter;
}
}
completeUiRequest(status);
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class SyncMeEngine method processUpdateStatusResponse.
/**
* This method processes the response to status update by setMe() method
* @param resp Response - the expected response datatype is ContactChanges
*/
private void processUpdateStatusResponse(final DecodedResponse resp) {
LogUtils.logD("SyncMeDbUtils processUpdateStatusResponse()");
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.CONTACT_CHANGES_DATA_TYPE, resp.mDataTypes);
if (status == ServiceStatus.SUCCESS) {
ContactChanges result = (ContactChanges) resp.mDataTypes.get(0);
LogUtils.logI("SyncMeProfile.processUpdateStatusResponse() - Me profile userId = " + result.mUserProfile.userID);
SyncMeDbUtils.savePresenceStatusResponse(mDbHelper, result);
}
completeUiRequest(status);
}
Aggregations