### Question:
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); }  static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, boolean create, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugin, @NotNull Class<?> resourceJar, boolean create,
                                          @NotNull String... resources); @Nullable static FileConfiguration getYaml(@NotNull Plugin plugin, String... filename); @Nullable static FileConfiguration getYaml(@NotNull File file); @NotNull static FileConfiguration getYamlOrDefault(@NotNull Plugin plugin, @NotNull FileConfiguration def,
                                                   String... filename); @NotNull static FileConfiguration getYamlOrDefault(@NotNull File file, @NotNull FileConfiguration def); static boolean saveYaml(@NotNull Plugin plugin, FileConfiguration conf, String... savePath); static boolean saveYaml(@Nullable ConfigurationSection conf, @Nullable File file); @NotNull static Map<String, Object> getMapSection(@NotNull ConfigurationSection conf, @NotNull String path); @NotNull static Map<String, Object> getMapSection(@Nullable Object obj); @NotNull static ConfigurationSection getSection(@NotNull Object obj); @NotNull static ConfigurationSection getSectionFromMap(@NotNull Map<String, Object> map); static boolean isEmpty(@Nullable ConfigurationSection conf); @NotNull static FileConfiguration toFileConf(@NotNull ConfigurationSection conf); static String saveToString(@NotNull ConfigurationSection conf); @NotNull static YamlConfiguration loadFromString(@NotNull String yaml); @Nullable static YamlConfiguration loadFromStringOrNull(@NotNull String yaml); static Set<String> flatKeys(@NotNull ConfigurationSection conf); @Nullable static T get(@NotNull ConfigurationSection conf, @NotNull String path); @Nullable @Contract("_,_,!null->!null") static T get(@NotNull ConfigurationSection conf, @NotNull String path, @Nullable T fallback); @NotNull static ConfigurationSection diff(@NotNull ConfigurationSection confA, @NotNull ConfigurationSection confB); static Logger logger; }### Answer:
@Test(expected = FileNotFoundException.class) public void saveDefaultResourcesNotExistingWhenNotCreating() throws IOException { ConfigUtil.saveDefaultResources(plugin, false, NON_EXISTING_TEST_FILE_WITH_DIR_PATH); }
@Test public void saveDefaultResourcesDoesNotOverwrite() throws IOException { String content = "yaegstfiuaeifyefgsaiefgipsaefåøæ"; FileUtils.write(content, plugin, TEST_FILE_WITH_DIR_PATH); ConfigUtil.saveDefaultResources(plugin, TEST_FILE_WITH_DIR_PATH); assertEquals(content, FileUtils.read(plugin, TEST_FILE_WITH_DIR_PATH)); }
@Test public void saveDefaultResourcesSavesMultipleFiles() throws IOException { String[] filesPaths = {TEST_FILE_WITH_DIR_PATH, TEST_FILE_WITHOUT_DIR_PATH, NON_EXISTING_TEST_FILE_WITH_DIR_PATH}; List<File> expectedFiles = new ArrayList<>(); for (String path : filesPaths) { expectedFiles.add(FileUtils.getDatafolderFile(plugin, path.split("[/\\\\]"))); } ConfigUtil.saveDefaultResources(plugin, filesPaths); List<File> savedFiles = FileUtils.getRecursiveFiles(false, plugin); Collections.sort(expectedFiles); Collections.sort(savedFiles); assertEquals(expectedFiles, savedFiles); for (File file : savedFiles) { assertTrue("File " + file + " does not exist", file.exists()); } }