// Path: src/main/java/com/lsoftware/playdoh/exception/FixtureNotFoundException.java
// public class FixtureNotFoundException extends PlaydohException {
// 
//     public FixtureNotFoundException(String fixtureName) {
//         super("Can't find " + fixtureName + " fixture on classpath");
//     }
// }
// 
// Path: src/main/java/com/lsoftware/playdoh/util/CaseUtils.java
// public class CaseUtils {
// 
//     public static String toSnakeCase(String s) {
//         return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, s);
//     }
// }
// 
// Path: src/main/java/com/lsoftware/playdoh/util/FileUtils.java
// public class FileUtils {
// 
//     public InputStream readFileFromClasspath(String filename) throws FileNotFoundException {
//         InputStream in = FileUtils.class.getClassLoader().getResourceAsStream(filename);
// 
//         if(in == null) {
//             throw new FileNotFoundException("Can't find file " + filename);
//         }
// 
//         return in;
//     }
// }


import com.lsoftware.playdoh.exception.FixtureNotFoundException;
import com.lsoftware.playdoh.util.CaseUtils;
import com.lsoftware.playdoh.util.FileUtils;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.ConstructorException;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
package com.lsoftware.playdoh.reader;



public class YamlModelReader implements ModelReader {

    private FileUtils fileUtils;

    private Yaml yaml;

    public YamlModelReader() {
        this.fileUtils = new FileUtils();
        this.yaml = new Yaml();
    }

    @Override
    public <T> Map<String, T> read(Class<T> type) {
        Map<String, T> objects = new HashMap<String, T>();
        try {
            InputStream inputStream = fileUtils.readFileFromClasspath(getYamlFilename(type));
            Map map = (Map) yaml.load(inputStream);

            if(map != null) {
                for (Object o : map.keySet()) {
                    String key = (String) o;
                    objects.put(key, yaml.loadAs(yaml.dump(map.get(key)), type));
                }
            }

            return objects;
        } catch (FileNotFoundException e) {
// Path: src/main/java/com/lsoftware/playdoh/exception/FixtureNotFoundException.java
// public class FixtureNotFoundException extends PlaydohException {
// 
//     public FixtureNotFoundException(String fixtureName) {
//         super("Can't find " + fixtureName + " fixture on classpath");
//     }
// }
// 
// Path: src/main/java/com/lsoftware/playdoh/util/CaseUtils.java
// public class CaseUtils {
// 
//     public static String toSnakeCase(String s) {
//         return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, s);
//     }
// }
// 
// Path: src/main/java/com/lsoftware/playdoh/util/FileUtils.java
// public class FileUtils {
// 
//     public InputStream readFileFromClasspath(String filename) throws FileNotFoundException {
//         InputStream in = FileUtils.class.getClassLoader().getResourceAsStream(filename);
// 
//         if(in == null) {
//             throw new FileNotFoundException("Can't find file " + filename);
//         }
// 
//         return in;
//     }
// }


// Path: src/main/java/com/lsoftware/playdoh/reader/YamlModelReader.java
import com.lsoftware.playdoh.exception.FixtureNotFoundException;
import com.lsoftware.playdoh.util.CaseUtils;
import com.lsoftware.playdoh.util.FileUtils;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.ConstructorException;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

package com.lsoftware.playdoh.reader;



public class YamlModelReader implements ModelReader {

    private FileUtils fileUtils;

    private Yaml yaml;

    public YamlModelReader() {
        this.fileUtils = new FileUtils();
        this.yaml = new Yaml();
    }

    @Override
    public <T> Map<String, T> read(Class<T> type) {
        Map<String, T> objects = new HashMap<String, T>();
        try {
            InputStream inputStream = fileUtils.readFileFromClasspath(getYamlFilename(type));
            Map map = (Map) yaml.load(inputStream);

            if(map != null) {
                for (Object o : map.keySet()) {
                    String key = (String) o;
                    objects.put(key, yaml.loadAs(yaml.dump(map.get(key)), type));
                }
            }

            return objects;
        } catch (FileNotFoundException e) {
            throw new FixtureNotFoundException(getYamlFilename(type));