### Question:
Editor { public void insert(@Nonnull String text) { Check.isMainThread(); insert(text, 0); } @Inject  Editor(@Nonnull Application application, @Nonnull SharedPreferences preferences, @Nonnull Engine engine); void init(); static int clamp(int selection, @Nonnull CharSequence text); static int clamp(int selection, int max); void setView(@Nonnull EditorView view); void clearView(@Nonnull EditorView view); @Nonnull EditorState getState(); void setState(@Nonnull EditorState state); @Nonnull EditorState setCursorOnStart(); @Nonnull EditorState setCursorOnEnd(); @Nonnull EditorState moveCursorLeft(); @Nonnull EditorState moveCursorRight(); boolean erase(); void clear(); void setText(@Nonnull String text); void setText(@Nonnull String text, int selection); void insert(@Nonnull String text); void insert(@Nonnull String text, int selectionOffset); @Nonnull EditorState moveSelection(int offset); @Nonnull EditorState setSelection(int selection); @Subscribe void onEngineChanged(@Nonnull Engine.ChangedEvent e); @Subscribe void onMemoryValueReady(@Nonnull Memory.ValueReadyEvent e); void onHistoryLoaded(@Nonnull RecentHistory history);  }### Answer:
@Test public void testInsert() throws Exception { EditorState viewState = editor.getState(); Assert.assertEquals("", viewState.getTextString()); Assert.assertEquals(0, viewState.selection); viewState = insertAndGet(""); Assert.assertEquals("", viewState.getTextString()); Assert.assertEquals(0, viewState.selection); viewState = insertAndGet("test"); Assert.assertEquals("test", viewState.getTextString()); Assert.assertEquals(4, viewState.selection); viewState = insertAndGet("test"); Assert.assertEquals("testtest", viewState.getTextString()); Assert.assertEquals(8, viewState.selection); viewState = insertAndGet(""); Assert.assertEquals("testtest", viewState.getTextString()); Assert.assertEquals(8, viewState.selection); viewState = insertAndGet("1234567890"); Assert.assertEquals("testtest1234567890", viewState.getTextString()); Assert.assertEquals(18, viewState.selection); editor.moveCursorLeft(); viewState = insertAndGet("9"); Assert.assertEquals("testtest12345678990", viewState.getTextString()); Assert.assertEquals(18, viewState.selection); editor.setCursorOnStart(); viewState = insertAndGet("9"); Assert.assertEquals("9testtest12345678990", viewState.getTextString()); Assert.assertEquals(1, viewState.selection); editor.erase(); viewState = insertAndGet("9"); Assert.assertEquals("9testtest12345678990", viewState.getTextString()); Assert.assertEquals(1, viewState.selection); viewState = insertAndGet("öäü"); Assert.assertEquals("9öäütesttest12345678990", viewState.getTextString()); editor.setCursorOnEnd(); viewState = insertAndGet("öäü"); Assert.assertEquals("9öäütesttest12345678990öäü", viewState.getTextString()); }