// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java
// public class NoValidActionException extends RamlMockServerException {
//     private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification.";
// 
//     public NoValidActionException(ApiExpectation expectation) {
//         super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri()));
//     }
// }
// 
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java
// public class NoValidResourceException extends RamlMockServerException {
//     private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification.";
// 
//     public NoValidResourceException(ApiExpectation expectation) {
//         super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri()));
//     }
// }
// 
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java
// public class DefaultBodySpecification implements BodySpecification {
//     private final MediaType mediaType;
// 
//     public DefaultBodySpecification(MediaType mediaType) {
//         this.mediaType = mediaType;
//     }
// 
//     @Override
//     public ValidationErrors validate(String body) {
//         return new ValidationErrors();
//     }
// 
//     @Override
//     public MediaType getContentType() {
//         return mediaType;
//     }
// }
// 
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java
// public class JsonBodySpecification implements BodySpecification {
//     private final String bodyType;
//     private final MimeType mimeType;
// 
//     public JsonBodySpecification(String bodyType, MimeType mimeType) {
//         this.bodyType = bodyType;
//         this.mimeType = mimeType;
//     }
// 
//     @Override
//     public MediaType getContentType() {
//         return MediaType.APPLICATION_JSON_TYPE;
//     }
// 
//     @Override
//     public ValidationErrors validate(String body) {
//         if (mimeType.getSchema() == null)
//             return new ValidationErrors();
// 
//         return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body);
//     }
// }


import com.damnhandy.uri.template.Literal;
import com.damnhandy.uri.template.UriTemplateComponent;
import com.damnhandy.uri.template.impl.UriTemplateParser;
import net.ozwolf.mockserver.raml.exception.NoValidActionException;
import net.ozwolf.mockserver.raml.exception.NoValidResourceException;
import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification;
import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification;
import org.apache.commons.lang.StringUtils;
import org.mockserver.mock.Expectation;
import org.mockserver.model.Header;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
import org.mockserver.model.Parameter;
import org.raml.model.*;
import org.raml.model.parameter.UriParameter;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import java.util.*;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Maps.newHashMap;
                        .getValue()
        );
    }

    public MediaType getResponseContentType() {
        return MediaType.valueOf(
                getResponseHeader(HttpHeaders.CONTENT_TYPE)
                        .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD))
                        .getValues()
                        .get(0)
                        .getValue()
        );
    }

    public Optional<BodySpecification> getRequestBodySpecification() {
        Optional<MimeType> body = specification.getRequestBodyFor(this);
        if (!body.isPresent()) return Optional.empty();

        if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getRequestContentType()))
            return Optional.of(new JsonBodySpecification("request", body.get()));

        return Optional.of(new DefaultBodySpecification(this.getResponseContentType()));
    }

    public Optional<BodySpecification> getResponseBodySpecification() {
        Optional<MimeType> body = specification.getResponseBodyFor(this);
        if (!body.isPresent())
            return Optional.empty();

        if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getResponseContentType()))
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java
// public class NoValidActionException extends RamlMockServerException {
//     private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification.";
// 
//     public NoValidActionException(ApiExpectation expectation) {
//         super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri()));
//     }
// }
// 
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java
// public class NoValidResourceException extends RamlMockServerException {
//     private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification.";
// 
//     public NoValidResourceException(ApiExpectation expectation) {
//         super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri()));
//     }
// }
// 
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java
// public class DefaultBodySpecification implements BodySpecification {
//     private final MediaType mediaType;
// 
//     public DefaultBodySpecification(MediaType mediaType) {
//         this.mediaType = mediaType;
//     }
// 
//     @Override
//     public ValidationErrors validate(String body) {
//         return new ValidationErrors();
//     }
// 
//     @Override
//     public MediaType getContentType() {
//         return mediaType;
//     }
// }
// 
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java
// public class JsonBodySpecification implements BodySpecification {
//     private final String bodyType;
//     private final MimeType mimeType;
// 
//     public JsonBodySpecification(String bodyType, MimeType mimeType) {
//         this.bodyType = bodyType;
//         this.mimeType = mimeType;
//     }
// 
//     @Override
//     public MediaType getContentType() {
//         return MediaType.APPLICATION_JSON_TYPE;
//     }
// 
//     @Override
//     public ValidationErrors validate(String body) {
//         if (mimeType.getSchema() == null)
//             return new ValidationErrors();
// 
//         return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body);
//     }
// }


// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectation.java
import com.damnhandy.uri.template.Literal;
import com.damnhandy.uri.template.UriTemplateComponent;
import com.damnhandy.uri.template.impl.UriTemplateParser;
import net.ozwolf.mockserver.raml.exception.NoValidActionException;
import net.ozwolf.mockserver.raml.exception.NoValidResourceException;
import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification;
import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification;
import org.apache.commons.lang.StringUtils;
import org.mockserver.mock.Expectation;
import org.mockserver.model.Header;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
import org.mockserver.model.Parameter;
import org.raml.model.*;
import org.raml.model.parameter.UriParameter;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import java.util.*;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Maps.newHashMap;

                        .getValue()
        );
    }

    public MediaType getResponseContentType() {
        return MediaType.valueOf(
                getResponseHeader(HttpHeaders.CONTENT_TYPE)
                        .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD))
                        .getValues()
                        .get(0)
                        .getValue()
        );
    }

    public Optional<BodySpecification> getRequestBodySpecification() {
        Optional<MimeType> body = specification.getRequestBodyFor(this);
        if (!body.isPresent()) return Optional.empty();

        if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getRequestContentType()))
            return Optional.of(new JsonBodySpecification("request", body.get()));

        return Optional.of(new DefaultBodySpecification(this.getResponseContentType()));
    }

    public Optional<BodySpecification> getResponseBodySpecification() {
        Optional<MimeType> body = specification.getResponseBodyFor(this);
        if (!body.isPresent())
            return Optional.empty();

        if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getResponseContentType()))
            return Optional.of(new JsonBodySpecification("response", body.get()));