### Question:
MonacoEditorPresenter { public void setValue(String languageId, String value) { if (null != current && !current.equals(languageId)) { view.dispose(); current = null; } if (null == current) { getLanguageById(languageId).ifPresent(module -> load(module, value)); } else { view.setValue(value); } } @Inject  MonacoEditorPresenter(MonacoEditorView view); @PostConstruct void init(); MonacoEditorPresenter setOnChangeCallback(OnChangeCallback onChangeCallback); MonacoEditorPresenter setWidthPx(int widthPx); MonacoEditorPresenter setHeightPx(int heightPx); MonacoEditorPresenter setReadOnly(boolean readOnly); MonacoEditorPresenter addLanguage(MonacoEditorLanguage module); void setValue(String languageId, String value); String getValue(); String getLanguageId(); MonacoEditorView getView(); @PreDestroy void destroy();  }### Answer:
@Test public void testSetValue() { tested.setWidthPx(300); tested.setHeightPx(100); tested.setReadOnly(true); tested.addLanguage(MonacoEditorLanguage.JAVA); tested.setValue(MonacoEditorLanguage.LANG_JAVA, "someJavaCode"); assertEquals(MonacoEditorLanguage.LANG_JAVA, tested.current); verify(view, never()).dispose(); ArgumentCaptor<MonacoEditorOptions> optionsCaptor = ArgumentCaptor.forClass(MonacoEditorOptions.class); ArgumentCaptor<Runnable> callbackCaptor = ArgumentCaptor.forClass(Runnable.class); verify(view, times(1)).loadingStarts(); verify(view, times(1)).setLanguage(eq(MonacoEditorLanguage.LANG_JAVA)); verify(view, times(1)).load(eq(MonacoEditorLanguage.JAVA.getModules()), optionsCaptor.capture(), callbackCaptor.capture()); MonacoEditorOptions options = optionsCaptor.getValue(); assertEquals(300, options.getWidthPx()); assertEquals(100, options.getHeightPx()); assertEquals(MonacoEditorLanguage.LANG_JAVA, options.getLanguage()); assertEquals("someJavaCode", options.getValue()); assertTrue(options.isReadOnly()); assertFalse(options.isAutomaticLayout()); callbackCaptor.getValue().run(); verify(view, times(1)).loadingEnds(); verify(view, times(1)).setLanguageReadOnly(eq(true)); verify(view, times(1)).attachListenerToPanelTitle(); }
@Test public void testSetValueUsingCurrentLang() { tested.current = "lang1"; tested.setValue("lang1", "anotherValue"); assertEquals("lang1", tested.current); verify(view, never()).dispose(); verify(view, times(1)).setValue(eq("anotherValue")); }