@Test public void ensureFolderExistsNothingToDo() { File folder = mock(File.class); doReturn(true).when(folder).exists(); doReturn(true).when(folder).isDirectory(); markupToEclipseHelp.ensureFolderExists("test", folder, false); verify(folder).exists(); verify(folder).isDirectory(); verifyNoMoreInteractions(folder); }
protected void ensureFolderExists(String name, File folder, boolean createIfMissing) { if (folder.exists()) { if (!folder.isDirectory()) { throw new BuildFailureException(format("{0} exists but is not a folder: {1}", name, folder)); } return; } if (!createIfMissing) { throw new BuildFailureException(format("{0} does not exist: {1}", name, folder)); } if (!folder.mkdirs()) { throw new BuildFailureException(format("Cannot create {0}: {1}", name, folder)); } }
MarkupToEclipseHelpMojo extends AbstractMojo { protected void ensureFolderExists(String name, File folder, boolean createIfMissing) { if (folder.exists()) { if (!folder.isDirectory()) { throw new BuildFailureException(format("{0} exists but is not a folder: {1}", name, folder)); } return; } if (!createIfMissing) { throw new BuildFailureException(format("{0} does not exist: {1}", name, folder)); } if (!folder.mkdirs()) { throw new BuildFailureException(format("Cannot create {0}: {1}", name, folder)); } } }
MarkupToEclipseHelpMojo extends AbstractMojo { protected void ensureFolderExists(String name, File folder, boolean createIfMissing) { if (folder.exists()) { if (!folder.isDirectory()) { throw new BuildFailureException(format("{0} exists but is not a folder: {1}", name, folder)); } return; } if (!createIfMissing) { throw new BuildFailureException(format("{0} does not exist: {1}", name, folder)); } if (!folder.mkdirs()) { throw new BuildFailureException(format("Cannot create {0}: {1}", name, folder)); } }  }
MarkupToEclipseHelpMojo extends AbstractMojo { protected void ensureFolderExists(String name, File folder, boolean createIfMissing) { if (folder.exists()) { if (!folder.isDirectory()) { throw new BuildFailureException(format("{0} exists but is not a folder: {1}", name, folder)); } return; } if (!createIfMissing) { throw new BuildFailureException(format("{0} does not exist: {1}", name, folder)); } if (!folder.mkdirs()) { throw new BuildFailureException(format("Cannot create {0}: {1}", name, folder)); } }  void execute(); }
MarkupToEclipseHelpMojo extends AbstractMojo { protected void ensureFolderExists(String name, File folder, boolean createIfMissing) { if (folder.exists()) { if (!folder.isDirectory()) { throw new BuildFailureException(format("{0} exists but is not a folder: {1}", name, folder)); } return; } if (!createIfMissing) { throw new BuildFailureException(format("{0} does not exist: {1}", name, folder)); } if (!folder.mkdirs()) { throw new BuildFailureException(format("Cannot create {0}: {1}", name, folder)); } }  void execute();  }