Search in sources :

Example 6 with NotificationCategory

use of org.infobip.mobile.messaging.interactive.NotificationCategory 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);
}
Also used : Message(org.infobip.mobile.messaging.Message) NotificationAction(org.infobip.mobile.messaging.interactive.NotificationAction) Intent(android.content.Intent) NotificationCategory(org.infobip.mobile.messaging.interactive.NotificationCategory) Test(org.junit.Test)

Aggregations

NotificationCategory (org.infobip.mobile.messaging.interactive.NotificationCategory)6 Message (org.infobip.mobile.messaging.Message)5 NotificationAction (org.infobip.mobile.messaging.interactive.NotificationAction)5 Intent (android.content.Intent)4 Test (org.junit.Test)4 Bundle (android.os.Bundle)1 NotificationCompat (android.support.v4.app.NotificationCompat)1