Examples of Verification


Examples of org.mockserver.verify.Verification

    }

    @Test
    public void shouldHandleNullFieldInput() {
        // when
        VerificationDTO verificationDTO = new VerificationDTO(new Verification());

        // then
        assertThat(verificationDTO.getHttpRequest(), is(new HttpRequestDTO(request())));
        assertThat(verificationDTO.getTimes(), is(new VerificationTimesDTO(VerificationTimes.once())));
    }
View Full Code Here

Examples of org.mockserver.verify.Verification

                "    \"path\" : \"somepath\"" + System.getProperty("line.separator") +
                "  }" + System.getProperty("line.separator") +
                "}";

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

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

Examples of org.mockserver.verify.Verification

                "    \"exact\" : true" + System.getProperty("line.separator") +
                "  }" + System.getProperty("line.separator") +
                "}";

        // 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)))
View Full Code Here

Examples of org.mockserver.verify.Verification

        String requestBytes = "{" + System.getProperty("line.separator") +
                "    \"path\": \"somePath\"" + System.getProperty("line.separator") +
                "}";

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

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

Examples of org.mockserver.verify.Verification

    public void deserialize() throws IOException {
        // given
        when(objectMapper.readValue(eq("requestBytes"), same(VerificationDTO.class))).thenReturn(fullVerificationDTO);

        // when
        Verification verification = verificationSerializer.deserialize("requestBytes");

        // then
        assertEquals(fullVerification, verification);
    }
View Full Code Here

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

Examples of org.mockserver.verify.Verification

        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

Examples of org.mockserver.verify.Verification

        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

Examples of org.mockserver.verify.Verification

        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

Examples of org.mockserver.verify.Verification

            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
TOP
Copyright © 2018 www.massapi.com. 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.