Package org.mockserver.verify

Examples of org.mockserver.verify.Verification


    }

    @Test(expected = RuntimeException.class)
    public void serializeHandlesException() throws IOException {
        // given
        Verification verification = mock(Verification.class);
        when(objectMapper.writerWithDefaultPrettyPrinter()).thenReturn(objectWriter);
        when(objectWriter.writeValueAsString(any(VerificationDTO.class))).thenThrow(IOException.class);

        // when
        verificationSerializer.serialize(verification);
View Full Code Here


        logFilter.onResponse(httpRequest, httpResponseThree);

        // then
        assertThat(logFilter.verify(null), is(""));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(new HttpRequest())
                ),
                is("expected:<{ }> but was:<[ {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_path\"" + System.getProperty("line.separator") +
                        "}, {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_other_path\"" + System.getProperty("line.separator") +
                        "} ]>"));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(
                                        new HttpRequest()
                                                .withPath("some_path")
                                )
                ),
                is(""));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(
                                        new HttpRequest()
                                                .withPath("some_other_path")
                                )
                ),
View Full Code Here

        logFilter.onResponse(httpRequest, httpResponseThree);

        // then
        assertThat(logFilter.verify(null), is(""));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(new HttpRequest())
                                .withTimes(atLeast(0))
                ),
                is(""));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(new HttpRequest())
                                .withTimes(atLeast(3))
                ),
                is("expected:<{ }> but was:<[ {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_path\"" + System.getProperty("line.separator") +
                        "}, {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_other_path\"" + System.getProperty("line.separator") +
                        "} ]>"));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(
                                        new HttpRequest()
                                                .withPath("some_path")
                                )
                                .withTimes(atLeast(1))
                ),
                is(""));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(
                                        new HttpRequest()
                                                .withPath("some_path")
                                )
                                .withTimes(atLeast(2))
                ),
                is("expected:<{" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_path\"" + System.getProperty("line.separator") +
                        "}> but was:<[ {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_path\"" + System.getProperty("line.separator") +
                        "}, {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_other_path\"" + System.getProperty("line.separator") +
                        "} ]>"));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(
                                        new HttpRequest()
                                                .withPath("some_other_path")
                                )
                                .withTimes(atLeast(1))
View Full Code Here

        logFilter.onResponse(httpRequest, httpResponseThree);

        // then
        assertThat(logFilter.verify(null), is(""));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(new HttpRequest())
                                .withTimes(exactly(0))
                ),
                is("expected:<{ }> but was:<[ {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_path\"" + System.getProperty("line.separator") +
                        "}, {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_other_path\"" + System.getProperty("line.separator") +
                        "} ]>"));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(
                                        new HttpRequest()
                                                .withPath("some_path")
                                )
                                .withTimes(exactly(1))
                ),
                is(""));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(
                                        new HttpRequest()
                                                .withPath("some_path")
                                )
                                .withTimes(exactly(2))
                ),
                is("expected:<{" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_path\"" + System.getProperty("line.separator") +
                        "}> but was:<[ {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_path\"" + System.getProperty("line.separator") +
                        "}, {" + System.getProperty("line.separator") +
                        "  \"path\" : \"some_other_path\"" + System.getProperty("line.separator") +
                        "} ]>"));
        assertThat(logFilter.verify(
                        new Verification()
                                .withRequest(
                                        new HttpRequest()
                                                .withPath("some_other_path")
                                )
                                .withTimes(exactly(1))
View Full Code Here

            throw new RuntimeException(String.format("Exception while serializing verification to JSON with value %s", verification), ioe);
        }
    }

    public Verification deserialize(String jsonVerification) {
        Verification verification = null;
        if (jsonVerification != null && !jsonVerification.isEmpty()) {
            try {
                VerificationDTO verificationDTO = objectMapper.readValue(jsonVerification, VerificationDTO.class);
                if (verificationDTO != null) {
                    verification = verificationDTO.buildObject();
View Full Code Here

    public VerificationDTO() {
    }

    public Verification buildObject() {
        return new Verification()
                .withRequest((httpRequest != null ? httpRequest.buildObject() : request()))
                .withTimes((times != null ? times.buildObject() : once()));
    }
View Full Code Here

TOP

Related Classes of org.mockserver.verify.Verification

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.