### Question:
EditorModel { public void openWithExternalEditor(final File file) throws ConsoleException { final ExternalEditor externalEditor; synchronized (this) { externalEditor = m_externalEditor; } if (externalEditor == null) { throw new DisplayMessageConsoleException(m_resources, "externalEditorNotSet.text"); } try { externalEditor.open(file); } catch (IOException e) { throw new DisplayMessageConsoleException(m_resources, "externalEditError.text", e); } } EditorModel(Resources resources,
                     TextSource.Factory textSourceFactory,
                     AgentCacheState agentCacheState,
                     FileChangeWatcher fileChangeWatcher); Buffer getSelectedBuffer(); void selectNewBuffer(); Buffer selectBufferForFile(File file); Buffer getBufferForFile(File file); Buffer[] getBuffers(); boolean isABufferDirty(); void selectBuffer(Buffer buffer); void closeBuffer(final Buffer buffer); File getSelectedPropertiesFile(); void setSelectedPropertiesFile(final File selectedProperties); void addListener(Listener listener); boolean isScriptFile(File f); boolean isPropertiesFile(File f); boolean isSelectedScript(File f); boolean isBoringFile(File f); void openWithExternalEditor(final File file); void setExternalEditor(File command, String arguments);  }### Answer:
@Test public void testOpenWithExternalEditor() throws Exception { final EditorModel editorModel = new EditorModel(s_resources, new StringTextSource.Factory(), m_agentCacheState, m_fileChangeWatcher); try { editorModel.openWithExternalEditor(null); fail("Expected DisplayMessageConsoleException"); } catch (DisplayMessageConsoleException e) { assertNull(e.getCause()); } editorModel.setExternalEditor(new File("not a command"), "bah"); try { editorModel.openWithExternalEditor(new File("foo")); fail("Expected DisplayMessageConsoleException"); } catch (DisplayMessageConsoleException e) { assertTrue(e.getCause() instanceof IOException); } editorModel.setExternalEditor(null, "bah"); try { editorModel.openWithExternalEditor(new File("foo")); fail("Expected DisplayMessageConsoleException"); } catch (DisplayMessageConsoleException e) { assertNull(e.getCause()); } }