Search in sources :

Example 1 with VerificationTimes

use of org.mockserver.verify.VerificationTimes in project mockserver by mock-server.

the class VerificationDTOTest method shouldReturnValuesSetInConstructor.

@Test
public void shouldReturnValuesSetInConstructor() {
    // given
    HttpRequest request = request();
    VerificationTimes times = VerificationTimes.atLeast(1);
    Verification verification = verification().withRequest(request).withTimes(times);
    // when
    VerificationDTO verificationDTO = new VerificationDTO(verification);
    // then
    assertThat(verificationDTO.getHttpRequest(), is(new HttpRequestDTO(request)));
    assertThat(verificationDTO.getTimes(), is(new VerificationTimesDTO(times)));
}
Also used : HttpRequest(org.mockserver.model.HttpRequest) VerificationTimes(org.mockserver.verify.VerificationTimes) Verification(org.mockserver.verify.Verification) Test(org.junit.Test)

Example 2 with VerificationTimes

use of org.mockserver.verify.VerificationTimes in project mockserver by mock-server.

the class VerificationTimesDTOTest method shouldBuildCorrectObject.

@Test
public void shouldBuildCorrectObject() {
    // when
    VerificationTimes times = new VerificationTimesDTO(VerificationTimes.never()).buildObject();
    // then
    assertThat(times.getAtLeast(), is(0));
    assertThat(times.getAtMost(), is(0));
    // when
    times = new VerificationTimesDTO(VerificationTimes.once()).buildObject();
    // then
    assertThat(times.getAtLeast(), is(1));
    assertThat(times.getAtMost(), is(1));
    // when
    times = new VerificationTimesDTO(VerificationTimes.exactly(2)).buildObject();
    // then
    assertThat(times.getAtLeast(), is(2));
    assertThat(times.getAtMost(), is(2));
    // when
    times = new VerificationTimesDTO(VerificationTimes.atLeast(3)).buildObject();
    // then
    assertThat(times.getAtLeast(), is(3));
    assertThat(times.getAtMost(), is(-1));
    // when
    times = new VerificationTimesDTO(VerificationTimes.atMost(4)).buildObject();
    // then
    assertThat(times.getAtLeast(), is(-1));
    assertThat(times.getAtMost(), is(4));
}
Also used : VerificationTimes(org.mockserver.verify.VerificationTimes) Test(org.junit.Test)

Example 3 with VerificationTimes

use of org.mockserver.verify.VerificationTimes in project mockserver by mock-server.

the class VerificationTimesTest method shouldCreateCorrectObjectForAtLeast.

@Test
public void shouldCreateCorrectObjectForAtLeast() {
    // when
    VerificationTimes times = atLeast(2);
    // then
    assertThat(times.getAtLeast(), is(2));
    assertThat(times.getAtMost(), is(-1));
}
Also used : VerificationTimes(org.mockserver.verify.VerificationTimes) Test(org.junit.Test)

Example 4 with VerificationTimes

use of org.mockserver.verify.VerificationTimes in project mockserver by mock-server.

the class VerificationTimesTest method shouldMatchAtMostZeroCorrectly.

@Test
public void shouldMatchAtMostZeroCorrectly() {
    // when
    VerificationTimes times = atMost(0);
    // then
    assertThat(times.matches(0), is(true));
    assertThat(times.matches(1), is(false));
    assertThat(times.matches(2), is(false));
    assertThat(times.matches(3), is(false));
}
Also used : VerificationTimes(org.mockserver.verify.VerificationTimes) Test(org.junit.Test)

Example 5 with VerificationTimes

use of org.mockserver.verify.VerificationTimes in project mockserver by mock-server.

the class VerificationTimesTest method shouldCreateCorrectObjectForAtMost.

@Test
public void shouldCreateCorrectObjectForAtMost() {
    // when
    VerificationTimes times = atMost(2);
    // then
    assertThat(times.getAtLeast(), is(-1));
    assertThat(times.getAtMost(), is(2));
}
Also used : VerificationTimes(org.mockserver.verify.VerificationTimes) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 VerificationTimes (org.mockserver.verify.VerificationTimes)14 HttpRequest (org.mockserver.model.HttpRequest)2 Verification (org.mockserver.verify.Verification)2