Package org.mockserver.model

Examples of org.mockserver.model.Parameter


        bookPage.containsBook(bookServer.getBooksDB().get("1"));
        proxy.verify(
                request()
                        .withPath("/get_book")
                        .withQueryStringParameter(
                                new Parameter("id", "1")
                        ),
                Times.exactly(1)
        );
    }
View Full Code Here


        mockServer
                .when(
                        request()
                                .withPath("/get_book")
                                .withQueryStringParameter(
                                        new Parameter("id", "1")
                                )
                )
                .respond(
                        response()
                                .withHeaders(
                                        new Header("Content-Type", "application/json")
                                )
                                .withBody("" +
                                        "{" + System.getProperty("line.separator") +
                                        "    \"id\": \"1\"," + System.getProperty("line.separator") +
                                        "    \"title\": \"Xenophon's imperial fiction : on the education of Cyrus\"," + System.getProperty("line.separator") +
                                        "    \"author\": \"James Tatum\"," + System.getProperty("line.separator") +
                                        "    \"isbn\": \"0691067570\"," + System.getProperty("line.separator") +
                                        "    \"publicationDate\": \"1989\"" + System.getProperty("line.separator") +
                                        "}")
                );

        MvcResult response = mockMvc.perform(get("/book/1").accept(MediaType.TEXT_HTML))
                .andExpect(status().isOk())
                .andExpect(content().contentType("text/html;charset=UTF-8"))
                .andReturn();

        BookPage bookPage = new BookPage(response);
        bookPage.containsBook(new Book(1, "Xenophon's imperial fiction : on the education of Cyrus", "James Tatum", "0691067570", "1989"));
        proxy.verify(
                request()
                        .withPath("/get_book")
                        .withQueryStringParameter(
                                new Parameter("id", "1")
                        ),
                Times.exactly(1)
        );
    }
View Full Code Here

public class ParameterDTOTest {

    @Test
    public void shouldReturnValueSetInConstructor() {
        // when
        ParameterDTO parameter = new ParameterDTO(new Parameter("first", "first_one", "first_two"));

        // then
        assertThat(parameter.getValues(), containsInAnyOrder("first_one", "first_two"));
        assertThat(parameter.buildObject().getValues(), containsInAnyOrder("first_one", "first_two"));
    }
View Full Code Here

        BodyDTO body = BodyDTO.createDTO(exact("body"));
        List<CookieDTO> cookies = Arrays.asList(new CookieDTO(new Cookie("name", "value")));
        List<HeaderDTO> headers = Arrays.asList(new HeaderDTO(new Header("name", "value")));
        String method = "METHOD";
        String path = "path";
        List<ParameterDTO> queryStringParameters = Arrays.asList(new ParameterDTO(new Parameter("name", "value")));
        String url = "url";
        HttpRequest httpRequest = new HttpRequest()
                .withBody("body")
                .withCookies(new Cookie("name", "value"))
                .withHeaders(new Header("name", "value"))
                .withMethod(method)
                .withPath(path)
                .withQueryStringParameter(new Parameter("name", "value"))
                .withURL(url);

        // when
        HttpRequestDTO httpRequestDTO = new HttpRequestDTO(httpRequest);
View Full Code Here

        String body = "body";
        Cookie cookie = new Cookie("name", "value");
        Header header = new Header("name", "value");
        String method = "METHOD";
        String path = "path";
        Parameter parameter = new Parameter("name", "value");
        String url = "url";
        HttpRequest httpRequest = new HttpRequest()
                .withBody(body)
                .withCookies(cookie)
                .withHeaders(header)
View Full Code Here

    @Test
    public void shouldReturnValueSetInConstructor() {
        // when
        ParameterBodyDTO parameterBody = new ParameterBodyDTO(new ParameterBody(
                new Parameter("some", "value")
        ));

        // then
        assertThat(parameterBody.getParameters(), containsInAnyOrder(new ParameterDTO(new Parameter("some", "value"))));
        assertThat(parameterBody.getType(), is(Body.Type.PARAMETERS));
    }
View Full Code Here

    @Test
    public void shouldBuildCorrectObject() {
        // when
        ParameterBody parameterBody = new ParameterBodyDTO(new ParameterBody(
                new Parameter("some", "value")
        )).buildObject();

        // then
        assertThat(parameterBody.getValue(), containsInAnyOrder(new Parameter("some", "value")));
        assertThat(parameterBody.getType(), is(Body.Type.PARAMETERS));
    }
View Full Code Here

    }

    @Test
    public void shouldReturnCorrectObjectFromStaticBuilder() {
        assertThat(params(
                        new Parameter("some", "value")
                ),
                is(
                        new ParameterBody(
                                new Parameter("some", "value")
                        )
                )
        );
        assertThat(params(Arrays.asList(
                        new Parameter("some", "value")
                )),
                is(
                        new ParameterBody(
                                new Parameter("some", "value")
                        )
                )
        );
    }
View Full Code Here

public class ParameterStringMatcherTest {

    @Test
    public void shouldMatchMatchingString() {
        assertTrue(new ParameterStringMatcher(Arrays.asList(
                new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
                new Parameter("parameterTwoName", "parameterTwoValue")
        )).matches("" +
                "parameterOneName=parameterOneValueOne" +
                "&parameterOneName=parameterOneValueTwo" +
                "&parameterTwoName=parameterTwoValue"));
    }
View Full Code Here

    }

    @Test
    public void shouldNotMatchIncorrectParameterName() {
        assertFalse(new ParameterStringMatcher(Arrays.asList(
                new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
                new Parameter("parameterTwoName", "parameterTwoValue")
        )).matches("" +
                "parameterOneName=parameterOneValueOne" +
                "&INCORRECTParameterOneName=parameterOneValueTwo" +
                "&parameterTwoName=parameterTwoValue"));
    }
View Full Code Here

TOP

Related Classes of org.mockserver.model.Parameter

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.