### Question:
WearNotifications extends BaseNotifications { public Notification buildStackedNotification(Account account, NotificationHolder holder) { int notificationId = holder.notificationId; NotificationContent content = holder.content; NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId); PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent( context, content.messageReference, holder.notificationId); builder.setDeleteIntent(deletePendingIntent); addActions(builder, account, holder); return builder.build(); } WearNotifications(NotificationController controller, NotificationActionCreator actionCreator); Notification buildStackedNotification(Account account, NotificationHolder holder); void addSummaryActions(Builder builder, NotificationData notificationData);  }### Answer:
@Test public void testBuildStackedNotification() throws Exception { disableOptionalActions(); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); MessageReference messageReference = createMessageReference(1); NotificationContent content = createNotificationContent(messageReference); NotificationHolder holder = createNotificationHolder(notificationId, content); PendingIntent replyPendingIntent = createFakePendingIntent(1); when(actionCreator.createReplyPendingIntent(messageReference, notificationId)).thenReturn(replyPendingIntent); PendingIntent markAsReadPendingIntent = createFakePendingIntent(2); when(actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId)) .thenReturn(markAsReadPendingIntent); Notification result = wearNotifications.buildStackedNotification(account, holder); assertEquals(notification, result); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_single_message_options_dark, "Reply", replyPendingIntent); verifyAddAction(R.drawable.ic_action_mark_as_read_dark, "Mark Read", markAsReadPendingIntent); verifyNumberOfActions(2); }
@Test public void testBuildStackedNotificationWithDeleteActionEnabled() throws Exception { enableDeleteAction(); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); MessageReference messageReference = createMessageReference(1); NotificationContent content = createNotificationContent(messageReference); NotificationHolder holder = createNotificationHolder(notificationId, content); PendingIntent deletePendingIntent = createFakePendingIntent(1); when(actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId)) .thenReturn(deletePendingIntent); Notification result = wearNotifications.buildStackedNotification(account, holder); assertEquals(notification, result); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_delete_dark, "Delete", deletePendingIntent); }
@Test public void testBuildStackedNotificationWithArchiveActionEnabled() throws Exception { enableArchiveAction(); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); MessageReference messageReference = createMessageReference(1); NotificationContent content = createNotificationContent(messageReference); NotificationHolder holder = createNotificationHolder(notificationId, content); PendingIntent archivePendingIntent = createFakePendingIntent(1); when(actionCreator.createArchiveMessagePendingIntent(messageReference, notificationId)) .thenReturn(archivePendingIntent); Notification result = wearNotifications.buildStackedNotification(account, holder); assertEquals(notification, result); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_archive_dark, "Archive", archivePendingIntent); }
@Test public void testBuildStackedNotificationWithMarkAsSpamActionEnabled() throws Exception { enableSpamAction(); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); MessageReference messageReference = createMessageReference(1); NotificationContent content = createNotificationContent(messageReference); NotificationHolder holder = createNotificationHolder(notificationId, content); PendingIntent markAsSpamPendingIntent = createFakePendingIntent(1); when(actionCreator.createMarkMessageAsSpamPendingIntent(messageReference, notificationId)) .thenReturn(markAsSpamPendingIntent); Notification result = wearNotifications.buildStackedNotification(account, holder); assertEquals(notification, result); verifyExtendWasOnlyCalledOnce(); verifyAddAction(R.drawable.ic_action_spam_dark, "Spam", markAsSpamPendingIntent); }