use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testUnattributedInitInfluence.
@Test
public void testUnattributedInitInfluence() {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
List<OSInfluence> influences = sessionManager.getInfluences();
for (OSInfluence influence : influences) {
assertTrue(influence.getInfluenceType().isUnattributed());
assertNull(influence.getIds());
}
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testRestartSessionIfNeededFromOpen.
@Test
public void testRestartSessionIfNeededFromOpen() 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_OPEN);
iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
OSInfluence notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, iamInfluences.getInfluenceType());
assertEquals(IAM_ID, iamInfluences.getIds().get(0));
assertEquals(OSInfluenceType.INDIRECT, notificationInfluences.getInfluenceType());
assertEquals(NOTIFICATION_ID, notificationInfluences.getIds().get(0));
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testIndirectIAMInitInfluence.
@Test
public void testIndirectIAMInitInfluence() throws JSONException {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
OSChannelTracker iamTracker = trackerFactory.getIAMChannelTracker();
assertEquals(0, iamTracker.getLastReceivedIds().length());
sessionManager.onInAppMessageReceived(IAM_ID);
iamTracker = trackerFactory.getIAMChannelTracker();
OSInfluence influence = iamTracker.getCurrentSessionInfluence();
assertEquals(OSInfluenceType.INDIRECT, iamTracker.getInfluenceType());
assertEquals(IAM_ID, iamTracker.getLastReceivedIds().get(0));
assertEquals(OSInfluenceChannel.IAM, influence.getInfluenceChannel());
assertEquals(OSInfluenceType.INDIRECT, influence.getInfluenceType());
assertEquals(1, influence.getIds().length());
assertEquals(IAM_ID, influence.getIds().get(0));
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testIndirectNotificationQuantityInfluence.
@Test
public void testIndirectNotificationQuantityInfluence() throws Exception {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
for (int i = 0; i < INFLUENCE_ID_LIMIT + 5; i++) {
sessionManager.onNotificationReceived(GENERIC_ID + i);
}
sessionManager.restartSessionIfNeeded(OneSignal.AppEntryAction.APP_OPEN);
OSInfluence influence = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertTrue(influence.getInfluenceType().isIndirect());
assertEquals(INFLUENCE_ID_LIMIT, influence.getIds().length());
assertEquals(GENERIC_ID + "5", influence.getIds().get(0));
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class SessionManagerUnitTests method testSessionUpgradeFromDirectToDirectEndChannelsDirect.
@Test
public void testSessionUpgradeFromDirectToDirectEndChannelsDirect() throws Exception {
trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
sessionManager.initSessionFromCache();
sessionManager.onNotificationReceived(GENERIC_ID);
sessionManager.onDirectInfluenceFromNotificationOpen(GENERIC_ID);
sessionManager.onInAppMessageReceived(IAM_ID);
sessionManager.onDirectInfluenceFromIAMClick(IAM_ID);
threadAndTaskWait();
OSInfluence iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
OSInfluence notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.DIRECT, iamInfluences.getInfluenceType());
assertEquals(OSInfluenceType.DIRECT, notificationInfluences.getInfluenceType());
assertEquals(IAM_ID, iamInfluences.getIds().get(0));
assertEquals(GENERIC_ID, notificationInfluences.getIds().get(0));
sessionManager.onDirectInfluenceFromNotificationOpen(NOTIFICATION_ID);
threadAndTaskWait();
iamInfluences = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
notificationInfluences = trackerFactory.getNotificationChannelTracker().getCurrentSessionInfluence();
assertEquals(OSInfluenceType.DIRECT, notificationInfluences.getInfluenceType());
assertEquals(1, notificationInfluences.getIds().length());
assertEquals(NOTIFICATION_ID, notificationInfluences.getIds().get(0));
assertEquals(OSInfluenceType.INDIRECT, iamInfluences.getInfluenceType());
assertEquals(IAM_ID, iamInfluences.getIds().get(0));
// We test that channel ending is working for both IAM and Notification
assertEquals(2, lastInfluencesBySessionEnding.size());
OSInfluence endingNotificationInfluence = lastInfluencesBySessionEnding.get(0);
OSInfluence endingIAMInfluence = lastInfluencesBySessionEnding.get(1);
assertEquals(OSInfluenceChannel.NOTIFICATION, endingNotificationInfluence.getInfluenceChannel());
assertEquals(OSInfluenceType.DIRECT, endingNotificationInfluence.getInfluenceType());
assertEquals(1, endingNotificationInfluence.getIds().length());
assertEquals(GENERIC_ID, endingNotificationInfluence.getIds().get(0));
assertEquals(OSInfluenceChannel.IAM, endingIAMInfluence.getInfluenceChannel());
assertEquals(OSInfluenceType.DIRECT, endingIAMInfluence.getInfluenceType());
assertEquals(1, endingIAMInfluence.getIds().length());
assertEquals(IAM_ID, endingIAMInfluence.getIds().get(0));
}
Aggregations