Package org.mockserver.client.serialization.model

Examples of org.mockserver.client.serialization.model.HttpRequestDTO


        // when
        Verification expectation = new VerificationSerializer().deserialize(requestBytes);

        // then
        assertEquals(new VerificationDTO()
                .setHttpRequest(new HttpRequestDTO(request().withPath("somepath")))
                .buildObject(), expectation);
    }
View Full Code Here


        // when
        Verification expectation = new VerificationSerializer().deserialize(requestBytes);

        // then
        assertEquals(new VerificationDTO()
                .setHttpRequest(new HttpRequestDTO(request().withMethod("GET").withPath("somepath")))
                .setTimes(new VerificationTimesDTO(VerificationTimes.exactly(2)))
                .buildObject(), expectation);
    }
View Full Code Here

        // when
        Verification expectation = new VerificationSerializer().deserialize(requestBytes);

        // then
        assertEquals(new VerificationDTO()
                .setHttpRequest(new HttpRequestDTO(request()))
                .buildObject(), expectation);
    }
View Full Code Here

    @Test
    public void shouldSerializeCompleteObject() throws IOException {
        // when
        String jsonExpectation = new VerificationSerializer().serialize(
                new VerificationDTO()
                        .setHttpRequest(new HttpRequestDTO(request().withMethod("GET").withPath("somepath")))
                        .setTimes(new VerificationTimesDTO(VerificationTimes.exactly(2)))
                        .buildObject()
        );

        // then
View Full Code Here

    @Test
    public void shouldSerializePartialObject() throws IOException {
        // when
        String jsonExpectation = new VerificationSerializer().serialize(
                new VerificationDTO()
                        .setHttpRequest(new HttpRequestDTO(request()))
                        .buildObject()
        );

        // then
        assertEquals("{" + System.getProperty("line.separator") +
View Full Code Here

    public String serialize(HttpRequest httpRequest) {
        try {
            return objectMapper
                    .writerWithDefaultPrettyPrinter()
                    .writeValueAsString(new HttpRequestDTO(httpRequest));
        } catch (IOException ioe) {
            logger.error(String.format("Exception while serializing httpRequest to JSON with value %s", httpRequest), ioe);
            throw new RuntimeException(String.format("Exception while serializing httpRequest to JSON with value %s", httpRequest), ioe);
        }
    }
View Full Code Here

    public HttpRequest deserialize(String jsonHttpRequest) {
        HttpRequest httpRequest = null;
        if (jsonHttpRequest != null && !jsonHttpRequest.isEmpty()) {
            try {
                if (!jsonHttpRequest.contains("\"httpRequest\"")) {
                    HttpRequestDTO httpRequestDTO = objectMapper.readValue(jsonHttpRequest, HttpRequestDTO.class);
                    if (httpRequestDTO != null) {
                        httpRequest = httpRequestDTO.buildObject();
                    }
                } else {
                    ExpectationDTO expectationDTO = objectMapper.readValue(jsonHttpRequest, ExpectationDTO.class);
                    if (expectationDTO != null) {
                        httpRequest = expectationDTO.buildObject().getHttpRequest();
View Full Code Here

    public String serialize(HttpRequest[] httpRequest) {
        try {
            if (httpRequest != null && httpRequest.length > 0) {
                HttpRequestDTO[] httpRequestDTOs = new HttpRequestDTO[httpRequest.length];
                for (int i = 0; i < httpRequest.length; i++) {
                    httpRequestDTOs[i] = new HttpRequestDTO(httpRequest[i]);
                }
                return objectMapper
                        .writerWithDefaultPrettyPrinter()
                        .writeValueAsString(httpRequestDTOs);
            }
View Full Code Here

TOP

Related Classes of org.mockserver.client.serialization.model.HttpRequestDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.