Search in sources :

Example 11 with MockServerEventLog

use of org.mockserver.log.MockServerEventLog in project mockserver by mock-server.

the class HttpStateTest method shouldVerifySequenceFailureWithCallback.

@Test
public void shouldVerifySequenceFailureWithCallback() throws Exception {
    // given
    MockServerEventLog mockServerEventLog = httpState.getMockServerLog();
    mockServerEventLog.add(new LogEntry().setHttpRequest(request("one")).setType(RECEIVED_REQUEST));
    mockServerEventLog.add(new LogEntry().setHttpRequest(request("two")).setType(RECEIVED_REQUEST));
    mockServerEventLog.add(new LogEntry().setHttpRequest(request("three")).setType(RECEIVED_REQUEST));
    CompletableFuture<String> verificationResult = new CompletableFuture<>();
    // when
    httpState.verify(new VerificationSequence().withRequests(request("three"), request("one")), verificationResult::complete);
    // then
    assertThat(verificationResult.get(5, SECONDS), is("Request sequence not found, expected:<[ {" + NEW_LINE + "  \"path\" : \"three\"" + NEW_LINE + "}, {" + NEW_LINE + "  \"path\" : \"one\"" + NEW_LINE + "} ]> but was:<[ {" + NEW_LINE + "  \"path\" : \"one\"" + NEW_LINE + "}, {" + NEW_LINE + "  \"path\" : \"two\"" + NEW_LINE + "}, {" + NEW_LINE + "  \"path\" : \"three\"" + NEW_LINE + "} ]>"));
}
Also used : MockServerEventLog(org.mockserver.log.MockServerEventLog) CompletableFuture(java.util.concurrent.CompletableFuture) VerificationSequence(org.mockserver.verify.VerificationSequence) LogEntry(org.mockserver.log.model.LogEntry) Test(org.junit.Test)

Aggregations

MockServerEventLog (org.mockserver.log.MockServerEventLog)11 LogEntry (org.mockserver.log.model.LogEntry)11 Test (org.junit.Test)10 Verification (org.mockserver.verify.Verification)5 VerificationSequence (org.mockserver.verify.VerificationSequence)5 CompletableFuture (java.util.concurrent.CompletableFuture)4 HttpRequest (org.mockserver.model.HttpRequest)4 TextWebSocketFrame (io.netty.handler.codec.http.websocketx.TextWebSocketFrame)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 MockServerLogger (org.mockserver.logging.MockServerLogger)1 HttpState (org.mockserver.mock.HttpState)1 RequestMatchers (org.mockserver.mock.RequestMatchers)1 Scheduler (org.mockserver.scheduler.Scheduler)1