@Test public void testAddNewMailNotificationTwice() throws Exception { int notificationIndexOne = 0; int notificationIndexTwo = 1; LocalMessage messageOne = createLocalMessage(); LocalMessage messageTwo = createLocalMessage(); NotificationContent contentOne = createNotificationContent(); NotificationContent contentTwo = createNotificationContent(); NotificationHolder holderOne = createNotificationHolder(contentOne, notificationIndexOne); NotificationHolder holderTwo = createNotificationHolder(contentTwo, notificationIndexTwo); addToNotificationContentCreator(messageOne, contentOne); addToNotificationContentCreator(messageTwo, contentTwo); whenAddingContentReturn(contentOne, AddNotificationResult.newNotification(holderOne)); whenAddingContentReturn(contentTwo, AddNotificationResult.newNotification(holderTwo)); Notification wearNotificationOne = createNotification(); Notification wearNotificationTwo = createNotification(); Notification summaryNotification = createNotification(); addToWearNotifications(holderOne, wearNotificationOne); addToWearNotifications(holderTwo, wearNotificationTwo); addToDeviceNotifications(summaryNotification); newMailNotifications.addNewMailNotification(account, messageOne, 42); newMailNotifications.addNewMailNotification(account, messageTwo, 42); int wearNotificationIdOne = NotificationIds.getNewMailStackedNotificationId(account, notificationIndexOne); int wearNotificationIdTwo = NotificationIds.getNewMailStackedNotificationId(account, notificationIndexTwo); int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account); verify(notificationManager).notify(wearNotificationIdOne, wearNotificationOne); verify(notificationManager).notify(wearNotificationIdTwo, wearNotificationTwo); verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification); }
public void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount) { NotificationContent content = contentCreator.createFromMessage(account, message); synchronized (lock) { NotificationData notificationData = getOrCreateNotificationData(account, unreadMessageCount); AddNotificationResult result = notificationData.addNotificationContent(content); if (result.shouldCancelNotification()) { int notificationId = result.getNotificationId(); cancelNotification(notificationId); } createStackedNotification(account, result.getNotificationHolder()); createSummaryNotification(account, notificationData, false); } }
NewMailNotifications { public void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount) { NotificationContent content = contentCreator.createFromMessage(account, message); synchronized (lock) { NotificationData notificationData = getOrCreateNotificationData(account, unreadMessageCount); AddNotificationResult result = notificationData.addNotificationContent(content); if (result.shouldCancelNotification()) { int notificationId = result.getNotificationId(); cancelNotification(notificationId); } createStackedNotification(account, result.getNotificationHolder()); createSummaryNotification(account, notificationData, false); } } }
NewMailNotifications { public void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount) { NotificationContent content = contentCreator.createFromMessage(account, message); synchronized (lock) { NotificationData notificationData = getOrCreateNotificationData(account, unreadMessageCount); AddNotificationResult result = notificationData.addNotificationContent(content); if (result.shouldCancelNotification()) { int notificationId = result.getNotificationId(); cancelNotification(notificationId); } createStackedNotification(account, result.getNotificationHolder()); createSummaryNotification(account, notificationData, false); } } NewMailNotifications(NotificationController controller, NotificationContentCreator contentCreator,
            DeviceNotifications deviceNotifications, WearNotifications wearNotifications); }
NewMailNotifications { public void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount) { NotificationContent content = contentCreator.createFromMessage(account, message); synchronized (lock) { NotificationData notificationData = getOrCreateNotificationData(account, unreadMessageCount); AddNotificationResult result = notificationData.addNotificationContent(content); if (result.shouldCancelNotification()) { int notificationId = result.getNotificationId(); cancelNotification(notificationId); } createStackedNotification(account, result.getNotificationHolder()); createSummaryNotification(account, notificationData, false); } } NewMailNotifications(NotificationController controller, NotificationContentCreator contentCreator,
            DeviceNotifications deviceNotifications, WearNotifications wearNotifications); static NewMailNotifications newInstance(NotificationController controller,
            NotificationActionCreator actionCreator); void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount); void removeNewMailNotification(Account account, MessageReference messageReference); void clearNewMailNotifications(Account account); }
NewMailNotifications { public void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount) { NotificationContent content = contentCreator.createFromMessage(account, message); synchronized (lock) { NotificationData notificationData = getOrCreateNotificationData(account, unreadMessageCount); AddNotificationResult result = notificationData.addNotificationContent(content); if (result.shouldCancelNotification()) { int notificationId = result.getNotificationId(); cancelNotification(notificationId); } createStackedNotification(account, result.getNotificationHolder()); createSummaryNotification(account, notificationData, false); } } NewMailNotifications(NotificationController controller, NotificationContentCreator contentCreator,
            DeviceNotifications deviceNotifications, WearNotifications wearNotifications); static NewMailNotifications newInstance(NotificationController controller,
            NotificationActionCreator actionCreator); void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount); void removeNewMailNotification(Account account, MessageReference messageReference); void clearNewMailNotifications(Account account);  }