package org.mockserver.serialization.deserializers.request;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.junit.Test;
import org.mockserver.file.FilePath;
import org.mockserver.file.FileReader;
import org.mockserver.model.*;
import org.mockserver.serialization.ObjectMapperFactory;
import org.mockserver.serialization.model.*;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;

import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockserver.character.Character.NEW_LINE;
import static org.mockserver.file.FileReader.openStreamToFileFromClassPathOrPath;
import static org.mockserver.model.BinaryBody.binary;
import static org.mockserver.model.Cookie.cookie;
import static org.mockserver.model.Header.header;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.JsonBody.json;
import static org.mockserver.model.JsonPathBody.jsonPath;
import static org.mockserver.model.JsonSchemaBody.jsonSchema;
import static org.mockserver.model.NottableString.string;
import static org.mockserver.model.OpenAPIDefinition.openAPI;
import static org.mockserver.model.Parameter.param;
import static org.mockserver.model.ParameterBody.params;
import static org.mockserver.model.RegexBody.regex;
import static org.mockserver.model.StringBody.exact;
import static org.mockserver.model.XPathBody.xpath;
import static org.mockserver.model.XmlBody.xml;
import static org.mockserver.model.XmlSchemaBody.xmlSchema;

public class RequestDefinitionDTODeserializerTest {

    @Test
    public void shouldParseJsonWithNoFieldsSetAndDefaultToHttpRequest() throws JsonProcessingException {
        assertThat(ObjectMapperFactory.createObjectMapper().readValue("{ }", RequestDefinitionDTO.class), is(new HttpRequestDTO(request())));
    }

    @Test
    public void shouldParseJsonWithOpenAPIClasspathLocationAndOperationId() throws JsonProcessingException {
        assertThat(ObjectMapperFactory.createObjectMapper().readValue("" +
            "{" + NEW_LINE +
            "  \"specUrlOrPayload\" : \"org/mockserver/openapi/openapi_simple_example.json\"," + NEW_LINE +
            "  \"operationId\" : \"listPets\"" + NEW_LINE +
            "}", RequestDefinitionDTO.class), is(
            new OpenAPIDefinitionDTO(openAPI()
                .withSpecUrlOrPayload("org/mockserver/openapi/openapi_simple_example.json")
                .withOperationId("listPets")
            )));
    }

    @Test
    public void shouldParseJsonWithOpenAPIClasspathLocation() throws JsonProcessingException {
        assertThat(ObjectMapperFactory.createObjectMapper().readValue("" +
            "{" + NEW_LINE +
            "  \"specUrlOrPayload\" : \"org/mockserver/openapi/openapi_simple_example.json\"" + NEW_LINE +
            "}", RequestDefinitionDTO.class), is(
            new OpenAPIDefinitionDTO(openAPI()
                .withSpecUrlOrPayload("org/mockserver/openapi/openapi_simple_example.json")
            )));
    }

    @Test
    public void shouldParseJsonWithOpenAPIUrlAndOperationId() throws JsonProcessingException {
        assertThat(ObjectMapperFactory.createObjectMapper().readValue("" +
            "{" + NEW_LINE +
            "  \"specUrlOrPayload\" : \"" + FilePath.getURL("org/mockserver/openapi/openapi_simple_example.json").toString() + "\"," + NEW_LINE +
            "  \"operationId\" : \"listPets\"" + NEW_LINE +
            "}", RequestDefinitionDTO.class), is(
            new OpenAPIDefinitionDTO(openAPI()
                .withSpecUrlOrPayload(FilePath.getURL("org/mockserver/openapi/openapi_simple_example.json").toString())
                .withOperationId("listPets")
            )));
    }

    @Test
    public void shouldParseJsonWithOpenAPIUrl() throws JsonProcessingException {
        assertThat(ObjectMapperFactory.createObjectMapper().readValue("" +
            "{" + NEW_LINE +
            "  \"specUrlOrPayload\" : \"" + FilePath.getURL("org/mockserver/openapi/openapi_simple_example.json").toString() + "\"" + NEW_LINE +
            "}", RequestDefinitionDTO.class), is(
            new OpenAPIDefinitionDTO(openAPI()
                .withSpecUrlOrPayload(FilePath.getURL("org/mockserver/openapi/openapi_simple_example.json").toString())
            )));
    }

