Search in sources :

Example 1 with OSOutcomeEventsFactory

use of com.onesignal.outcomes.data.OSOutcomeEventsFactory in project OneSignal-Android-SDK by OneSignal.

the class OneSignal method setupContextListeners.

private static void setupContextListeners(boolean wasAppContextNull) {
    // Register the lifecycle listener of the app for state changes in activities with proper context
    ActivityLifecycleListener.registerActivityLifecycleCallbacks((Application) appContext);
    // Do work here that should only happen once or at the start of a new lifecycle
    if (wasAppContextNull) {
        // Set Language Context to null
        languageContext = new LanguageContext(preferences);
        // Prefs require a context to save
        // If the previous state of appContext was null, kick off write in-case it was waiting
        OneSignalPrefs.startDelayedWrite();
        OneSignalDbHelper dbHelper = getDBHelperInstance();
        notificationDataController = new OSNotificationDataController(dbHelper, logger);
        // Cleans out old cached data to prevent over using the storage on devices
        notificationDataController.cleanOldCachedData();
        getInAppMessageController().cleanCachedInAppMessages();
        if (outcomeEventsFactory == null)
            outcomeEventsFactory = new OSOutcomeEventsFactory(logger, apiClient, dbHelper, preferences);
        sessionManager.initSessionFromCache();
        outcomeEventsController = new OSOutcomeEventsController(sessionManager, outcomeEventsFactory);
        outcomeEventsController.cleanCachedUniqueOutcomes();
    }
}
Also used : LanguageContext(com.onesignal.language.LanguageContext) OSOutcomeEventsFactory(com.onesignal.outcomes.data.OSOutcomeEventsFactory)

Example 2 with OSOutcomeEventsFactory

use of com.onesignal.outcomes.data.OSOutcomeEventsFactory in project OneSignal-Android-SDK by OneSignal.

the class OutcomeEventV2UnitTests method beforeEachTest.

// Before each test
@Before
public void beforeEachTest() throws Exception {
    outcomeEvents = null;
    dbHelper = new MockOneSignalDBHelper(ApplicationProvider.getApplicationContext());
    // Mock on a custom HashMap in order to not use custom context
    preferences = new MockOSSharedPreferences();
    // Save v2 flag
    String v2Name = preferences.getOutcomesV2KeyName();
    preferences.saveBool(preferences.getPreferencesName(), v2Name, true);
    MockOSTimeImpl time = new MockOSTimeImpl();
    trackerFactory = new OSTrackerFactory(preferences, logWrapper, time);
    sessionManager = new MockSessionManager(sessionListener, trackerFactory, logWrapper);
    service = new MockOneSignalAPIClient();
    OSOutcomeEventsFactory factory = new OSOutcomeEventsFactory(logWrapper, service, dbHelper, preferences);
    controller = new MockOutcomeEventsController(sessionManager, factory);
    TestHelpers.beforeTestInitAndCleanup();
    repository = factory.getRepository();
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
    OneSignal.setAppId(APP_ID);
}
Also used : OSTrackerFactory(com.onesignal.influence.data.OSTrackerFactory) MockOneSignalDBHelper(com.onesignal.MockOneSignalDBHelper) MockOSTimeImpl(com.onesignal.MockOSTimeImpl) MockSessionManager(com.onesignal.MockSessionManager) MockOSSharedPreferences(com.onesignal.MockOSSharedPreferences) MockOneSignalAPIClient(com.onesignal.MockOneSignalAPIClient) OSOutcomeEventsFactory(com.onesignal.outcomes.data.OSOutcomeEventsFactory) MockOutcomeEventsController(com.onesignal.MockOutcomeEventsController) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Before(org.junit.Before)

Example 3 with OSOutcomeEventsFactory

use of com.onesignal.outcomes.data.OSOutcomeEventsFactory in project OneSignal-Android-SDK by OneSignal.

the class OutcomeEventUnitTests method beforeEachTest.

// Before each test
@Before
public void beforeEachTest() throws Exception {
    outcomeEvents = null;
    MockOSTimeImpl time = new MockOSTimeImpl();
    dbHelper = new MockOneSignalDBHelper(ApplicationProvider.getApplicationContext());
    // Mock on a custom HashMap in order to not use custom context
    preferences = new MockOSSharedPreferences();
    trackerFactory = new OSTrackerFactory(preferences, logWrapper, time);
    sessionManager = new MockSessionManager(sessionListener, trackerFactory, logWrapper);
    service = new MockOneSignalAPIClient();
    OSOutcomeEventsFactory factory = new OSOutcomeEventsFactory(logWrapper, service, dbHelper, preferences);
    controller = new MockOutcomeEventsController(sessionManager, factory);
    TestHelpers.beforeTestInitAndCleanup();
    repository = factory.getRepository();
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
    OneSignal.setAppId(APP_ID);
}
Also used : OSTrackerFactory(com.onesignal.influence.data.OSTrackerFactory) MockOneSignalDBHelper(com.onesignal.MockOneSignalDBHelper) MockOSTimeImpl(com.onesignal.MockOSTimeImpl) MockSessionManager(com.onesignal.MockSessionManager) MockOSSharedPreferences(com.onesignal.MockOSSharedPreferences) MockOneSignalAPIClient(com.onesignal.MockOneSignalAPIClient) OSOutcomeEventsFactory(com.onesignal.outcomes.data.OSOutcomeEventsFactory) MockOutcomeEventsController(com.onesignal.MockOutcomeEventsController) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Before(org.junit.Before)

Aggregations

OSOutcomeEventsFactory (com.onesignal.outcomes.data.OSOutcomeEventsFactory)3 MockOSSharedPreferences (com.onesignal.MockOSSharedPreferences)2 MockOSTimeImpl (com.onesignal.MockOSTimeImpl)2 MockOneSignalAPIClient (com.onesignal.MockOneSignalAPIClient)2 MockOneSignalDBHelper (com.onesignal.MockOneSignalDBHelper)2 MockOutcomeEventsController (com.onesignal.MockOutcomeEventsController)2 MockSessionManager (com.onesignal.MockSessionManager)2 OneSignalPackagePrivateHelper (com.onesignal.OneSignalPackagePrivateHelper)2 OSTrackerFactory (com.onesignal.influence.data.OSTrackerFactory)2 Before (org.junit.Before)2 LanguageContext (com.onesignal.language.LanguageContext)1