Search in sources :

Example 1 with VerificationDTO

use of org.mockserver.serialization.model.VerificationDTO in project mockserver by mock-server.

the class VerificationSerializerIntegrationTest method shouldSerializeCompleteObject.

@Test
public void shouldSerializeCompleteObject() {
    // when
    String jsonExpectation = new VerificationSerializer(new MockServerLogger()).serialize(new VerificationDTO().setHttpRequest(new HttpRequestDTO(request().withMethod("GET").withPath("somepath"))).setTimes(new VerificationTimesDTO(VerificationTimes.between(2, 3))).buildObject());
    // then
    assertEquals("{" + NEW_LINE + "  \"httpRequest\" : {" + NEW_LINE + "    \"method\" : \"GET\"," + NEW_LINE + "    \"path\" : \"somepath\"" + NEW_LINE + "  }," + NEW_LINE + "  \"times\" : {" + NEW_LINE + "    \"atLeast\" : 2," + NEW_LINE + "    \"atMost\" : 3" + NEW_LINE + "  }" + NEW_LINE + "}", jsonExpectation);
}
Also used : MockServerLogger(org.mockserver.logging.MockServerLogger) VerificationDTO(org.mockserver.serialization.model.VerificationDTO) VerificationTimesDTO(org.mockserver.serialization.model.VerificationTimesDTO) HttpRequestDTO(org.mockserver.serialization.model.HttpRequestDTO) Test(org.junit.Test)

Example 2 with VerificationDTO

use of org.mockserver.serialization.model.VerificationDTO in project mockserver by mock-server.

the class VerificationSerializerIntegrationTest method shouldDeserializePartialObject.

@Test
public void shouldDeserializePartialObject() {
    // given
    String requestBytes = "{" + NEW_LINE + "  \"httpRequest\" : {" + NEW_LINE + "  }" + NEW_LINE + "}";
    // when
    Verification verification = new VerificationSerializer(new MockServerLogger()).deserialize(requestBytes);
    // then
    assertEquals(new VerificationDTO().setHttpRequest(new HttpRequestDTO(request())).buildObject(), verification);
}
Also used : MockServerLogger(org.mockserver.logging.MockServerLogger) VerificationDTO(org.mockserver.serialization.model.VerificationDTO) Verification(org.mockserver.verify.Verification) HttpRequestDTO(org.mockserver.serialization.model.HttpRequestDTO) Test(org.junit.Test)

Example 3 with VerificationDTO

use of org.mockserver.serialization.model.VerificationDTO in project mockserver by mock-server.

the class VerificationSerializerIntegrationTest method shouldDeserializeCompleteObject.

@Test
public void shouldDeserializeCompleteObject() {
    // given
    String requestBytes = "{" + NEW_LINE + "  \"httpRequest\" : {" + NEW_LINE + "    \"method\" : \"GET\"," + NEW_LINE + "    \"path\" : \"somepath\"" + NEW_LINE + "  }," + NEW_LINE + "  \"times\" : {" + NEW_LINE + "    \"atLeast\" : 2," + NEW_LINE + "    \"atMost\" : 3" + NEW_LINE + "  }" + NEW_LINE + "}";
    // when
    Verification verification = new VerificationSerializer(new MockServerLogger()).deserialize(requestBytes);
    // then
    assertEquals(new VerificationDTO().setHttpRequest(new HttpRequestDTO(request().withMethod("GET").withPath("somepath"))).setTimes(new VerificationTimesDTO(VerificationTimes.between(2, 3))).buildObject(), verification);
}
Also used : MockServerLogger(org.mockserver.logging.MockServerLogger) VerificationDTO(org.mockserver.serialization.model.VerificationDTO) VerificationTimesDTO(org.mockserver.serialization.model.VerificationTimesDTO) Verification(org.mockserver.verify.Verification) HttpRequestDTO(org.mockserver.serialization.model.HttpRequestDTO) Test(org.junit.Test)

Example 4 with VerificationDTO

use of org.mockserver.serialization.model.VerificationDTO in project mockserver by mock-server.

the class VerificationSerializerIntegrationTest method shouldSerializePartialObject.

@Test
public void shouldSerializePartialObject() {
    // when
    String jsonExpectation = new VerificationSerializer(new MockServerLogger()).serialize(new VerificationDTO().setHttpRequest(new HttpRequestDTO(request())).buildObject());
    // then
    assertEquals("{" + NEW_LINE + "  \"httpRequest\" : { }," + NEW_LINE + "  \"times\" : {" + NEW_LINE + "    \"atLeast\" : 1," + NEW_LINE + "    \"atMost\" : 1" + NEW_LINE + "  }" + NEW_LINE + "}", jsonExpectation);
}
Also used : MockServerLogger(org.mockserver.logging.MockServerLogger) VerificationDTO(org.mockserver.serialization.model.VerificationDTO) HttpRequestDTO(org.mockserver.serialization.model.HttpRequestDTO) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 MockServerLogger (org.mockserver.logging.MockServerLogger)4 HttpRequestDTO (org.mockserver.serialization.model.HttpRequestDTO)4 VerificationDTO (org.mockserver.serialization.model.VerificationDTO)4 VerificationTimesDTO (org.mockserver.serialization.model.VerificationTimesDTO)2 Verification (org.mockserver.verify.Verification)2