use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationTest method shouldPassVerificationWithExactlyTwoTimes.
@Test
public void shouldPassVerificationWithExactlyTwoTimes() {
// given
HttpRequest httpRequest = new HttpRequest().withPath("some_path");
HttpRequest otherHttpRequest = new HttpRequest().withPath("some_other_path");
// when
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(otherHttpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
// then
assertThat(verify(verification().withRequest(new HttpRequest().withPath("some_path")).withTimes(exactly(2))), is(""));
}
use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationTest method shouldFailVerificationWithDefaultTimes.
@Test
public void shouldFailVerificationWithDefaultTimes() {
// given
HttpRequest httpRequest = new HttpRequest().withPath("some_path");
HttpRequest otherHttpRequest = new HttpRequest().withPath("some_other_path");
// when
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(otherHttpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
// then
assertThat(verify(verification().withRequest(new HttpRequest().withPath("some_non_matching_path"))), is("Request not found at least once, expected:<{" + NEW_LINE + " \"path\" : \"some_non_matching_path\"" + NEW_LINE + "}> but was:<[ {" + NEW_LINE + " \"path\" : \"some_path\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"some_other_path\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"some_path\"" + NEW_LINE + "} ]>"));
}
use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationTest method shouldPassVerificationWithAtLeastTwoTimes.
@Test
public void shouldPassVerificationWithAtLeastTwoTimes() {
// given
HttpRequest httpRequest = new HttpRequest().withPath("some_path");
HttpRequest otherHttpRequest = new HttpRequest().withPath("some_other_path");
// when
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(otherHttpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
// then
assertThat(verify(verification().withRequest(new HttpRequest().withPath("some_path")).withTimes(atLeast(2))), is(""));
}
use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationTest method shouldFailVerificationWithLimitedReturnedRequestsViaConfiguration.
@Test
public void shouldFailVerificationWithLimitedReturnedRequestsViaConfiguration() {
Integer originalMaximumNumberOfRequestToReturnInVerificationFailure = ConfigurationProperties.maximumNumberOfRequestToReturnInVerificationFailure();
try {
// given
HttpRequest httpRequest = new HttpRequest().withPath("some_path");
HttpRequest otherHttpRequest = new HttpRequest().withPath("some_other_path");
ConfigurationProperties.maximumNumberOfRequestToReturnInVerificationFailure(1);
// when
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(otherHttpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
// then
assertThat(verify(verification().withRequest(new HttpRequest().withPath("some_other_path")).withTimes(atLeast(2))), is("Request not found at least 2 times, expected:<{" + NEW_LINE + " \"path\" : \"some_other_path\"" + NEW_LINE + "}> but was not found, found 3 other requests"));
} finally {
ConfigurationProperties.maximumNumberOfRequestToReturnInVerificationFailure(originalMaximumNumberOfRequestToReturnInVerificationFailure);
}
}
use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationTest method shouldFailVerificationWithAtLeastTwoTimes.
@Test
public void shouldFailVerificationWithAtLeastTwoTimes() {
// given
HttpRequest httpRequest = new HttpRequest().withPath("some_path");
HttpRequest otherHttpRequest = new HttpRequest().withPath("some_other_path");
// when
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(otherHttpRequest).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
// then
assertThat(verify(verification().withRequest(new HttpRequest().withPath("some_other_path")).withTimes(atLeast(2))), is("Request not found at least 2 times, expected:<{" + NEW_LINE + " \"path\" : \"some_other_path\"" + NEW_LINE + "}> but was:<[ {" + NEW_LINE + " \"path\" : \"some_path\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"some_other_path\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"some_path\"" + NEW_LINE + "} ]>"));
}
Aggregations