Search in sources :

Example 6 with OSOutcomeEventParams

use of com.onesignal.outcomes.domain.OSOutcomeEventParams in project OneSignal-Android-SDK by OneSignal.

the class OutcomeEventV2UnitTests method testOutcomeIndirectFailSavedOnDB.

@Test
public void testOutcomeIndirectFailSavedOnDB() throws Exception {
    service.setSuccess(false);
    sessionManager.initSessionFromCache();
    sessionManager.onInAppMessageReceived(IAM_ID);
    sessionManager.onNotificationReceived(NOTIFICATION_ID);
    sessionManager.restartSessionIfNeeded(OneSignal.AppEntryAction.APP_OPEN);
    controller.sendOutcomeEvent(OUTCOME_NAME);
    threadAndTaskWait();
    handler.setOutcomes(repository.getSavedOutcomeEvents());
    threadAndTaskWait();
    assertTrue(outcomeEvents.size() > 0);
    OSOutcomeEventParams params = outcomeEvents.get(0);
    assertEquals(OUTCOME_NAME, params.getOutcomeId());
    assertEquals(new Float(0), (Float) params.getWeight());
    assertTrue(params.getTimestamp() > 0);
    assertNotNull(params.getOutcomeSource());
    // Indirect body
    assertEquals(1, params.getOutcomeSource().getIndirectBody().getInAppMessagesIds().length());
    assertEquals(IAM_ID, params.getOutcomeSource().getIndirectBody().getInAppMessagesIds().get(0));
    assertEquals(1, params.getOutcomeSource().getIndirectBody().getNotificationIds().length());
    assertEquals(NOTIFICATION_ID, params.getOutcomeSource().getIndirectBody().getNotificationIds().get(0));
    // Direct body
    assertNull(params.getOutcomeSource().getDirectBody());
}
Also used : OSOutcomeEventParams(com.onesignal.outcomes.domain.OSOutcomeEventParams) Test(org.junit.Test)

Aggregations

OSOutcomeEventParams (com.onesignal.outcomes.domain.OSOutcomeEventParams)6 Test (org.junit.Test)4 OSInfluence (com.onesignal.influence.domain.OSInfluence)1 OSOutcomeSource (com.onesignal.outcomes.domain.OSOutcomeSource)1 OSOutcomeSourceBody (com.onesignal.outcomes.domain.OSOutcomeSourceBody)1