    @Test
    public void shouldParseJsonWithOpenAPIAndContextPathPrefix() throws JsonProcessingException {
        assertThat(ObjectMapperFactory.createObjectMapper().readValue("" +
            "{" + NEW_LINE +
            "  \"specUrlOrPayload\" : \"org/mockserver/openapi/openapi_simple_example.json\"," + NEW_LINE +
            "  \"operationId\" : \"listPets\"," + NEW_LINE +
            "  \"contextPathPrefix\" : \"/api/v1\"" + NEW_LINE +
            "}", RequestDefinitionDTO.class), is(
            new OpenAPIDefinitionDTO(openAPI()
                .withSpecUrlOrPayload("org/mockserver/openapi/openapi_simple_example.json")
                .withOperationId("listPets")
                .withContextPathPrefix("/api/v1")
            )));
    }

    @Test
    public void shouldParseJsonWithOpenAPISpecAndOperationId() throws JsonProcessingException {
        assertThat(ObjectMapperFactory.createObjectMapper().readValue("" +
            "{" + NEW_LINE +
            "  \"specUrlOrPayload\" : " + ObjectMapperFactory.createObjectMapper().readTree(FileReader.readFileFromClassPathOrPath("org/mockserver/openapi/openapi_simple_example.json")).toPrettyString().replaceAll("\\R", "\n  ") + "," + NEW_LINE +
            "  \"operationId\" : \"listPets\"" + NEW_LINE +
            "}", RequestDefinitionDTO.class), is(
            new OpenAPIDefinitionDTO(openAPI()
                .withSpecUrlOrPayload(ObjectMapperFactory.createObjectMapper().readTree(FileReader.readFileFromClassPathOrPath("org/mockserver/openapi/openapi_simple_example.json")).toPrettyString())
                .withOperationId("listPets")
            )));
    }

    @Test
    public void shouldParseJsonWithOpenAPISpec() throws JsonProcessingException {
        assertThat(ObjectMapperFactory.createObjectMapper().readValue("" +
            "{" + NEW_LINE +
            "  \"specUrlOrPayload\" : " + ObjectMapperFactory.createObjectMapper().readTree(FileReader.readFileFromClassPathOrPath("org/mockserver/openapi/openapi_simple_example.json")).toPrettyString().replaceAll("\\R", "\n  ") + NEW_LINE +
            "}", RequestDefinitionDTO.class), is(
            new OpenAPIDefinitionDTO(openAPI()
                .withSpecUrlOrPayload(ObjectMapperFactory.createObjectMapper().readTree(FileReader.readFileFromClassPathOrPath("org/mockserver/openapi/openapi_simple_example.json")).toPrettyString())
            )));
    }

