### Question:
History { @Nonnull public List<HistoryState> getRecent() { return getRecent(true); } @Inject  History(); void init(@NonNull Executor initThread); void addRecent(@Nonnull HistoryState state); void updateSaved(@Nonnull HistoryState state); @Nonnull List<HistoryState> getRecent(); @Nonnull List<HistoryState> getSaved(); void clearRecent(); void clearSaved(); void undo(); void redo(); void removeSaved(@Nonnull HistoryState state); @Subscribe void onDisplayChanged(@Nonnull Display.ChangedEvent e); boolean isLoaded(); void runWhenLoaded(@NonNull Runnable runnable); static final String OLD_HISTORY_PREFS_KEY; }### Answer:
@Test public void testGetStates() throws Exception { addState("1"); addState("12"); addState("123"); addState("123+"); addState("123+3"); addState(""); addState("2"); addState("23"); addState("235"); addState("2355"); addState("235"); addState("2354"); addState("23547"); final List<HistoryState> states = history.getRecent(); assertEquals(3, states.size()); assertEquals("23547", states.get(0).editor.getTextString()); assertEquals("235", states.get(1).editor.getTextString()); assertEquals("123+3", states.get(2).editor.getTextString()); }
@Test public void testRecentHistoryShouldNotContainEmptyStates() throws Exception { addState(""); addState("1"); addState("12"); addState(""); addState(""); addState("34"); addState(""); final List<HistoryState> states = history.getRecent(); assertEquals(2, states.size()); assertEquals("34", states.get(0).editor.getTextString()); assertEquals("12", states.get(1).editor.getTextString()); }