use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testRestartSessionIfNeededFromClose.
@Test
public void testRestartSessionIfNeededFromClose() throws JSONException {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.onInAppMessageReceived(IAM_ID);
sessionManager.onNotificationReceived(NOTIFICATION_ID);
OSInfluence iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, iamInfluences.getInfluenceType());
assertEquals(IAM_ID, iamInfluences.getIds().get(0));
sessionManager.restartSessionIfNeeded(OneSignal.AppEntryAction.APP_CLOSE);
iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
OSInfluence notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, iamInfluences.getInfluenceType());
assertEquals(IAM_ID, iamInfluences.getIds().get(0));
assertEquals(OSInfluenceType.UNATTRIBUTED, notificationInfluences.getInfluenceType());
assertNull(notificationInfluences.getIds());
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testRestartSessionIfNeededFromNotification.
@Test
public void testRestartSessionIfNeededFromNotification() throws JSONException {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.onInAppMessageReceived(IAM_ID);
sessionManager.onNotificationReceived(NOTIFICATION_ID);
OSInfluence iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, iamInfluences.getInfluenceType());
assertEquals(IAM_ID, iamInfluences.getIds().get(0));
sessionManager.restartSessionIfNeeded(OneSignal.AppEntryAction.NOTIFICATION_CLICK);
iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
OSInfluence notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, iamInfluences.getInfluenceType());
assertEquals(IAM_ID, iamInfluences.getIds().get(0));
assertEquals(OSInfluenceType.UNATTRIBUTED, notificationInfluences.getInfluenceType());
assertNull(notificationInfluences.getIds());
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testSessionUpgradeFromDirectToDirectSameID.
@Test
public void testSessionUpgradeFromDirectToDirectSameID() throws Exception {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
sessionManager.onNotificationReceived(GENERIC_ID);
sessionManager.onDirectInfluenceFromNotificationOpen(GENERIC_ID);
OSInfluence notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.DIRECT, notificationInfluences.getInfluenceType());
assertEquals(GENERIC_ID, notificationInfluences.getIds().get(0));
sessionManager.attemptSessionUpgrade(OneSignal.AppEntryAction.NOTIFICATION_CLICK);
threadAndTaskWait();
notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.DIRECT, notificationInfluences.getInfluenceType());
assertEquals(1, notificationInfluences.getIds().length());
assertEquals(GENERIC_ID, notificationInfluences.getIds().get(0));
// We test that channel ending is working
assertEquals(1, lastInfluencesBySessionEnding.size());
assertEquals(OSInfluenceChannel.NOTIFICATION, lastInfluencesBySessionEnding.get(0).getInfluenceChannel());
assertEquals(OSInfluenceType.UNATTRIBUTED, lastInfluencesBySessionEnding.get(0).getInfluenceType());
assertNull(lastInfluencesBySessionEnding.get(0).getIds());
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testSessionUpgradeFromIndirectToDirect.
@Test
public void testSessionUpgradeFromIndirectToDirect() throws Exception {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
sessionManager.onNotificationReceived(GENERIC_ID);
sessionManager.onInAppMessageReceived(GENERIC_ID);
sessionManager.attemptSessionUpgrade(OneSignal.AppEntryAction.APP_OPEN);
OSInfluence iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
OSInfluence notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, iamInfluences.getInfluenceType());
assertEquals(OSInfluenceType.INDIRECT, notificationInfluences.getInfluenceType());
assertEquals(GENERIC_ID, notificationInfluences.getIds().get(0));
sessionManager.onDirectInfluenceFromNotificationOpen(NOTIFICATION_ID);
threadAndTaskWait();
iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, iamInfluences.getInfluenceType());
assertEquals(1, iamInfluences.getIds().length());
assertEquals(GENERIC_ID, iamInfluences.getIds().get(0));
assertEquals(OSInfluenceType.DIRECT, notificationInfluences.getInfluenceType());
assertEquals(1, notificationInfluences.getIds().length());
assertEquals(NOTIFICATION_ID, notificationInfluences.getIds().get(0));
// We test that channel ending is working for both IAM and Notification
assertEquals(1, lastInfluencesBySessionEnding.size());
OSInfluence endingNotificationInfluence = lastInfluencesBySessionEnding.get(0);
assertEquals(OSInfluenceChannel.NOTIFICATION, endingNotificationInfluence.getInfluenceChannel());
assertEquals(OSInfluenceType.INDIRECT, endingNotificationInfluence.getInfluenceType());
assertEquals(1, endingNotificationInfluence.getIds().length());
assertEquals(GENERIC_ID, endingNotificationInfluence.getIds().get(0));
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testIndirectInfluence.
@Test
public void testIndirectInfluence() throws Exception {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
sessionManager.onInAppMessageReceived(GENERIC_ID);
sessionManager.onNotificationReceived(GENERIC_ID);
sessionManager.restartSessionIfNeeded(OneSignal.AppEntryAction.APP_OPEN);
for (OSInfluence influence : sessionManager.getInfluences()) {
assertTrue(influence.getInfluenceType().isIndirect());
assertEquals(1, influence.getIds().length());
assertEquals(GENERIC_ID, influence.getIds().get(0));
}
}
Aggregations