Search in sources :

Example 11 with OSChannelTracker

use of com.onesignal.influence.data.OSChannelTracker in project OneSignal-Android-SDK by OneSignal.

the class SessionManagerUnitTests method testDirectNotificationInitInfluence.

@Test
public void testDirectNotificationInitInfluence() throws JSONException {
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
    sessionManager.initSessionFromCache();
    OSChannelTracker notificationTracker = trackerFactory.getNotificationChannelTracker();
    assertEquals(0, notificationTracker.getLastReceivedIds().length());
    sessionManager.onNotificationReceived(NOTIFICATION_ID);
    sessionManager.onDirectInfluenceFromNotificationOpen(NOTIFICATION_ID);
    notificationTracker = trackerFactory.getNotificationChannelTracker();
    OSInfluence influence = notificationTracker.getCurrentSessionInfluence();
    assertEquals(OSInfluenceType.DIRECT, notificationTracker.getInfluenceType());
    assertEquals(NOTIFICATION_ID, notificationTracker.getLastReceivedIds().get(0));
    assertEquals(OSInfluenceChannel.NOTIFICATION, influence.getInfluenceChannel());
    assertEquals(OSInfluenceType.DIRECT, influence.getInfluenceType());
    assertEquals(1, influence.getIds().length());
    assertEquals(NOTIFICATION_ID, influence.getIds().get(0));
}
Also used : OSChannelTracker(com.onesignal.influence.data.OSChannelTracker) OSInfluence(com.onesignal.influence.domain.OSInfluence) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Test(org.junit.Test)

Aggregations

OSChannelTracker (com.onesignal.influence.data.OSChannelTracker)11 OSInfluence (com.onesignal.influence.domain.OSInfluence)7 OneSignalPackagePrivateHelper (com.onesignal.OneSignalPackagePrivateHelper)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)2 JSONArray (org.json.JSONArray)2