RecentEmojiManager implements RecentEmoji { @Override @SuppressWarnings({ "PMD.AvoidDeeplyNestedIfStmts", "checkstyle:nestedifdepth" }) @NonNull public Collection<Emoji> getRecentEmojis() { if (emojiList.size() == 0) { final String savedRecentEmojis = sharedPreferences.getString(RECENT_EMOJIS, ""); if (savedRecentEmojis.length() > 0) { final StringTokenizer stringTokenizer = new StringTokenizer(savedRecentEmojis, EMOJI_DELIMITER); emojiList = new EmojiList(stringTokenizer.countTokens()); while (stringTokenizer.hasMoreTokens()) { final String token = stringTokenizer.nextToken(); final String[] parts = token.split(TIME_DELIMITER); if (parts.length == 2) { final Emoji emoji = EmojiManager.getInstance().findEmoji(parts[0]); if (emoji != null && emoji.getLength() == parts[0].length()) { final long timestamp = Long.parseLong(parts[1]); emojiList.add(emoji, timestamp); } } } } else { emojiList = new EmojiList(0); } } return emojiList.getEmojis(); } RecentEmojiManager(@NonNull final Context context); @Override @SuppressWarnings({ "PMD.AvoidDeeplyNestedIfStmts", "checkstyle:nestedifdepth" }) @NonNull Collection<Emoji> getRecentEmojis(); @Override void addEmoji(@NonNull final Emoji emoji); @Override void persist();  }
@Test public void getRecentEmojis() { assertThat(recentEmojiManager.getRecentEmojis()).isEmpty(); }