    @Test
    public void shouldDeserializeCompleteObject() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"method\" : \"someMethod\"," + NEW_LINE +
            "  \"path\" : \"somePath\"," + NEW_LINE +
            "  \"pathParameters\" : [ {" + NEW_LINE +
            "    \"name\" : \"path_queryParameterName\"," + NEW_LINE +
            "    \"values\" : [ \"path_queryParameterValue\" ]" + NEW_LINE +
            "  } ]," + NEW_LINE +
            "  \"queryStringParameters\" : [ {" + NEW_LINE +
            "    \"name\" : \"queryParameterName\"," + NEW_LINE +
            "    \"values\" : [ \"queryParameterValue\" ]" + NEW_LINE +
            "  } ]," + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"STRING\"," + NEW_LINE +
            "    \"string\" : \"someBody\"" + NEW_LINE +
            "  }," + NEW_LINE +
            "  \"cookies\" : [ {" + NEW_LINE +
            "    \"name\" : \"someCookieName\"," + NEW_LINE +
            "    \"value\" : \"someCookieValue\"" + NEW_LINE +
            "  } ]," + NEW_LINE +
            "  \"headers\" : [ {" + NEW_LINE +
            "    \"name\" : \"someHeaderName\"," + NEW_LINE +
            "    \"values\" : [ \"someHeaderValue\" ]" + NEW_LINE +
            "  } ]," + NEW_LINE +
            "  \"secure\" : true," + NEW_LINE +
            "  \"keepAlive\" : false," + NEW_LINE +
            "  \"protocol\" : \"HTTP_2\"," + NEW_LINE +
            "  \"socketAddress\" : {" + NEW_LINE +
            "    \"host\" : \"someHost\"," + NEW_LINE +
            "    \"port\" : 1234," + NEW_LINE +
            "    \"scheme\" : \"HTTPS\"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setMethod(string("someMethod"))
                .setPath(string("somePath"))
                .setPathParameters(new Parameters().withEntries(
                    param("path_queryParameterName", "path_queryParameterValue")
                ))
                .setQueryStringParameters(new Parameters().withEntries(
                    param("queryParameterName", "queryParameterValue")
                ))
                .setBody(new StringBodyDTO(exact("someBody")))
                .setHeaders(new Headers().withEntries(
                    header("someHeaderName", "someHeaderValue")
                ))
                .setCookies(new Cookies().withEntries(
                    cookie("someCookieName", "someCookieValue")
                ))
                .setSecure(true)
                .setKeepAlive(false)
                .setProtocol(Protocol.HTTP_2)
                .setSocketAddress(new SocketAddress()
                    .withHost("someHost")
                    .withPort(1234)
                    .withScheme(SocketAddress.Scheme.HTTPS)
                ),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeStringBodyShorthand() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : \"somebody\"" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(exact("somebody"))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeStringBodyWithType() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"STRING\"," + NEW_LINE +
            "    \"string\" : \"somebody\"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(exact("somebody"))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeRegexBody() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"REGEX\"," + NEW_LINE +
            "    \"regex\" : \"some[a-z]{3}\"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(regex("some[a-z]{3}"))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeJsonBody() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"JSON\"," + NEW_LINE +
            "    \"json\" : \"{ \\\"key\\\": \\\"value\\\" }\"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(json("{ \"key\": \"value\" }"))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeJsonSchemaBody() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"JSON_SCHEMA\"," + NEW_LINE +
            "    \"jsonSchema\" : \"{ \\\"key\\\": \\\"value\\\" }\"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(jsonSchema("{ \"key\": \"value\" }"))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeJsonPathBody() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"JSON_PATH\"," + NEW_LINE +
            "    \"jsonPath\" : \"$..book[?(@.price <= $['expensive'])]\"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(jsonPath("$..book[?(@.price <= $['expensive'])]"))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeXmlBody() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"XML\"," + NEW_LINE +
            "    \"xml\" : \"<some><xml></xml></some>\"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(xml("<some><xml></xml></some>"))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeXmlSchemaBody() throws JsonProcessingException {
        // given
        String xmlSchema = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\">" +
            "    <!-- XML Schema Generated from XML Document on Wed Jun 28 2017 21:52:45 GMT+0100 (BST) -->" +
            "    <!-- with XmlGrid.net Free Online Service http://xmlgrid.net -->" +
            "    <xs:element name=\"notes\">" +
            "        <xs:complexType>" +
            "            <xs:sequence>" +
            "                <xs:element name=\"note\" maxOccurs=\"unbounded\">" +
            "                    <xs:complexType>" +
            "                        <xs:sequence>" +
            "                            <xs:element name=\"to\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>" +
            "                            <xs:element name=\"from\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>" +
            "                            <xs:element name=\"heading\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>" +
            "                            <xs:element name=\"body\" minOccurs=\"1\" maxOccurs=\"1\" type=\"xs:string\"></xs:element>" +
            "                        </xs:sequence>" +
            "                    </xs:complexType>" +
            "                </xs:element>" +
            "            </xs:sequence>" +
            "        </xs:complexType>" +
            "    </xs:element>" +
            "</xs:schema>";
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"XML_SCHEMA\"," + NEW_LINE +
            "    \"xmlSchema\" : \"" + StringEscapeUtils.escapeJava(xmlSchema) + "\"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";


        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(xmlSchema(xmlSchema))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeXpathBody() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"XPATH\"," + NEW_LINE +
            "    \"xpath\" : \"/element[key = 'some_key' and value = 'some_value']\"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(xpath("/element[key = 'some_key' and value = 'some_value']"))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeParameterBody() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"PARAMETERS\"," + NEW_LINE +
            "    \"parameters\" : [ {" + NEW_LINE +
            "      \"name\" : \"nameOne\"," + NEW_LINE +
            "      \"values\" : [ \"valueOne\" ]" + NEW_LINE +
            "    }, {" + NEW_LINE +
            "      \"name\" : \"nameTwo\"," + NEW_LINE +
            "      \"values\" : [ \"valueTwo_One\", \"valueTwo_Two\" ]" + NEW_LINE +
            "    } ]" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyDTO.createDTO(params(
                    new Parameter("nameOne", "valueOne"),
                    new Parameter("nameTwo", "valueTwo_One", "valueTwo_Two")
                ))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeBinaryBody() throws IOException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "  \"body\" : {" + NEW_LINE +
            "    \"type\" : \"BINARY\"," + NEW_LINE +
            "    \"base64Bytes\" : \" \"" + NEW_LINE +
            "  }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setBody(BodyWithContentTypeDTO.createWithContentTypeDTO(binary(IOUtils.toByteArray(openStreamToFileFromClassPathOrPath("org/mockserver/serialization/forkme_right_red.png"))))),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializePartialObject() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "    \"path\": \"somePath\"" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setPath(string("somePath")),
            requestDefinitionDTO);
    }

    @Test
    public void shouldDeserializeClientCertificateChain() throws JsonProcessingException {
        String requestBytes = "{" + NEW_LINE +
            "  \"path\" : \"somePath\"," + NEW_LINE +
            "  \"clientCertificateChain\" : [ {" + NEW_LINE +
            "    \"issuerDistinguishedName\" : \"CN=Test CA\"," + NEW_LINE +
            "    \"subjectDistinguishedName\" : \"CN=Test Client\"," + NEW_LINE +
            "    \"serialNumber\" : \"12345\"," + NEW_LINE +
            "    \"signatureAlgorithmName\" : \"SHA256WithRSA\"" + NEW_LINE +
            "  } ]," + NEW_LINE +
            "  \"localAddress\" : \"127.0.0.1:1080\"," + NEW_LINE +
            "  \"remoteAddress\" : \"192.168.1.1:54321\"" + NEW_LINE +
            "}";

        HttpRequestDTO requestDefinitionDTO = (HttpRequestDTO) ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        assertNotNull(requestDefinitionDTO.getClientCertificateChain());
        assertEquals(1, requestDefinitionDTO.getClientCertificateChain().size());
        assertEquals("CN=Test CA", requestDefinitionDTO.getClientCertificateChain().get(0).getIssuerDistinguishedName());
        assertEquals("CN=Test Client", requestDefinitionDTO.getClientCertificateChain().get(0).getSubjectDistinguishedName());
        assertEquals("12345", requestDefinitionDTO.getClientCertificateChain().get(0).getSerialNumber());
        assertEquals("SHA256WithRSA", requestDefinitionDTO.getClientCertificateChain().get(0).getSignatureAlgorithmName());
        assertEquals("127.0.0.1:1080", requestDefinitionDTO.getLocalAddress());
        assertEquals("192.168.1.1:54321", requestDefinitionDTO.getRemoteAddress());
    }

    @Test
    public void shouldDeserializeNullClientCertificateChain() throws JsonProcessingException {
        String requestBytes = "{" + NEW_LINE +
            "  \"path\" : \"somePath\"," + NEW_LINE +
            "  \"clientCertificateChain\" : null" + NEW_LINE +
            "}";

        HttpRequestDTO requestDefinitionDTO = (HttpRequestDTO) ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        assertNull(requestDefinitionDTO.getClientCertificateChain());
    }

    @Test
    public void shouldDeserializeAsHttpRequestField() throws JsonProcessingException {
        // given
        String requestBytes = "{" + NEW_LINE +
            "    \"httpRequest\": {" + NEW_LINE +
            "        \"path\": \"somePath\"," + NEW_LINE +
            "        \"queryStringParameters\" : [ {" + NEW_LINE +
            "            \"name\" : \"queryParameterName\"," + NEW_LINE +
            "            \"values\" : [ \"queryParameterValue\" ]" + NEW_LINE +
            "        } ]" + NEW_LINE +
            "    }" + NEW_LINE +
            "}";

        // when
        RequestDefinitionDTO requestDefinitionDTO = ObjectMapperFactory.createObjectMapper().readValue(requestBytes, RequestDefinitionDTO.class);

        // then
        assertEquals(new HttpRequestDTO()
                .setPath(string("somePath"))
                .setQueryStringParameters(new Parameters().withEntries(
                    param("queryParameterName", "queryParameterValue")
                )),
            requestDefinitionDTO);
    }

}