use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testIndirectNotificationInitInfluence.
@Test
public void testIndirectNotificationInitInfluence() throws JSONException {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
OSChannelTracker notificationTracker = trackerFactory.getNotificationChannelTracker();
assertEquals(0, notificationTracker.getLastReceivedIds().length());
sessionManager.onNotificationReceived(NOTIFICATION_ID);
sessionManager.attemptSessionUpgrade(OneSignal.AppEntryAction.APP_OPEN);
notificationTracker = trackerFactory.getNotificationChannelTracker();
OSInfluence influence = notificationTracker.getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, notificationTracker.getInfluenceType());
assertEquals(NOTIFICATION_ID, notificationTracker.getLastReceivedIds().get(0));
assertEquals(OSInfluenceChannel.NOTIFICATION, influence.getInfluenceChannel());
assertEquals(OSInfluenceType.INDIRECT, influence.getInfluenceType());
assertEquals(1, influence.getIds().length());
assertEquals(NOTIFICATION_ID, influence.getIds().get(0));
}
use of com.onesignal.influence.domain.OSInfluence 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));
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testSessionUpgradeFromDirectToDirectDifferentID.
@Test
public void testSessionUpgradeFromDirectToDirectDifferentID() 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.onNotificationReceived(NOTIFICATION_ID);
sessionManager.onDirectInfluenceFromNotificationOpen(NOTIFICATION_ID);
threadAndTaskWait();
notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.DIRECT, notificationInfluences.getInfluenceType());
assertEquals(1, notificationInfluences.getIds().length());
assertEquals(NOTIFICATION_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.DIRECT, lastInfluencesBySessionEnding.get(0).getInfluenceType());
assertEquals(1, lastInfluencesBySessionEnding.get(0).getIds().length());
assertEquals(GENERIC_ID, lastInfluencesBySessionEnding.get(0).getIds().get(0));
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testSessionUpgradeFromAppClosed.
@Test
public void testSessionUpgradeFromAppClosed() throws Exception {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
List<OSInfluence> influences = sessionManager.getInfluences();
for (OSInfluence influence : influences) {
assertEquals(OSInfluenceType.UNATTRIBUTED, influence.getInfluenceType());
assertNull(influence.getIds());
}
sessionManager.onNotificationReceived(GENERIC_ID);
sessionManager.onInAppMessageReceived(GENERIC_ID);
influences = sessionManager.getInfluences();
for (OSInfluence influence : influences) {
switch(influence.getInfluenceChannel()) {
case NOTIFICATION:
assertEquals(OSInfluenceType.UNATTRIBUTED, influence.getInfluenceType());
assertNull(influence.getIds());
break;
case IAM:
assertEquals(OSInfluenceType.INDIRECT, influence.getInfluenceType());
assertEquals(1, influence.getIds().length());
break;
}
}
sessionManager.attemptSessionUpgrade(OneSignal.AppEntryAction.APP_CLOSE);
threadAndTaskWait();
influences = sessionManager.getInfluences();
for (OSInfluence influence : influences) {
switch(influence.getInfluenceChannel()) {
case NOTIFICATION:
assertEquals(OSInfluenceType.UNATTRIBUTED, influence.getInfluenceType());
assertNull(influence.getIds());
break;
case IAM:
assertEquals(OSInfluenceType.INDIRECT, influence.getInfluenceType());
assertEquals(1, influence.getIds().length());
break;
}
}
// We test that channel ending is working
assertNull(lastInfluencesBySessionEnding);
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testSessionUpgradeFromUnattributedToDirectNotification.
@Test
public void testSessionUpgradeFromUnattributedToDirectNotification() throws Exception {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
OSInfluence iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
OSInfluence notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.UNATTRIBUTED, iamInfluences.getInfluenceType());
assertEquals(OSInfluenceType.UNATTRIBUTED, notificationInfluences.getInfluenceType());
sessionManager.onNotificationReceived(GENERIC_ID);
sessionManager.onInAppMessageReceived(GENERIC_ID);
sessionManager.onDirectInfluenceFromNotificationOpen(GENERIC_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(GENERIC_ID, notificationInfluences.getIds().get(0));
// We test that channel ending is working for Notification
assertEquals(1, lastInfluencesBySessionEnding.size());
OSInfluence endingNotificationInfluence = lastInfluencesBySessionEnding.get(0);
assertEquals(OSInfluenceChannel.NOTIFICATION, endingNotificationInfluence.getInfluenceChannel());
assertEquals(OSInfluenceType.UNATTRIBUTED, endingNotificationInfluence.getInfluenceType());
assertNull(endingNotificationInfluence.getIds());
}
Aggregations