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);
}
Aggregations