/*
 * TuneJar <http://sudicode.com/tunejar/>
 * Copyright (C) 2016 Jonathan Sudiaman
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package com.sudicode.tunejar.config;

import org.apache.commons.io.FilenameUtils;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;

public class TestDefaults {

    public static final Path RESOURCES;

    /**
     * Maps sample music files to the URLs where they can be downloaded if
     * missing.
     */
    public static final Map<File, URL> SAMPLE_MUSIC_MAP;

    static {
        RESOURCES = Paths.get("src", "test", "resources");
        SAMPLE_MUSIC_MAP = getSampleMusicMap();
    }

    private TestDefaults() {}

    private static Map<File, URL> getSampleMusicMap() {
        Map<File, URL> sampleMusicMap = new HashMap<>();
        Consumer<String> sampleMusicRegistrar = (file) -> {
            try {
                String fileType = FilenameUtils.getExtension(file);
                if (fileType.equals("m4a")) {
                    fileType = "mp4";
                }
                URL url = new URL("http://sudicode.com/tunejar/Sample-Music/" + fileType + "/" + file);
                sampleMusicMap.put(RESOURCES.resolve(fileType).resolve(file).toFile(), url);
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            }
        };
        String[] sampleMusicFiles = new String[] { "AfterDark.mp3", "CrunkKnight.m4a", "Cute.wav" };
        for (String file : sampleMusicFiles) {
            sampleMusicRegistrar.accept(file);
        }
        return Collections.unmodifiableMap(sampleMusicMap);
    }

}

@@ -1030,44 +1030,8 @@
 Map;
-%0Aimport java.util.function.Consumer;
 %0A%0Apu
@@ -1546,24 +1546,16 @@
     
-Consumer%3C
 String
-%3E
+%5B%5D
  sam
@@ -1566,29 +1566,125 @@
 usic
-Registrar = (file) -%3E
+Files = new String%5B%5D %7B %22AfterDark.mp3%22, %22CrunkKnight.m4a%22, %22Cute.wav%22 %7D;%0A        for (String file : sampleMusicFiles)
  %7B%0A 
@@ -2158,24 +2158,24 @@
 ception(e);%0A
+
             
@@ -2180,214 +2180,8 @@
   %7D%0A
-        %7D;%0A        String%5B%5D sampleMusicFiles = new String%5B%5D %7B %22AfterDark.mp3%22, %22CrunkKnight.m4a%22, %22Cute.wav%22 %7D;%0A        for (String file : sampleMusicFiles) %7B%0A            sampleMusicRegistrar.accept(file);%0A
     

Update TestDefaults.java