### Question:
History { public void init(@NonNull Executor initThread) { Check.isMainThread(); bus.register(this); initThread.execute(new Runnable() { @Override public void run() { initAsync(); } }); } @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 testShouldReportOnMigrateException() throws Exception { when(history.preferences.getString(eq(History.OLD_HISTORY_PREFS_KEY), anyString())).thenReturn( "boom"); history.init(sameThreadExecutor()); verify(history.errorReporter).onException(any(Throwable.class)); }
@Test public void testShouldNotRemoveOldHistoryOnError() throws Exception { when(history.preferences.getString(eq(History.OLD_HISTORY_PREFS_KEY), anyString())).thenReturn("boom"); history.init(sameThreadExecutor()); verify(history.preferences, never()).edit(); verify(history.errorReporter).onException(any(Throwable.class)); }