// Path: src/main/java/net/technolords/micro/model/ResponseContext.java
// public class ResponseContext {
//     public static final String JSON_CONTENT_TYPE = "application/json";
//     public static final String XML_CONTENT_TYPE = "application/xml";
//     public static final String PLAIN_TEXT_CONTENT_TYPE = "text/plain";
//     public static final String HTML_CONTENT_TYPE = "text/html";
//     public static final String DEFAULT_CONTENT_TYPE = JSON_CONTENT_TYPE;
//     private String response;
//     private String errorCode;
//     private String contentType = DEFAULT_CONTENT_TYPE;
// 
//     public String getResponse() {
//         return response;
//     }
// 
//     public void setResponse(String response) {
//         this.response = response;
//     }
// 
//     public String getErrorCode() {
//         return errorCode;
//     }
// 
//     public void setErrorCode(String errorCode) {
//         this.errorCode = errorCode;
//     }
// 
//     public String getContentType() {
//         return contentType;
//     }
// 
//     public void setContentType(String contentType) {
//         this.contentType = contentType;
//     }
// }
// 
// Path: src/main/java/net/technolords/micro/model/jaxb/resource/SimpleResource.java
// public class SimpleResource {
//     private String resource;
//     private String cachedData;
//     private int delay;
//     private String errorCode;
//     private int errorRate;
//     private String contentType;
// 
//     @XmlValue
//     public String getResource() {
//         return resource;
//     }
// 
//     public void setResource(String resource) {
//         this.resource = resource;
//     }
// 
//     @XmlTransient
//     public String getCachedData() {
//         return cachedData;
//     }
// 
//     public void setCachedData(String cachedData) {
//         this.cachedData = cachedData;
//     }
// 
//     @XmlAttribute(name = "delay")
//     public int getDelay() {
//         return delay;
//     }
// 
//     public void setDelay(int delay) {
//         this.delay = delay;
//     }
// 
//     @XmlAttribute(name = "error-code")
//     public String getErrorCode() {
//         return errorCode;
//     }
// 
//     public void setErrorCode(String errorCode) {
//         this.errorCode = errorCode;
//     }
// 
//     @XmlAttribute(name = "error-rate")
//     public int getErrorRate() {
//         return errorRate;
//     }
// 
//     public void setErrorRate(int errorRate) {
//         this.errorRate = errorRate;
//     }
// 
//     @XmlAttribute(name = "content-type")
//     public String getContentType() {
//         return contentType;
//     }
// 
//     public void setContentType(String contentType) {
//         this.contentType = contentType;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (obj == null) {
//             return false;
//         }
//         if (!(obj instanceof SimpleResource)) {
//             return false;
//         }
//         SimpleResource ref = (SimpleResource) obj;
//         return (Objects.equals(this.getContentType(), ref.getContentType())
//                 && Objects.equals(this.getErrorCode(), ref.getErrorCode())
//                 && Objects.equals(this.getResource(), ref.getResource())
//         );
//     }
// }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.technolords.micro.model.ResponseContext;
import net.technolords.micro.model.jaxb.resource.SimpleResource;
            } else {
                resource.setCachedData(this.readFromReferencedPath(resource.getResource()));
            }
        }
        // Apply content type
        responseContext.setResponse(resource.getCachedData());
        if (resource.getContentType() != null) {
            responseContext.setContentType(resource.getContentType());
        } else {
            responseContext.setContentType(this.fallbackLogicForContentType(resource));
        }
        // Apply custom error (only when applicable)
        if (resource.getErrorRate() > 0) {
            if (resource.getErrorRate() >= this.generateRandom()) {
                responseContext.setErrorCode(resource.getErrorCode());
            }
        }
        return responseContext;
    }

    /**
     * Auxiliary method to determine the content type (as fall back logic). In this case, the file extension is used.
     * When it .xml it will be 'application/xml' and otherwise 'application/json'.
     *
     * @param resource
     *  The resource associated with the fall back logic.
     *
     * @return
     *  The content type.
     */
