Search in sources :

Example 1 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class DatabaseHelper method deleteActivities.

/***
     * Removes all the status or timeline activities from the database. Note:
     * Only called from tests.
     * 
     * @param flag The type of activity to delete or null to delete all
     * @return SUCCESS or a suitable error code
     * @see #addActivities(List)
     * @see #fetchActivitiesIds(List, Long)
     */
public ServiceStatus deleteActivities(Integer flag) {
    if (Settings.ENABLED_DATABASE_TRACE)
        trace(false, "DatabaseHelper.deleteActivities() flag[" + flag + "]");
    ServiceStatus status = ActivitiesTable.deleteActivities(flag, getWritableDatabase());
    if (ServiceStatus.SUCCESS == status) {
        if (flag == null || flag.intValue() == ActivityItem.TIMELINE_ITEM) {
            StateTable.modifyLatestPhoneCallTime(System.currentTimeMillis(), getWritableDatabase());
        }
    }
    fireDatabaseChangedEvent(DatabaseChangeType.ACTIVITIES, true);
    return status;
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 2 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class ContactSyncEngineTest method testFirstTimeSync_dummyProcessors.

/**
     * Verifies that the first time sync triggers a call to the correct
     * processors and in the right order.
     */
@Suppress
public // Breaks tests.
void testFirstTimeSync_dummyProcessors() {
    // list of the processors in calling order
    final ArrayList<Integer> processorTypeList = new ArrayList<Integer>();
    // list of expected processors in the right calling order
    final ArrayList<Integer> expectedTypeList = new ArrayList<Integer>();
    // set the expected processors
    expectedTypeList.add(new Integer(ProcessorFactory.DOWNLOAD_SERVER_CONTACTS));
    expectedTypeList.add(new Integer(ProcessorFactory.FETCH_NATIVE_CONTACTS));
    expectedTypeList.add(new Integer(ProcessorFactory.SYNC_ME_PROFILE));
    expectedTypeList.add(new Integer(ProcessorFactory.UPLOAD_SERVER_CONTACTS));
    final ProcessorFactory factory = new ProcessorFactory() {

        @Override
        public BaseSyncProcessor create(int type, IContactSyncCallback callback, DatabaseHelper dbHelper) {
            Log.i(LOG_TAG, "create(), type=" + type);
            processorTypeList.add(new Integer(type));
            return new DummySyncProcessor(mContactSyncEngine, null);
        }
    };
    final IEngineEventCallback engineEventCallback = new HelperClasses.EngineCallbackBase();
    minimalEngineSetup(engineEventCallback, factory);
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    mContactSyncEngine.addUiStartFullSync();
    mContactSyncEngine.run();
    // check the processors order
    assertTrue(processorTypeList.equals(expectedTypeList));
}
Also used : DatabaseHelper(com.vodafone360.people.database.DatabaseHelper) ArrayList(java.util.ArrayList) ProcessorFactory(com.vodafone360.people.engine.contactsync.ProcessorFactory) IContactSyncCallback(com.vodafone360.people.engine.contactsync.IContactSyncCallback) IEngineEventCallback(com.vodafone360.people.engine.IEngineEventCallback) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 3 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class ContactSyncEngineTest method testUiRequestCompleteEvent_serverSync.

/**
     * Verifies that server sync completes correctly.
     */
@Suppress
public // Breaks tests.
void testUiRequestCompleteEvent_serverSync() {
    Log.i(LOG_TAG, "**** testUiRequestCompleteEvent_serverSync() begin ****");
    final UiEventCall uiEventCall = new UiEventCall();
    final IEngineEventCallback engineEventCallback = new HelperClasses.EngineCallbackBase() {

        @Override
        public void onUiEvent(ServiceUiRequest event, int request, int status, Object data) {
            Log.i(LOG_TAG, "onUiEvent: " + event + ", " + request + ", " + status + ", " + data);
            uiEventCall.event = event.ordinal();
            uiEventCall.request = request;
            uiEventCall.status = status;
            uiEventCall.data = data;
        }
    };
    final ProcessorFactory factory = new ProcessorFactory() {

        @Override
        public BaseSyncProcessor create(int type, IContactSyncCallback callback, DatabaseHelper dbHelper) {
            Log.i(LOG_TAG, "create(), type=" + type);
            return new DummySyncProcessor(mContactSyncEngine, null);
        }
    };
    minimalEngineSetup(engineEventCallback, factory);
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    long nextRuntime = mContactSyncEngine.getNextRunTime();
    // should be equal to -1 because first time sync has not been yet
    // started
    assertEquals(-1, nextRuntime);
    // set the connection to be fine
    NetworkAgent.setAgentState(AgentState.CONNECTED);
    // ask for a full sync
    mContactSyncEngine.addUiStartFullSync();
    nextRuntime = mContactSyncEngine.getNextRunTime();
    assertEquals(0, nextRuntime);
    mContactSyncEngine.run();
    // check that first time sync is completed
    assertEquals(ServiceUiRequest.UI_REQUEST_COMPLETE.ordinal(), uiEventCall.event);
    assertEquals(uiEventCall.status, ServiceStatus.SUCCESS.ordinal());
    // check that first time sync is completed
    assertEquals(ServiceUiRequest.UI_REQUEST_COMPLETE.ordinal(), uiEventCall.event);
    assertEquals(uiEventCall.status, ServiceStatus.SUCCESS.ordinal());
    Log.i(LOG_TAG, "**** testUiRequestCompleteEvent_serverSync() end ****");
}
Also used : DatabaseHelper(com.vodafone360.people.database.DatabaseHelper) ServiceUiRequest(com.vodafone360.people.service.ServiceUiRequest) ProcessorFactory(com.vodafone360.people.engine.contactsync.ProcessorFactory) IContactSyncCallback(com.vodafone360.people.engine.contactsync.IContactSyncCallback) IEngineEventCallback(com.vodafone360.people.engine.IEngineEventCallback) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 4 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class ContactSyncEngineTest method testEventCallback.

/**
     * Checks that the engine events are correctly sent to listeners.
     */
@Suppress
public // Breaks tests.
void testEventCallback() {
    Log.i(LOG_TAG, "**** testEventCallback() begin ****");
    // Set up the expected events
    final ArrayList<ContactSyncObserver.ContactSyncStateChanged> expectedCssc = new ArrayList<ContactSyncObserver.ContactSyncStateChanged>();
    final ArrayList<ContactSyncObserver.ProgressEvent> expectedPe = new ArrayList<ContactSyncObserver.ProgressEvent>();
    final ArrayList<ContactSyncObserver.SyncComplete> expectedSc = new ArrayList<ContactSyncObserver.SyncComplete>();
    setupExpectedFirstTimeSyncObserverCalls(expectedCssc, expectedPe, expectedSc);
    final UiEventCall uiEventCall = new UiEventCall();
    final IEngineEventCallback engineEventCallback = new HelperClasses.EngineCallbackBase() {

        @Override
        public void onUiEvent(ServiceUiRequest event, int request, int status, Object data) {
            Log.i(LOG_TAG, "onUiEvent: " + event + ", " + request + ", " + status + ", " + data);
            uiEventCall.event = event.ordinal();
            uiEventCall.request = request;
            uiEventCall.status = status;
            uiEventCall.data = data;
        }
    };
    final ProcessorFactory factory = new ProcessorFactory() {

        @Override
        public BaseSyncProcessor create(int type, IContactSyncCallback callback, DatabaseHelper dbHelper) {
            Log.i(LOG_TAG, "create(), type=" + type);
            return new DummySyncProcessor(mContactSyncEngine, null);
        }
    };
    final ContactSyncObserver observer = new ContactSyncObserver();
    minimalEngineSetup(engineEventCallback, factory);
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    // add a listener
    mContactSyncEngine.addEventCallback(observer);
    // ask for a full sync
    mContactSyncEngine.addUiStartFullSync();
    // perform the sync
    mContactSyncEngine.run();
    // compare the retrieved events with the expected ones
    assertTrue(expectedCssc.equals(observer.mCsscList));
    assertTrue(expectedPe.equals(observer.mPeList));
    assertTrue(expectedSc.equals(observer.mScList));
    Log.i(LOG_TAG, "**** testEventCallback() end ****");
}
Also used : ArrayList(java.util.ArrayList) ServiceUiRequest(com.vodafone360.people.service.ServiceUiRequest) DatabaseHelper(com.vodafone360.people.database.DatabaseHelper) ProcessorFactory(com.vodafone360.people.engine.contactsync.ProcessorFactory) IContactSyncCallback(com.vodafone360.people.engine.contactsync.IContactSyncCallback) IContactSyncObserver(com.vodafone360.people.engine.contactsync.ContactSyncEngine.IContactSyncObserver) IEngineEventCallback(com.vodafone360.people.engine.IEngineEventCallback) Suppress(android.test.suitebuilder.annotation.Suppress)

Example 5 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class ContactSyncEngineTest method testAutoSyncTimer.

/**
     * Checks that nothing is scheduled before the first time sync has been
     * completed.
     */
@Suppress
public void testAutoSyncTimer() {
    Log.i(LOG_TAG, "**** testAutoSyncTimer() begin ****");
    final IEngineEventCallback engineEventCallback = new HelperClasses.EngineCallbackBase() {

        @Override
        public void onUiEvent(ServiceUiRequest event, int request, int status, Object data) {
            Log.i(LOG_TAG, "onUiEvent: " + event + ", " + request + ", " + status + ", " + data);
        }
    };
    final ProcessorFactory factory = new ProcessorFactory() {

        @Override
        public BaseSyncProcessor create(int type, IContactSyncCallback callback, DatabaseHelper dbHelper) {
            Log.i(LOG_TAG, "create(), type=" + type);
            return new DummySyncProcessor(mContactSyncEngine, null);
        }
    };
    minimalEngineSetup(engineEventCallback, factory);
    // set the connection to be fine
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    // should be equal to -1 because first time sync has not been yet
    // started
    assertEquals(-1, mContactSyncEngine.getNextRunTime());
    mContactSyncEngine.run();
    assertEquals(-1, mContactSyncEngine.getNextRunTime());
    mContactSyncEngine.run();
    assertEquals(-1, mContactSyncEngine.getNextRunTime());
    Log.i(LOG_TAG, "**** testAutoSyncTimer() end ****");
}
Also used : DatabaseHelper(com.vodafone360.people.database.DatabaseHelper) ServiceUiRequest(com.vodafone360.people.service.ServiceUiRequest) ProcessorFactory(com.vodafone360.people.engine.contactsync.ProcessorFactory) IContactSyncCallback(com.vodafone360.people.engine.contactsync.IContactSyncCallback) IEngineEventCallback(com.vodafone360.people.engine.IEngineEventCallback) Suppress(android.test.suitebuilder.annotation.Suppress)

Aggregations

ArrayList (java.util.ArrayList)14 Suppress (android.test.suitebuilder.annotation.Suppress)13 DatabaseHelper (com.vodafone360.people.database.DatabaseHelper)11 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)11 IEngineEventCallback (com.vodafone360.people.engine.IEngineEventCallback)11 IContactSyncCallback (com.vodafone360.people.engine.contactsync.IContactSyncCallback)11 ProcessorFactory (com.vodafone360.people.engine.contactsync.ProcessorFactory)11 ServiceStatus (com.vodafone360.people.service.ServiceStatus)10 ServiceUiRequest (com.vodafone360.people.service.ServiceUiRequest)10 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)7 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)6 Identity (com.vodafone360.people.datatypes.Identity)6 Request (com.vodafone360.people.service.io.Request)5 Cursor (android.database.Cursor)4 Contact (com.vodafone360.people.datatypes.Contact)4 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)4 ServerError (com.vodafone360.people.datatypes.ServerError)4 SQLException (android.database.SQLException)3 SQLiteException (android.database.sqlite.SQLiteException)3 Bundle (android.os.Bundle)3