### Question:
History { @Nullable static List<HistoryState> convertOldHistory(@NonNull String xml) throws Exception { final OldHistory history = OldHistory.fromXml(xml); if (history == null) { return null; } final List<HistoryState> states = new ArrayList<>(); for (OldHistoryState state : history.getItems()) { final OldEditorHistoryState oldEditor = state.getEditorState(); final OldDisplayHistoryState oldDisplay = state.getDisplayState(); final String editorText = oldEditor.getText(); final EditorState editor = EditorState.create(Strings.nullToEmpty(editorText), oldEditor.getCursorPosition()); final DisplayState display = DisplayState.createValid(oldDisplay.getJsclOperation(), null, Strings.nullToEmpty(oldDisplay.getEditorState().getText()), Calculator.NO_SEQUENCE); states.add(HistoryState.builder(editor, display).withTime(state.getTime()).withComment(state.getComment()).build()); } return states; } @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 testShouldConvertOldHistory() throws Exception { List<HistoryState> states = History.convertOldHistory(oldXml1); assertNotNull(states); assertEquals(1, states.size()); HistoryState state = states.get(0); assertEquals(100000000, state.time); assertEquals("", state.comment); assertEquals("1+1", state.editor.getTextString()); assertEquals(3, state.editor.selection); assertEquals("Error", state.display.text); assertEquals(true, state.display.valid); assertNull(state.display.getResult()); states = History.convertOldHistory(oldXml2); checkOldXml2States(states); }