use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationSequenceTest method shouldFailVerificationSequenceWithTwoRequestsSecondIncorrect.
@Test
public void shouldFailVerificationSequenceWithTwoRequestsSecondIncorrect() {
// when
mockServerEventLog.add(new LogEntry().setHttpRequest(request("one")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("multi")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("three")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("multi")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("four")).setType(RECEIVED_REQUEST));
// then - next to each other
assertThat(verify(new VerificationSequence().withRequests(request("one"), request("five"))), is("Request sequence not found, expected:<[ {" + NEW_LINE + " \"path\" : \"one\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"five\"" + NEW_LINE + "} ]> but was:<[ {" + NEW_LINE + " \"path\" : \"one\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"multi\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"three\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"multi\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"four\"" + NEW_LINE + "} ]>"));
assertThat(verify(new VerificationSequence().withRequests(request("multi"), request("five"))), is("Request sequence not found, expected:<[ {" + NEW_LINE + " \"path\" : \"multi\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"five\"" + NEW_LINE + "} ]> but was:<[ {" + NEW_LINE + " \"path\" : \"one\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"multi\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"three\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"multi\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"four\"" + NEW_LINE + "} ]>"));
assertThat(verify(new VerificationSequence().withRequests(request("three"), request("five"))), is("Request sequence not found, expected:<[ {" + NEW_LINE + " \"path\" : \"three\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"five\"" + NEW_LINE + "} ]> but was:<[ {" + NEW_LINE + " \"path\" : \"one\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"multi\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"three\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"multi\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"four\"" + NEW_LINE + "} ]>"));
}
use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationSequenceTest method shouldPassVerificationSequenceWithNoRequest.
@Test
public void shouldPassVerificationSequenceWithNoRequest() {
// when
mockServerEventLog.add(new LogEntry().setHttpRequest(request("one")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("multi")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("three")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("multi")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("four")).setType(RECEIVED_REQUEST));
// then
assertThat(verify(new VerificationSequence().withRequests()), is(""));
}
use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationSequenceTest method shouldFailVerificationSequenceWithOneRequest.
@Test
public void shouldFailVerificationSequenceWithOneRequest() {
// when
mockServerEventLog.add(new LogEntry().setHttpRequest(request("one")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("multi")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("three")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("multi")).setType(RECEIVED_REQUEST));
mockServerEventLog.add(new LogEntry().setHttpRequest(request("four")).setType(RECEIVED_REQUEST));
// then
assertThat(verify(new VerificationSequence().withRequests(request("five"))), is("Request sequence not found, expected:<[ {" + NEW_LINE + " \"path\" : \"five\"" + NEW_LINE + "} ]> but was:<[ {" + NEW_LINE + " \"path\" : \"one\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"multi\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"three\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"multi\"" + NEW_LINE + "}, {" + NEW_LINE + " \"path\" : \"four\"" + NEW_LINE + "} ]>"));
}
use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationTest method shouldPassVerificationWithExactlyZeroTimes.
@Test
public void shouldPassVerificationWithExactlyZeroTimes() {
// 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")).withTimes(exactly(0))), is(""));
}
use of org.mockserver.log.model.LogEntry in project mockserver by mock-server.
the class MockServerEventLogRequestLogEntryVerificationTest method shouldFailVerificationWithNoInteractions.
@Test
public void shouldFailVerificationWithNoInteractions() {
// given
HttpRequest httpRequest = new HttpRequest();
// when
mockServerEventLog.add(new LogEntry().setHttpRequest(httpRequest).setType(RECEIVED_REQUEST));
// then
assertThat(verify(verification().withRequest(request()).withTimes(exactly(0))), is("Request not found exactly 0 times, expected:<{ }> but was:<{ }>"));
}
Aggregations