use of org.infobip.mobile.messaging.Message 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);
}
use of org.infobip.mobile.messaging.Message 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());
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class NotificationCategoriesTest method shouldPerformSendMoAndMarkMessagesSeen_whenTriggeringSdkActions.
@Test
public void shouldPerformSendMoAndMarkMessagesSeen_whenTriggeringSdkActions() throws Exception {
// given
Message givenMessage = createMessage(context, "SomeMessageId", false);
NotificationAction givenTappedNotificationAction = givenNotificationAction("actionId").withMoMessage().build();
NotificationCategory givenCategory = givenNotificationCategory(givenTappedNotificationAction);
// when
mobileInteractive.triggerSdkActionsFor(givenCategory.getCategoryId(), givenTappedNotificationAction, givenMessage);
// then
Mockito.verify(mmcMock, Mockito.times(1)).setMessagesSeen(messageIdArgumentCaptor.capture());
Mockito.verify(mmcMock, Mockito.times(1)).sendMessagesWithRetry(messageArgumentCaptor.capture());
Message actualMessage = messageArgumentCaptor.getValue();
assertEquals(givenCategory.getCategoryId() + " " + givenTappedNotificationAction.getId(), actualMessage.getBody());
assertEquals(givenMessage.getMessageId(), InternalDataMapper.getInternalDataInitialMessageId(actualMessage.getInternalData()));
assertEquals(givenMessage.getMessageId(), messageIdArgumentCaptor.getValue());
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class AndroidInteractiveBroadcasterTest method test_should_send_notification_action_tapped_event.
@Test
public void test_should_send_notification_action_tapped_event() throws Exception {
// Given
Message givenMessage = createMessage(context, "SomeMessageId", false);
NotificationAction notificationAction = givenNotificationAction("actionIdNotTapped").build();
NotificationAction givenTappedNotificationAction = givenNotificationAction("actionId").build();
NotificationCategory givenNotificationCategory = new NotificationCategory("categoryId", notificationAction, givenTappedNotificationAction);
// When
broadcastSender.notificationActionTapped(givenMessage, givenNotificationCategory, givenTappedNotificationAction);
// Then
Mockito.verify(contextMock, Mockito.times(1)).sendBroadcast(intentArgumentCaptor.capture());
Intent intent = intentArgumentCaptor.getValue();
assertEquals(InteractiveEvent.NOTIFICATION_ACTION_TAPPED.getKey(), intent.getAction());
Message messageAfter = Message.createFrom(intent.getExtras());
NotificationAction actionAfter = NotificationAction.createFrom(intent.getExtras());
NotificationCategory categoryAfter = NotificationCategory.createFrom(intent.getExtras());
assertNotSame(message, messageAfter);
assertEquals("SomeMessageId", messageAfter.getMessageId());
assertJEquals(givenMessage, messageAfter);
assertJEquals(givenTappedNotificationAction, actionAfter);
assertJEquals(givenNotificationCategory, categoryAfter);
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class MobileMessagingTestCase method createMessage.
/**
* Generates messages with provided ids and geo campaign object
*
* @param saveToStorage set to true to save messages to message store
* @param messageId message id for a message
* @return new message
*/
protected static Message createMessage(Context context, String messageId, boolean saveToStorage) {
Message message = new Message();
message.setMessageId(messageId);
if (saveToStorage) {
MobileMessagingCore.getInstance(context).getMessageStore().save(context, message);
}
return message;
}
Aggregations