// Path: src/main/java/net/technolords/micro/model/ResponseContext.java
// public class ResponseContext {
//     public static final String JSON_CONTENT_TYPE = "application/json";
//     public static final String XML_CONTENT_TYPE = "application/xml";
//     public static final String PLAIN_TEXT_CONTENT_TYPE = "text/plain";
//     public static final String HTML_CONTENT_TYPE = "text/html";
//     public static final String DEFAULT_CONTENT_TYPE = JSON_CONTENT_TYPE;
//     private String response;
//     private String errorCode;
//     private String contentType = DEFAULT_CONTENT_TYPE;
// 
//     public String getResponse() {
//         return response;
//     }
// 
//     public void setResponse(String response) {
//         this.response = response;
//     }
// 
//     public String getErrorCode() {
//         return errorCode;
//     }
// 
//     public void setErrorCode(String errorCode) {
//         this.errorCode = errorCode;
//     }
// 
//     public String getContentType() {
//         return contentType;
//     }
// 
//     public void setContentType(String contentType) {
//         this.contentType = contentType;
//     }
// }
// 
// Path: src/main/java/net/technolords/micro/model/jaxb/resource/SimpleResource.java
// public class SimpleResource {
//     private String resource;
//     private String cachedData;
//     private int delay;
//     private String errorCode;
//     private int errorRate;
//     private String contentType;
// 
//     @XmlValue
//     public String getResource() {
//         return resource;
//     }
// 
//     public void setResource(String resource) {
//         this.resource = resource;
//     }
// 
//     @XmlTransient
//     public String getCachedData() {
//         return cachedData;
//     }
// 
//     public void setCachedData(String cachedData) {
//         this.cachedData = cachedData;
//     }
// 
//     @XmlAttribute(name = "delay")
//     public int getDelay() {
//         return delay;
//     }
// 
//     public void setDelay(int delay) {
//         this.delay = delay;
//     }
// 
//     @XmlAttribute(name = "error-code")
//     public String getErrorCode() {
//         return errorCode;
//     }
// 
//     public void setErrorCode(String errorCode) {
//         this.errorCode = errorCode;
//     }
// 
//     @XmlAttribute(name = "error-rate")
//     public int getErrorRate() {
//         return errorRate;
//     }
// 
//     public void setErrorRate(int errorRate) {
//         this.errorRate = errorRate;
//     }
// 
//     @XmlAttribute(name = "content-type")
//     public String getContentType() {
//         return contentType;
//     }
// 
//     public void setContentType(String contentType) {
//         this.contentType = contentType;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (obj == null) {
//             return false;
//         }
//         if (!(obj instanceof SimpleResource)) {
//             return false;
//         }
//         SimpleResource ref = (SimpleResource) obj;
//         return (Objects.equals(this.getContentType(), ref.getContentType())
//                 && Objects.equals(this.getErrorCode(), ref.getErrorCode())
//                 && Objects.equals(this.getResource(), ref.getResource())
//         );
//     }
// }


// Path: src/main/java/net/technolords/micro/output/ResponseContextGenerator.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.technolords.micro.model.ResponseContext;
import net.technolords.micro.model.jaxb.resource.SimpleResource;

            } else {
                resource.setCachedData(this.readFromReferencedPath(resource.getResource()));
            }
        }
        // Apply content type
        responseContext.setResponse(resource.getCachedData());
        if (resource.getContentType() != null) {
            responseContext.setContentType(resource.getContentType());
        } else {
            responseContext.setContentType(this.fallbackLogicForContentType(resource));
        }
        // Apply custom error (only when applicable)
        if (resource.getErrorRate() > 0) {
            if (resource.getErrorRate() >= this.generateRandom()) {
                responseContext.setErrorCode(resource.getErrorCode());
            }
        }
        return responseContext;
    }

    /**
     * Auxiliary method to determine the content type (as fall back logic). In this case, the file extension is used.
     * When it .xml it will be 'application/xml' and otherwise 'application/json'.
     *
     * @param resource
     *  The resource associated with the fall back logic.
     *
     * @return
     *  The content type.
     */
    private String fallbackLogicForContentType(SimpleResource resource) {