Inbox { @NonNull public List<Message> getReadMessages(@Nullable Predicate<Message> predicate) { synchronized (inboxLock) { List<Message> messages = new ArrayList<>(filterMessages(readMessages.values(), predicate)); Collections.sort(messages, MESSAGE_COMPARATOR); return messages; } } 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 testGetReadMessages() { HashSet<String> messageIds = new HashSet<>(); messageIds.add("1_message_id"); messageIds.add("2_message_id"); messageIds.add("3_message_id"); messageIds.add("4_message_id"); inbox.markMessagesRead(messageIds); List<Message> readMessages = inbox.getReadMessages(); assertEquals(readMessages.size(), 4); List<Message> filteredMessages = inbox.getReadMessages(testPredicate); assertEquals(filteredMessages.size(), 2); for (Message message : filteredMessages) { String substring = message.getMessageId().replace("_message_id", ""); int index = Integer.parseInt(substring); assertEquals(index % 2, 0); } }