Inbox { public void markMessagesUnread(@NonNull final Set<String> messageIds) { executor.execute(new Runnable() { @Override public void run() { messageCenterResolver.markMessagesUnread(messageIds); } }); synchronized (inboxLock) { for (String messageId : messageIds) { Message message = readMessages.get(messageId); if (message != null) { message.unreadClient = true; readMessages.remove(messageId); unreadMessages.put(messageId, message); } } } notifyInboxUpdated(); } Inbox(@NonNull Context context, @NonNull PreferenceDataStore dataStore,
                 @NonNull AirshipChannel airshipChannel); @VisibleForTesting  Inbox(@NonNull Context context, @NonNull PreferenceDataStore dataStore, @NonNull final JobDispatcher jobDispatcher,
          @NonNull User user, @NonNull MessageCenterResolver resolver, @NonNull Executor executor,
          @NonNull ActivityMonitor activityMonitor, @NonNull AirshipChannel airshipChannel); @NonNull User getUser(); void addListener(@NonNull InboxListener listener); void removeListener(@NonNull InboxListener listener); void fetchMessages(); @Nullable Cancelable fetchMessages(@Nullable FetchMessagesCallback callback); @Nullable Cancelable fetchMessages(@Nullable Looper looper, @Nullable FetchMessagesCallback callback); int getCount(); @NonNull Set<String> getMessageIds(); int getReadCount(); int getUnreadCount(); @NonNull List<Message> getMessages(@Nullable Predicate<Message> predicate); @NonNull List<Message> getMessages(); @NonNull List<Message> getUnreadMessages(@Nullable Predicate<Message> predicate); @NonNull List<Message> getUnreadMessages(); @NonNull List<Message> getReadMessages(@Nullable Predicate<Message> predicate); @NonNull List<Message> getReadMessages(); @Nullable Message getMessage(@Nullable String messageId); @Nullable Message getMessageByUrl(@Nullable String messageUrl); void markMessagesRead(@NonNull final Set<String> messageIds); void markMessagesUnread(@NonNull final Set<String> messageIds); void deleteMessages(@NonNull final Set<String> messageIds);  }
@Test public void testMarkMessagesUnread() throws InterruptedException { HashSet<String> messageIds = new HashSet<>(); messageIds.add("1_message_id"); messageIds.add("3_message_id"); messageIds.add("6_message_id"); inbox.markMessagesRead(messageIds); assertEquals(3, inbox.getReadCount()); assertEquals(7, inbox.getUnreadCount()); inbox.markMessagesUnread(messageIds); assertEquals(10, inbox.getCount()); assertEquals(10, inbox.getUnreadCount()); assertEquals(0, inbox.getReadCount()); }