Inbox { @NonNull public List<Message> getMessages(@Nullable Predicate<Message> predicate) { synchronized (inboxLock) { List<Message> messages = new ArrayList<>(); messages.addAll(filterMessages(unreadMessages.values(), predicate)); messages.addAll(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 testGetMessages() { List<Message> messages = inbox.getMessages(); Assert.assertEquals(messages.size(), inbox.getCount()); List<Message> filteredMessages = inbox.getMessages(testPredicate); Assert.assertEquals(filteredMessages.size(), inbox.getCount() / 2); }