Search in sources :

Example 6 with Geo

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

the class AndroidGeoBroadcasterTest method test_should_send_geo_event.

@Test
public void test_should_send_geo_event() {
    // Given
    Geo geo = new Geo(0.0, 0.0, null, null, null, "SomeCampaignId", Collections.singletonList(createArea("areaId1")), new ArrayList<GeoEventSettings>(), 0, null);
    Message message = createMessage(context, "SomeMessageId", false, geo);
    // When
    broadcastSender.geoEvent(GeoEventType.entry, GeoMessage.createFrom(message, geo));
    // Then
    Mockito.verify(contextMock, Mockito.times(1)).sendBroadcast(intentArgumentCaptor.capture());
    Intent intent = intentArgumentCaptor.getValue();
    assertEquals(GeoEvent.GEOFENCE_AREA_ENTERED.getKey(), intent.getAction());
    GeoMessage geoMessage = GeoMessage.createFrom(intent.getExtras());
    assertNotSame(message, geoMessage);
    assertEquals("SomeMessageId", geoMessage.getMessageId());
}
Also used : Geo(org.infobip.mobile.messaging.geo.Geo) GeoMessage(org.infobip.mobile.messaging.geo.GeoMessage) GeoMessage(org.infobip.mobile.messaging.geo.GeoMessage) Message(org.infobip.mobile.messaging.Message) GeoEventSettings(org.infobip.mobile.messaging.geo.GeoEventSettings) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

Message (org.infobip.mobile.messaging.Message)6 Geo (org.infobip.mobile.messaging.geo.Geo)6 ArrayList (java.util.ArrayList)4 Area (org.infobip.mobile.messaging.geo.Area)4 Date (java.util.Date)3 GeoMessage (org.infobip.mobile.messaging.geo.GeoMessage)2 Intent (android.content.Intent)1 NonNull (android.support.annotation.NonNull)1 ArrayMap (android.support.v4.util.ArrayMap)1 Pair (android.util.Pair)1 Geofence (com.google.android.gms.location.Geofence)1 HashMap (java.util.HashMap)1 List (java.util.List)1 GeoEventSettings (org.infobip.mobile.messaging.geo.GeoEventSettings)1 GeoEventType (org.infobip.mobile.messaging.geo.GeoEventType)1 GeoLatLng (org.infobip.mobile.messaging.geo.GeoLatLng)1 GeoSQLiteMessageStore (org.infobip.mobile.messaging.geo.storage.GeoSQLiteMessageStore)1 Test (org.junit.Test)1