Search in sources :

Example 11 with GeoReport

use of org.infobip.mobile.messaging.geo.report.GeoReport in project mobile-messaging-sdk-android by infobip.

the class GeoReportHelperTest method test_should_find_signaling_messages_for_report.

@Test
public void test_should_find_signaling_messages_for_report() throws Exception {
    // Given
    Message m1 = createMessage(context, "signalingMessageId", "campaignId", true, createArea("areaId"));
    Message m2 = createMessage(context, "signalingMessageI2", "campaignId", true, createArea("areaId"));
    Message m3 = createMessage(context, "signalingMessageI3", "campaignId", true, createArea("areaId"));
    GeoReport report = createReport(context, "signalingMessageId", "campaignId", "sdkMessageId", false);
    // When
    Message foundMessage = GeoReportHelper.getSignalingMessageForReport(Arrays.asList(m1, m2, m3), report);
    // Then
    assertJEquals(m1, foundMessage);
}
Also used : GeoReport(org.infobip.mobile.messaging.geo.report.GeoReport) Message(org.infobip.mobile.messaging.Message) Test(org.junit.Test)

Example 12 with GeoReport

use of org.infobip.mobile.messaging.geo.report.GeoReport in project mobile-messaging-sdk-android by infobip.

the class GeoReportHelperTest method test_should_filter_reports_for_inactive_campaigns.

@Test
public void test_should_filter_reports_for_inactive_campaigns() throws Exception {
    // Given
    Area area = createArea("areaId");
    EventReportResponse reportResponse = new EventReportResponse();
    reportResponse.setFinishedCampaignIds(Sets.newSet("campaignId1"));
    reportResponse.setSuspendedCampaignIds(Sets.newSet("campaignId2"));
    createMessage(context, "signalingMessageId1", "campaignId1", true, area);
    createMessage(context, "signalingMessageId2", "campaignId2", true, area);
    createMessage(context, "signalingMessageId3", "campaignId3", true, area);
    GeoReportingResult geoReportingResult = new GeoReportingResult(reportResponse);
    List<GeoReport> reports = Arrays.asList(createReport(context, "signalingMessageId1", "campaignId1", "sdkMessageId1", false, area), createReport(context, "signalingMessageId2", "campaignId2", "sdkMessageId2", false, area), createReport(context, "signalingMessageId3", "campaignId3", "sdkMessageId3", false, area));
    // When
    List<GeoReport> filtered = GeoReportHelper.filterOutNonActiveReports(context, reports, geoReportingResult);
    // Then
    assertJEquals(reports.get(2), filtered.get(0));
}
Also used : EventReportResponse(org.infobip.mobile.messaging.api.geo.EventReportResponse) GeoReport(org.infobip.mobile.messaging.geo.report.GeoReport) GeoReportingResult(org.infobip.mobile.messaging.geo.report.GeoReportingResult) Test(org.junit.Test)

Example 13 with GeoReport

use of org.infobip.mobile.messaging.geo.report.GeoReport in project mobile-messaging-sdk-android by infobip.

the class GeoReportHelperTest method test_should_create_messages_with_generated_ids_for_unsuccessful_report.

@Test
public void test_should_create_messages_with_generated_ids_for_unsuccessful_report() {
    // Given
    Area area = createArea("areaId");
    GeoReport report = createReport(context, "signalingMessageId", "campaignId", "sdkMessageId", false, area);
    GeoReportingResult geoReportingResult = new GeoReportingResult(new Exception());
    createMessage(context, "signalingMessageId", "campaignId", true, area);
    // When
    Map<Message, GeoEventType> messages = GeoReportHelper.createMessagesToNotify(context, Collections.singletonList(report), geoReportingResult);
    // Then
    Message generated = messages.keySet().iterator().next();
    assertEquals("sdkMessageId", generated.getMessageId());
    assertEquals(GeoEventType.entry, messages.values().iterator().next());
}
Also used : GeoReport(org.infobip.mobile.messaging.geo.report.GeoReport) Message(org.infobip.mobile.messaging.Message) GeoReportingResult(org.infobip.mobile.messaging.geo.report.GeoReportingResult) Test(org.junit.Test)

Aggregations

GeoReport (org.infobip.mobile.messaging.geo.report.GeoReport)13 Test (org.junit.Test)11 Message (org.infobip.mobile.messaging.Message)7 EventReportResponse (org.infobip.mobile.messaging.api.geo.EventReportResponse)7 GeoReportingResult (org.infobip.mobile.messaging.geo.report.GeoReportingResult)7 EventReportBody (org.infobip.mobile.messaging.api.geo.EventReportBody)4 Context (android.content.Context)3 GeoTransition (org.infobip.mobile.messaging.geo.transition.GeoTransition)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Intent (android.content.Intent)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 EventReport (org.infobip.mobile.messaging.api.geo.EventReport)1 MessagePayload (org.infobip.mobile.messaging.api.geo.MessagePayload)1